grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

Lua Grammar seems off, does not parse Pound / # / Length operator properly?

Open N0K0 opened this issue 8 months ago • 1 comments

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}

Image

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

N0K0 avatar Mar 02 '25 09:03 N0K0