[antlr-interest] error(208)

Ranco Marcus ranco.marcus at epirion.nl
Tue Jun 7 02:17:31 PDT 2011


Yes, it takes quite a bit of practise, but you will find a great help in Terence Parr's books.

See the links below.

http://pragprog.com/titles/tpantlr/the-definitive-antlr-reference 

http://pragprog.com/titles/tpdsl/language-implementation-patterns 

Best regards, Ranco

________________________________________
From: antlr-interest-bounces at antlr.org [antlr-interest-bounces at antlr.org] on behalf of P.N. [peter.nabbefeld at gmx.de]
Sent: Tuesday, June 07, 2011 11:07 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] error(208)

Thank You, works great now!
I'm not used to writing parsers and/or lexers, so I'm still confusing
about it.

Kind regards
Peter


Ranco Marcus schrieb:
> Hello Peter,
>
> You should probably change the name of rule PV to lowercase pv, because it is a parser rule and not a lexer rule.
>
> Best regards,
>
> Ranco
>
> ________________________________________
> From: antlr-interest-bounces at antlr.org [antlr-interest-bounces at antlr.org] on behalf of P.N. [peter.nabbefeld-Mmb7MZpHnFY at public.gmane.org]
> Sent: Tuesday, June 07, 2011 10:32 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] error(208)
>
> Hello!
>
> Using the following rules for grammar (ESC_SEQ defined as fragment):
>
> root    :        object;
> object  :       '{' props '}';
> props   :       prop (',' prop)*;
> prop    :       ID ('=' PV | '+' | '-');
> PV      :       STRING | object | INT;
> ID      :       ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
> INT     :       '0' | ('1'..'9') ('0'..'9')*;
> WS      :       (' '|'\t'|'\r'|'\n') {$channel=HIDDEN;};
> STRING  :       '"' (ESC_SEQ | ~('\\'|'"'))* '"';
>
> When I try to generate the Java code, the following error message is shown:
> "error(208):  The following token definitions can never be matched
> because prior tokens match the same input: INT,STRING"
>
> Why do I get this message, as every lexical rule has its own starting
> character?
>
> Kind regards
>
> Peter
>
>
> 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
>



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