Reputation: 91
I'm trying to parse a language. The follow ANTLR4 parser rules are directly copied from the language specification :
physical_value
: raw_value DIV factor MUL factor PLUS offset
;
raw_value
: (physical_value MINUS offset) DIV factor
;
but antlr reports an error:The following sets of rules are mutually left-recursive I don't know how to modify the grammar, Hope someone can help me. Thanks.
Upvotes: 0
Views: 360
Reputation: 99859
You cannot eliminate the left recursion from the rules you posted, because the only string it matches is an infinite sequence.
physical_value
always starts with a raw_value
raw_value
always starts with a physical_value
...and repeat
Upvotes: 1