My fork of LuaJIT with fancy syntax
c
Archived 9 months ago
R
Michael
Playing Custom Status
Copy Paster!
I wanted operators like += -= \*= /=, but in Lua. So I forked LuaJIT and patched it. The result is that I slightly changed my mind and now this operator is universal and suits even for `or`, `and` etc. like so:
```
obj.field =~+ 7; // obj.field = obj.field + 7
arg1 =~ or 78; // arg1 = arg1 or 78
arg2 =~ or arg1 and "foobar"; // arg2 = arg2 or arg1 and "foobar";
```
Also it has very custom operators like in Haskell (you can define operators `<&>, &><&, ^&*^, ^^^, ^-^, |>, ||<>, qwerty, is, isinstanceof, <<++<>><<><>>-->>>>.` and so on).
Also you can use this to compile your bytecode, and then feed the bytecode into unchanged upstream LuaJIT, and this should work since I didn't patch the VM
It took me the time about 9 months to figure out and get hands dirty into the lexer and the compiler into bytecode (actually lj_lex.c and lj_parse.c) which are the main things that determine the syntax
Of course while I was working on it there were many other changes, but with the achievement of `=~` operator I consider the new language formed (however syntax may change over time)
The syntax is now more close to C-like one, however still is very similar to Lua. Also, all Lua code which LuaJIT is compatible with - is also compatible with this thing (I'm sure for 99.9%, if some plain LuaJIT code happens to not work please report an issue). I couldn't see this language with losing possibility to import existing libraries.
For documentation you can refer to luarjit.md in the root of repo.
https://github.com/reglnk/luarjit2
For examples (there are few for now), you can see this repo. So far this is a simple wrapper around GDB that captures commands and output from the debugger, but actually is unfinished and does nothing. And, by the way, another example of the same thing but in other experimental language is present here.
https://github.com/reglnk/rltrace
The next application which I see for it is my upcoming 3d engine which I probably will post later. Thanks for your attention.
