Closed lalshikh closed 1 year ago
It looks to me like the error isn't because of parenthesis, but because of a collision between SIGNED_INT and the subtraction operator ("-").
Anyway, there are other issues with your grammar too. I suggest that you use the calc example as the initial grammar, and try to build on it. Or at least learn the example and understand the pattern behind it. (left recursion, etc.)
I rewrote my grammar following the example and it works great. Thank you!
I'm writing a parser that needs to recognise additions with parentheses and constant functions.
Here is my grammar :
And my code that performes the parsing :
With this input string :
I get the following tree (which is what I expect) :
But if I insert parentheses and use, for instance the following input string,
I get the following error message :
I gess the parser expects a constant function as soon as it gets to the left parenthesis but I have no clue where is the ambiguity in my grammar.
I have to keep the argument rule as the parser will later need to recognise non constant functions.
How can I make the parser recognise properly when the parentheses are in a complex addition or in a constant function ?