generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Lol Custom Lua Compiler

Previous Thread :: Next Thread 
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
18 Oct 2011 06:25 PM
I have plans to write my own custom Lua compiler.
If finished, this should take normal Lua code and make it faster (depending on if I can find enough ways to optimize things)
It would also enable new things.

Features to be:
- cool operators like "+=", and "++"
- goto / labels (lua 5.2 style)
- function inlining
- a decent C like preprocessor
- might try cool peephole optimizations
- general localization optimizations

suggestions/opinions

gogogo
Report Abuse
LocalChum is not online. LocalChum
Joined: 04 Mar 2011
Total Posts: 6906
18 Oct 2011 06:26 PM
OYUS!!!!!

liek, optional/predefined/watever in functions

ex:

function NOOB(nob = "ahhhhh yea")

end
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
18 Oct 2011 06:28 PM
Make it so that I can create a dinosaur that can only be edited by itself.

local dino = new "dinosaur" {f = function(d) d.v = not d.v end, v = false}


print(dino.v) --> false
dino.v = true --> unknown exception
dino.f()
print(dino.v) --> true

I ate my reply button so haters can't hate.
Report Abuse
mew9O3 is not online. mew9O3
Joined: 10 Jun 2011
Total Posts: 179
18 Oct 2011 06:28 PM
NecroBumpist AKA Jaccob
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
18 Oct 2011 06:29 PM
[ Content Deleted ]
Report Abuse
babyzander44 is not online. babyzander44
Joined: 14 Aug 2011
Total Posts: 756
18 Oct 2011 06:30 PM
Mew9O3 AKA noob
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
18 Oct 2011 06:31 PM
LocalChum, yeah I could do that.
Arceus, nope. That's a metatables thing, not a compiler feature. Go lrn2script.

In case xLEGOx is reading: I tried reading "Lets Build a Compiler" by Jack Crenshaw, but it was using the assembler as a crutch it seemed with the way it handled variables. It's useful for expression handling, but I don't know what else. Any other compiler theory recommendations ? Such as decent methods of generating what was referred to as P-code in that tutorial, or intermediary code between a front-end lexer and back-end compiler/linker...
Report Abuse
LocalChum is not online. LocalChum
Joined: 04 Mar 2011
Total Posts: 6906
18 Oct 2011 06:31 PM
Yeah, classes that can be inherited, along with public/protected/private/virtual members. :3
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
18 Oct 2011 06:33 PM
"Arceus, nope. That's a metatables thing, not a compiler feature"

IT CAN BE WHAT IT WANTS TO BE
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
18 Oct 2011 06:34 PM
- Documentation generation
- 'continue' statement
- 'switch' statement
- bitwise operators? (pops in some extra inline functions)

*thinking*

~+[Y U NO WORSHIP BLOCCO?]+~
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
18 Oct 2011 06:35 PM
LocalChum, again, that's something that can already easily be implemented in Lua. I do not wish to make massive changes to the language such as shifting it from a dynamic procedural language to a crappy dynamic OOP language.
Report Abuse
Oyus93 is not online. Oyus93
Joined: 26 Apr 2011
Total Posts: 166
18 Oct 2011 06:36 PM
"OYUS!!!!!"

Yes?

Anyways, GO NECRO GO, I WANT TO SEE THIS
Report Abuse
LocalChum is not online. LocalChum
Joined: 04 Mar 2011
Total Posts: 6906
18 Oct 2011 06:38 PM
^ TROLOLOL
Report Abuse
mew9O3 is not online. mew9O3
Joined: 10 Jun 2011
Total Posts: 179
18 Oct 2011 06:38 PM
i wanna see it.
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
18 Oct 2011 06:39 PM
popinman, good idea. I'm not too sure about 'switch' and 'continue', but I'll look into it. Bitwise operators are also possible, Linoleum once shared some fast integer routines for bitwise operations that didn't rely on an external library.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
18 Oct 2011 06:41 PM
I HASH AN LUA COMPILER!!!!!!


function compile(strang)
loadstring(strang);
end
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
18 Oct 2011 06:42 PM
@Necro:
You can just "borrow" my intermediary Lua bytecode generator which I use for project like you're doing right now, then you can forget having to write one of those and get right to the actual meat and bones of the project:
http://codepad.org/P7LieyOe

It even has goto/label management and constant tracking. Example usage:

local c = MakeAssembler()
c.beginChunk("main", {MaxStack=5, ParamCount=2, VarArg=0})
c.emitLoadK(0, 10) --R(0) = 10
c.emitLabel("begin-loop") --label the start of the loop
c.emitGetGlobal(1, "print")
c.emitLoadK(2, "Hello, World")
c.emitCall(1, 1, 0) --print("Hello, World")
c.emitArith(0, 0, '-', c.getConstIndex(1)) --R(0) -= 1
c.emitCompare(0, '>=', c.getConstIndex(0))
c.emitJumpLabel("begin-loop")
c.emitReturn(0, 0)
loadstring(c.endChunk())() -->load and run the finished chunk

Currently I've left the NewTable opcode unimplemented, it still needs code to translate the arguments into the correct 8-bit floating point format. You can use it but currently you'll have to manually translate the arguments.


Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
18 Oct 2011 06:42 PM
And this sounds similar to oysi's C-lua.
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
18 Oct 2011 06:46 PM
Jeez xLEGOx, you've done freaking everything in this field already lol.
I'll take a look at it, thanks!
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
18 Oct 2011 06:48 PM
@Necro

your post count - 2000 == 1337?

Java/C/C++? O.o

~+[Y U NO WORSHIP BLOCCO?]+~
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
18 Oct 2011 06:51 PM
[ Content Deleted ]
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
18 Oct 2011 08:53 PM
xLEGOx,

about the NEWTABLE integer conversion, I found a function to do that a few days ago.

------------------------------------------------------------------------
-- converts an integer to a "floating point byte", represented as
-- (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
-- eeeee != 0 and (xxx) otherwise.
------------------------------------------------------------------------
function int2fb(x)
local e = 0 -- exponent
while x >= 16 do
x = math.floor((x + 1) / 2)
e = e + 1
end
if x < 8 then
return x
else
return ((e + 1) * 8) + (x - 8)
end
end

It was in a Lua implementation of Lua 5.1.3 (it literally had files like luac.lua, lparser.lua, llex.lua, ldump.lua, lopcodes.lua)
I think this should do the job, not 100 percent sure as I haven't tested it and compared it against a natural result...
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
18 Oct 2011 09:09 PM
Stole it out of ChunkSpy, didn't you? I can do that too by the way, I just haven't yet since my own language didn't need those features yet, I'm still working on other parts of it.
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
18 Oct 2011 09:16 PM
>steal
noooooo

I borrowed it from a Lua implementation (like, literally a C -> Lua translation) of Lua called Yueliang (I think I found it in the 5.1.3 "lparser.lua" file), it's a little outdated, but it should work.

And I have no doubts about your ability to do this, I've seen your 64 bit float conversions from your LASM suite.

Now to go fix up your Lexer (http://pastebin.com/RavhR1SF) that you never tested :3
I'll use that again!
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
18 Oct 2011 09:25 PM
I guess I was right then, considering that ChunkSpy borrowed from MetaLua which in turn borrowed from Yueliang =P

Anyways, you might as well get my LuaText script to do the Parsing for you while you while you're at it, and then all you have left to do is implement a code generator:
http://wiki.roblox.com/index.php/User:XLEGOx/luatext
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image