boolangery / py-lua-parser

A Lua parser and AST builder written in Python.
MIT License
117 stars 36 forks source link

Ambiguous syntax detected #53

Open zumoshi opened 10 months ago

zumoshi commented 10 months ago

Hi

I've failed to reproduce the syntax error described in Lua runtime for both simple cases e.g.

io.write
('A')

(IDE One result)

and the example mentioned in the link in this comment:

z = (function(...) print(...); return "Bar"; end)
("Foo"):sub(1,1)

io.write(z)

(IDE One result)

They work fine in both the online Lua playground and IDE One, but fail to parse with this library getting this error:

File "/home/.../site-packages/luaparser/builder.py", line 697, in parse_tail
    raise SyntaxException(
luaparser.builder.SyntaxException: (2,4): Error: Ambiguous syntax detected

Was this a limitation of older Lua versions or ...?

For context my use case was static analysis of an existing working code base, and I was forced to patch it to be able to get it parsed by this library which was not ideal.

Is there any chance this error can be removed with ambiguity solved the same way Lua itself does? or was there another reason for this to be added that I missed? I didn't find any other issues/pull requests referencing this error.

Thanks.

Edit: for the test case used Lua runtime resolves it to as if there was no newline present image