Hi! So now that my life is moderately in order, I’d like to share some plans I have for this plugin. Going through the compilers course at Uni made me realise my approach for this was rather naive (and also, turns out trying to deal with efficiently snapshotting mutable custom data structures makes for some incredibly hard to maintain code). I’ve been meaning to start a rewrite for some time, but I’m glad I put it off because this gave me some time to think and research.
So, to do this by the book, I’m going to use lattices to model the Lua heap at different program points. After reading his paper and his code, I think going to use a similar approach as Jan Midtgaard’s LuaTA.
For this to work, I will need some good immutable data structures and I figured, sure, Immutable.js is cool and fine, but let’s take it one step further, so I decided I’d write the static analysis code in ReasonML and compile it to JS.
I played with Reason/OCaml these past weeks and managed to parse some Lua with a Menhir parser on the OCaml side, but compiled into JS, tail calls are not optimised and it overflows the stack on mid-sized Lua files.
So, I figured I’d try to use some other parser and I stumbled upon Chevrotain, which seems to be fast and, most importantly, has error recovery, so it’s much better suited for in-editor use than the previous parser. So… yeah… I’ll write a Lua grammar… that will be fun!
This project made me research and learn a lot of stuff and I’m really happy about that. I’m still doing this in my spare time, though, between a part-time job and actually working on the game, so not making any release promises, but at least now the path to implementation is clearer.