antlr - ANTLR4 - Mutually left-recursive grammar -


i getting error: the following sets of rules mutually left-recursive [symbolexpression]. in grammar, symbolexpression directly left-recursive shouldn't antlr4 handling this?

here relevant parts of parser:

operation:         operator '(' (operation | values | value | symbolexpression) ')'                       #operatorexpression      | bracketedsymbolexpression                                                              #bracketedoperatorexpression      ;  symbolexpression:      (operation | values | value | symbolexpression) symbol (operation | values | value | symbolexpression);  bracketedsymbolexpression:      '(' (operation | values | value | symbolexpression) symbol (operation | values | value | symbolexpression) ')';  list: '[' (operation | value) (',' (operation | value))* ']';  values: (operation | value) (',' (operation | value))+;  value:      number    | identifier    | list    | object; 

the elements 'symbolexpression' , 'operation' in rule 'symbolexpression' interdependently left recursive.

without knowing language specification, impossible whether language irrecoverably ambiguous.

nonetheless, 1 avenue try refactor grammar move repeated clauses,

( operation | value ) 

and

(operation | values | value | symbolexpression) 

to own rules goal of unifying 'operation' , 'symbolexpression' (and perhaps 'bracketedsymbolexpression') rules single rule -- rule @ self left-recursive. like

a : value   | lparen a* rparen   | lbrack a* lbrack   | symbol   | ( comma )+   ; 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -