[antlr-interest] non-LL(*) error in list rule

Chris Rebert cvrebert at gmail.com
Tue Jul 1 18:26:30 PDT 2008


I have a grammar and am getting an error about the rule 'exprlist'
being non-LL(*), even after turning on backtracking as suggested by
the error:


exprlist options {backtrack=true;}: es+=expr? (',' es+=expr)*  -> es;
list: '['! exprlist ']'!;


And suffice it to say that the rule for 'expr' includes some rules
like 'list' as alternatives.
ANTLRWorks' diagram shows red lines indicating (I think) that ANTLR
can't see whether to try and match the first expr or skip past it, but
I don't see how to refactor exprlist to avoid this. I understand
exprlist could recursively call itself through 'expr', but shouldn't
backtracking take care of this?

How do I go about fixing this grammar?

Thanks,
Chris Rebert


More information about the antlr-interest mailing list