[antlr-interest] False error 208?

Jim Idle jimi at temporal-wave.com
Mon Oct 24 08:26:21 PDT 2011


Oh – I did not see it was a lexer error.



Reorder the rules:

IF     :    'if';

ID     :    ('A'..'Z'|'a'..'z')+;

RAW    :    ({rawAhead()}?=> . )+;



However IF and ID will always be produced like this. If they should not be,
then you want:





IF     :    {!rawAhead()}?=>'if';

ID     :    {!rawAhead()}?=> ('A'..'Z'|'a'..'z')+;

RAW    :   .+;



Jim



*From:* Bart Kiers [mailto:bkiers at gmail.com]
*Sent:* Monday, October 24, 2011 8:20 AM
*To:* Jim Idle
*Cc:* antlr-interest at antlr.org
*Subject:* Re: [antlr-interest] False error 208?



Hi Jim,



No, that doesn't make a difference: the error (IF can never be matched)
still remains.

Not that _I_ know what is going wrong though...



Regards,



Bart.



On Mon, Oct 24, 2011 at 5:09 PM, Jim Idle <jimi at temporal-wave.com> wrote:

parse    :    IF* EOF;


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Bood Qian
> Sent: Monday, October 24, 2011 1:29 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] False error 208?

>
> I don't understand why the following grammar leads to error 208
> complaining IF will be never matched
>
> ANTLRWorks 1.4.3
> ANTLT 3.4
> =====================
> grammar test;
>
> @lexer::members {
>   private boolean rawAhead() {
>   }
> }
>
> parse    :    IF*;
>
> RAW    :    ({rawAhead()}?=> . )+;
> IF      :    'if';
> ID    :    ('A'..'Z'|'a'..'z')+;
> ======================
>
> Either remove RAW rule or ID rule solves the error...
> >From my point of view, IF has the possibility to be matched.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address

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