[antlr-interest] Parsing this ambiguous grammar

Gokulakannan Somasundaram gokul007 at gmail.com
Fri Jan 27 12:21:29 PST 2012


>
>
> No matter what the parser "asks" of the lexer, the lexer will simply return
> the longest match. And in case of a tie, it returns the match (token) that
> is defined first. So in your case, "A", "B" and "C" (regardless of case)
> will always be tokenized as an ID (assuming ID is defined before PITCH as
> you posted in your example). I wouldn't call it ambiguous.
>
>
> I think this is slightly different in ANTLR grammars with a fixed look
ahead. Wherein it will try to resolve ambiguities till the look ahead and
picks up the first match, if they still remain ambiguos.


More information about the antlr-interest mailing list