What is the best way to reuse a Lua analyzer?

I know how to embed Lua in other languages, but I would like to use ONLY the parser for code analysis and give me the result, for example, for AST. What is the easiest way to do this using the Lua platform?

Thank!

+5
source share
1 answer

Someone already made an ANTLR grammar for Lua:

http://www.antlr3.org/grammar/1178608849736/Lua.g

Or if you are using ANTLR v4:

https://github.com/antlr/grammars-v4/blob/master/lua/Lua.g4

I used ANTLR for several projects with good results. It will generate a parser C (ANTLR v3) or C ++ (ANTLR v2), including AST generation, if you ask for it.

+3
source

All Articles