[antlr-interest] ANother mismatched token 0!=0

G R relationalalgebra at gmail.com
Sun Mar 16 08:12:58 PDT 2008


Thanks Gavin.
I have rearange my rules for my literals, but i still got some errors with
my NEWLINE token.
You answer my question before i could write it down :)
Thanks again.

:beer:



2008/3/16, Gavin Lambert <antlr at mirality.co.nz>:
>
> At 02:53 15/03/2008, G R wrote:
> >IDMEFPATH
> >     :    LETTER (LETTER | SCORIES);
> >VALUE
> >     :    (SCORIES | DIGITS | LETTER)+;
> >DIGITS
> >     :    DIGIT+;
> >
> >TAG
> >     :    '@_' LITERAL;
> >LITERAL
> >     :    LETTER (LETTER | '-' | '_')*;
> >
> >fragment SCORIES
> >     :    '-' | '_' | ':' | '.' | '?' | '!' | '|' | '@' | '#' |
> > '$' | '^' | '~' | '(' | ')' | '[' | ']' | '\\' | '/' | '*';
> >fragment LETTER
> >     :    ('a'..'z' | 'A'..'Z');
> >fragment DIGIT
> >     :    '0'..'9';
> >
> >NEWLINE
> >     :    '\r'? '\n';
> >WS
> >     : (' '|'\t'|'\n'|'\r')+ {skip();};
>
>
> These rules are going to give you a lot of problems, since you
> have a lot of overlaps in the public rules.
>
> Remember that lexing is done first and context-free; all public
> rules are viable output tokens.  Given the excerpt above, "423"
> will *always* be a VALUE and not a DIGITS, since they're of
> equivalent length and the VALUE rule is listed first.  By
> contrast, sometimes you won't get NEWLINE tokens emitted since
> they may be swallowed up within a WS token.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080316/3168887f/attachment.html 


More information about the antlr-interest mailing list