[antlr-interest] Simple problem with tokens string
Mark Wright
markwright at internode.on.net
Wed Jul 30 03:07:23 PDT 2008
Hi,
Please see the section "Keywords as Variables" on p. 287 of the ANTLR
book.
Regards, Mark
On Wed, 30 Jul 2008 11:33:27 +0200
edA-qa mort-ora-y <e.mortoray at ecircle.com> wrote:
> I'd like to do something like below in a grammar (to handle keywords
> and identifiers), but it just doesn't work as expected.
>
> grammar Test;
>
> sample
> : 'sample' VALUE;
>
> VALUE
> : ('a'..'z')+;
>
> This works, so long as the input is not of this form:
> sample sample
> In which case I get a MismatchedTokenException.
>
> Why is it that as soon as I use a fixed string in a token it can no
> longer be identified as a different token? And how do I do it
> correctly?
>
> (Using ANTLRWorks 1.1.7)
>
--
More information about the antlr-interest
mailing list