[antlr-interest] Ambiguity error in lexer generation

Gavin Lambert antlr at mirality.co.nz
Wed Sep 19 21:03:12 PDT 2007


At 03:57 20/09/2007, Alex Kinneer wrote:
 >warning(205): TestLang.g:1:8: ANTLR could not analyze this 
decision
 >in rule Tokens; often this is because of recursive rule 
references
 >visible from the left edge of alternatives. ANTLR will 
re-analyze
 >the decision with a fixed lookahead of k=1. Consider using 
"options
 >{k=1;}" for that decision and possibly adding a syntactic
 >predicate.

Are you sure you don't have any left-recursion in the grammar?

 >warning(209): TestLang.g:20:1: Multiple token rules can match 
input
 >such as "'v'": T22, T24, T25, UNQUOTED_STRING, JAVA_ID
 >As a result, tokens(s) JAVA_ID,UNQUOTED_STRING,T24,T25 were
 >disabled for that input
 >warning(209): TestLang.g:13:1: Multiple token rules can match 
input
 >such as "'g'": T16, T18, UNQUOTED_STRING, JAVA_ID
 >...

Maybe this is just inconsistent naming, but why would 
UNQUOTED_STRING or JAVA_ID be a candidate match for something in 
single quotes?  Something seems wrong here.

(Yes, I know that this isn't answering your original 
question.  But I think these are worth looking into as well.)



More information about the antlr-interest mailing list