1

i have the following antlr4 grammar and i get mutually left-recursive error , how can i fix it ?

expr : expr_prefix term ;
expr_prefix : expr_prefix term addop
            | () ;
term : factor_prefix factor;
factor_prefix : factor_prefix factor mulop
              | () ;
factor : primary 
       | call_expr ;
primary : ( expr ) 
        | id
        | INTLITERAL
        | FLOATLITERAL ;
  • What is the actual error message? What parts are mutually left recursive? – ramana_k Nov 13 '15 at 16:17
  • this is exactly what i get : error <119> the following sets of rules are mutually left - recursive [ expr , primary , expr_prefix , term , factor_prefix , factor ] – farah madhoun Nov 13 '15 at 16:26
  • They are multiple ways this can be fixed. I would start with `factor_prefix : factor_prefix` or `expr_prefix : expr_prefix `. It would help if you could update the question with examples of sentences this grammar has to accept and the ones it should reject – ramana_k Nov 13 '15 at 17:48

0 Answers0