Closed britzl closed 3 years ago
HI @britzl . I've started some work on this in https://github.com/stevenjohnstone/lua-grammar/commit/7b4bad968d57e28c62bfe5deac6a4610a6a46594.
Which language are you targeting? Do you have any example code so I can indicate how it'd need to be changed to accommodate the grammar changes?
I'm working on the Defold game engine (www.defold.com) which uses LuaJIT/Lua 5.1 for game logic scripting. We're going to use Antlr and the Lua grammar to parse all game logic and strip comments, identify all require()'d Lua modules and find use of a couple of game engine specific APIs. We used to have a bunch of regular expressions to do these tasks but it has always been pretty brittle and prone to miss things or include things that should have been excluded.
Oh, and we plan to use the Java runtime for Antlr (currently antlr-runtime-4.9.1.jar).
Hi @britzl! Could you take a look at https://github.com/stevenjohnstone/lua-grammar/commit/afcca492e7ea2203ade5b4d374f4128b33d0981f to see if my changes make sense for your use case?
Thanks! I'm going to give this a try now!
I can confirm that your changes solved the problems I had. Thanks Steven!
I've found two instances where the grammar is incorrect and doesn't detect function calls properly. The first scenario doesn't detect the function call at all:
The second scenario includes too much in the function call:
This gets detected as foo("bar", "hello") as can be seen here:
Also discussed here: https://github.com/antlr/grammars-v4/issues/1824#issuecomment-765591643