Open RobertoRoos opened 1 day ago
I have a potential fix for this problem:
Variable: CommentAny name=ID (',' ID) (address=Address)? ':' type=VariableType ((arglist=ArgList) | (AssignmentSymbol value=AssignmentValue))? ';' comment=CommentLine? ;
AssignmentSymbol: (':=') | ('REF=') ;
VariableType: (array=VariableTypeArray)? (pointer=PointerLike 'TO')? name=BaseType ;
AssignmentValue: ExpressionSemicolon | Expression | ArgList ;
ExpressionSemicolon: /'[^']*'/ ;
Issue with arglist and AssignmentSymbol: The problem seems to be in the Variable rule where either arglist or AssignmentSymbol can be matched. This creates ambiguity because only one of these should be valid at any given time.
Order of AssignmentValue: The second fix was to adjust the order of the AssignmentValue alternatives. By prioritizing ExpressionSemicolon, the parser can first check for a semicolon at the end of the expression. If no semicolon is found, it will proceed to evaluate the other options (Expression or ArgList).
Regex for Semicolons in Strings: Finally, the regex for ExpressionSemicolon was updated to allow semicolons within a string. This ensures that strings containing semicolons are parsed correctly without prematurely ending the expression.
These adjustments aim to resolve the ambiguity between arglist and AssignmentSymbol in the Variable rule, improve the handling of AssignmentValue, and properly account for semicolons within strings. I hope this helps!
Following #28.
E.g.: