I have the following in a JavaCC file:
void condition() : {}
{
expression() comp_op() expression()
| condition() (<AND> | <OR>) condition()
}
where <AND>
is "&&" and <OR>
is "||". This is causing problems due to the fact that it is direct left-recursion. How can I fix this?
A condition is essentially 1 or more of expression comp_op expression
separated by an AND
or an OR
. You could do the following
condition --> simpleCondition ( (<AND> | <OR>) simpleCondition )*
simpleCondition --> expression comp_op expression