[antlr-interest] Adding a Space Leads to Mismatch

Jim Idle jimi at temporal-wave.com
Thu Feb 9 11:30:28 PST 2012


Don't use 'strings' in your parser, create real tokens and list the
keywords and punctuation in the lexer before the generic rule. Also, it
does not look like you need the spaces, so try skipping them:

LPAREN: '(' ;
...
KEYWORD: 'keyword';
....
ALPHANUMERICSPACE: 'A'..'Z'+ ... etc

WS: (' '|'\t')+ { skip(); } ;  // Then remove WS refs in your parser


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Quintin Beukes
> Sent: Thursday, February 09, 2012 11:20 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Adding a Space Leads to Mismatch
>
> I debugged the Lexer, and it seems that it's predictions for the next
> token always seems to match against ALPHANUMERICSPACE.
>
> How can I resolve such a prediction error? Even if just pointing me to
> the wiki.
>
> thanks,
> Quintin Beukes
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list