grammars-v4
grammars-v4 copied to clipboard
Problem when there are consecutive function calls on the right side of the assignment statement
local a = GetClass(data).OtherFunc(self, ohterData)
GetClass is a function that returns an object with a member function OtherFunc.
GetClass(data).OtherFunc(self, otherData) should be parsed as a tree structure where the root node is a function call, and the child node is also a function call.
The parsing result of GetClass(data).OtherFunc(self, ohterData) when parsing in a single line is inconsistent with the parsing result when placed on the right side of the assignment statement.
local a = GetClass(data).OtherFunc(self, ohterData)
GetClass(data).OtherFunc(self, ohterData)
How can I resolve this issue?
Please clarify the grammar you are talking about.
Got it, I've seen Lua
on the image.
Instead of:
prefixexp
: NAME ('[' exp ']' | '.' NAME)*
| functioncall ('[' exp ']' | '.' NAME)*
| '(' exp ')' ('[' exp ']' | '.' NAME)*
;
try this:
prefixexp
: functioncall ('[' exp ']' | '.' NAME)*
| NAME ('[' exp ']' | '.' NAME)*
| '(' exp ')' ('[' exp ']' | '.' NAME)*
;
This seems to be an exact duplicate of https://github.com/antlr/grammars-v4/issues/3885
This seems to be an exact duplicate of https://github.com/antlr/grammars-v4/issues/3885
yes,I saw the question after I asked it.
Instead of:
prefixexp : NAME ('[' exp ']' | '.' NAME)* | functioncall ('[' exp ']' | '.' NAME)* | '(' exp ')' ('[' exp ']' | '.' NAME)* ;
try this:
prefixexp : functioncall ('[' exp ']' | '.' NAME)* | NAME ('[' exp ']' | '.' NAME)* | '(' exp ')' ('[' exp ']' | '.' NAME)* ;
Yes, I have reordered the syntax rules like this, but I saw kaby76's comment: https://github.com/antlr/grammars-v4/issues/3885#issuecomment-1852090676, so this issue might require a different solution.
Yes, I have reordered the syntax rules like this, but I saw kaby76's comment: #3885 (comment), so this issue might require a different solution.
Of course, I may be wrong! Reordering may fix your problem, but I think the problem is that it doesn't solve the reported ambiguity.
Yes, I have reordered the syntax rules like this, but I saw kaby76's comment: #3885 (comment), so this issue might require a different solution.
Of course, I may be wrong! Reordering may fix your problem, but I think the problem is that it doesn't solve the reported ambiguity.
Is there a plan to fix this issue?
... Is there a plan to fix this issue?
Feel free to submit a PR including some tests to validate it 😄