[antlr-interest] Ambiguity error in lexer generation

Alex Kinneer kinneera at hotmail.com
Thu Sep 20 09:34:01 PDT 2007


I will post the grammar in response to the next message on the thread, so you will see there is definitely no left recursion (there isn't any recursion at all, actually).
 
The single quotes are just misleading antlr output -- none of the rules have anything to do with single quotes (well, technically the UNQUOTED_STRING rule will accept them, but it's definitely unambiguous there).  There are a set of implicit literal tokens (defined in the grammar rules), so it is just warning that the first character of some (all) of those tokens/keywords can also be matched by the JAVA_ID rule (and the UNQUOTED_STRING rule if the predicate is satisfied).  For some reason, it feels the need to put the character in single quotes, probably because there's no symbolic name for the token in the grammar.> (Yes, I know that this isn't answering your original > question. But I think these are worth looking into as well.)
No problem.
 
 



> Date: Thu, 20 Sep 2007 16:03:12 +1200> To: kinneera at hotmail.com; antlr-interest at antlr.org> From: antlr at mirality.co.nz> Subject: Re: [antlr-interest] Ambiguity error in lexer generation> > 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.)> 
_________________________________________________________________
Kick back and relax with hot games and cool activities at the Messenger Café.
http://www.cafemessenger.com?ocid=TXT_TAGLM_SeptWLtagline
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070920/15e6603e/attachment.html 


More information about the antlr-interest mailing list