Exercise 27:

Conflict resolution: left recursion
We have the following grammar for a simple language of expressions:
  expr: term (('+'^|'-'^) term)*;
  term: atom (('*'^|'/'^) atom)*;
  atom: '*'^ atom | atom '['^ expr ']'! | IDENT;
  IDENT: ('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
However, we have detected that it has left recursion. Consequently, a parser generated from this grammar could hang by entering infinite recursion. Change the grammar to fix this problem, without modifying the language or AST construction.
Authors: Nil Mamano / Documentation:
To be able to submit you need to either log in, register, or become a guest.