Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to reuse the Lua parser?

I know how to embed Lua in other languages, but I would like to re-use ONLY the parser to parse code and give me the result as AST for instance. What is the easiest way of doing that with the Lua platform?

Thanks!

like image 548
CharlesS Avatar asked Nov 04 '22 08:11

CharlesS


1 Answers

Someone already made an ANTLR grammar for the Lua language:

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

Or if you're using ANTLR v4:

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

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

like image 84
John Zwinck Avatar answered Nov 10 '22 16:11

John Zwinck