grammars-v4
grammars-v4 copied to clipboard
Lua Grammar seems off, does not parse Pound / # / Length operator properly?
Hey, I'm relatively new to Antlr so sorry if this is intended to be fixed downstream by implementers of the parser. Running the Lua grammar i hit a undefined token
http://lab.antlr.org/
https://github.com/antlr/grammars-v4/blob/master/lua/LuaLexer.g4 https://github.com/antlr/grammars-v4/blob/master/lua/LuaParser.g4
start rule: start_
Sample:
local a, b
a = "test"
b = #a
return b
Error message
5:0 extraneous input 'return' expecting {'function', 'nil', 'false', 'true', '~', '-', '#', '(', 'not', '{', '...', NAME, NORMALSTRING, CHARSTRING, LONGSTRING, INT, HEX, FLOAT, HEX_FLOAT}
The python lua parser has fixed it in the builder for example: https://github.com/boolangery/py-lua-parser/blob/master/luaparser/builder.py#L393
lab.antlr.org cannot be used with lua because it contains Antlr "actions". https://github.com/antlr/grammars-v4/blob/a9c0af477e3047be24abf525043db4e3b71d5f08/lua/LuaLexer.g4#L123 It should not even offer the list of grammars UI because lab.antlr.org uses grammars.json, which is constructed to weed out grammars that have actions.