I have the following grammar to parse a nested list using Antlr3
parse:
list
;
list:
LBRACK list_element* RBRACK
;
list_element:
tree_ | list
;
tree_:
node | ATOM
;
node:
LBRACK tree_ SEPARATOR tree_ RBRACK
;
ATOM: 'nil';
LBRACK: '(';
RBRACK: ')';
SEPARATOR: '.';
WS : (' ' | '\f' | '\r' | '\n' | '\t')+{$channel = HIDDEN;};
I can't find out what is causing, or how to remove the error:
'/ListParseTest/src/ListParse.g:17:13: [fatal] rule list_element has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option. |---> list_element: '
I recognize it has something to do with the recursive relationships between list
, list_element
and tree_
, but I am not able to solve the problem.
Can anybody help?