lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Dear Lua community,

I am glad to announce parser-gen, a parser generator that I created together with LabLua this summer. The code can be found on GitHub: https://github.com/vsbenas/parser-gen

The tool extends the LPeg(Label) module to provide these features:
1) generate parsers based on a PEG grammar description (similar to ANTLR and re);
2) allow easier error description and reporting;
3) automatically handle space characters, comments or any other patterns set by the user;
4) build ASTs automatically based on the rule name;
5) generate recovery grammars automatically, build partial ASTs for inputs with errors;
6) generate error labels for LL(1) grammars.

All these features should make the description of parsers easier, faster and more concise. Any of these features can be disabled if necessary (for example, to build a custom AST).

The grammars used for this tool are described using a PEG-like syntax, that is identical to the one provided by the "re" module, with some extensions used in the "relabel" module and "ANTLR" grammars. See a working example parser here: 
https://github.com/vsbenas/parser-gen#example-tiny-parser

For a more advanced example check out the Lua parser: 
https://github.com/vsbenas/parser-gen/blob/master/parsers/lua-parser.lua

The package can be installed using luarocks:
$ luarocks install parser-gen

This is a beta release, please report any bugs when found.