I have the below grammar... JavaCC complains about left-recursion in
all the productions of Expression except Expression_Finish(). I've
read all the previous posts on left-recursion in this group and in my
Compilers textbook to no avail... would appreciate any suggestions on
what I could do, for at least one of the possible productions.
void Expression():
{ Token t; }
{
Expression() ( AND() | LESS_THAN() | PLUS() | MINUS() | MULTIPLY() )
Expression()
| Expression() LEFT_BRACE() Expression() RIGHT_BRACE()
| Expression() DOT() LENGTH()
| Expression() DOT() Identifier() LEFT_PAREN() ( Expression()
( COMMA() Expression() )* )? RIGHT_PAREN()
| Expression_Finish()
}
void Expression_Finish():
{}
{
<INTEGER_LITERAL>
| TRUE()
| FALSE()
| Identifier()
| THIS()
| NEW() INTEGER() LEFT_BRACE() Expression() RIGHT_BRACE()
{System.out.println("My expression: new int(expression())"); }
| NEW() Identifier() LEFT_PAREN() RIGHT_PAREN()
{System.out.println("My expression: new ID ()"); }
| EXCLAMATION() Expression()
| LEFT_PAREN() Expression() RIGHT_PAREN()
}