[antlr-interest] MismatchedTokenException and how to find errors in ANTLRWorks
Jim Idle
jimi at temporal-wave.com
Tue Feb 12 11:50:10 PST 2008
> -----Original Message-----
> From: Matt Benson [mailto:gudnabrsam at yahoo.com]
> Sent: Tuesday, February 12, 2008 11:40 AM
> To: Jim Idle; antlr-interest at antlr.org
> Subject: Re: [antlr-interest] MismatchedTokenException and how to find
> errors in ANTLRWorks
>
>
> --- Jim Idle <jimi at temporal-wave.com> wrote:
>
> > I strongly believe that using literal strings in the
> > grammar is fraught
> > with difficulties for the beginner and advise
> > against it.
>
> [SNIP]
>
> But... the examples say it's okay! ;)
>
> Seriously, Jim: what's the likelihood of your (or
> anyone's) being able to sum up the reason for this
> fairly succinctly? What is the #1 gotcha about using
> literals vs. tokens that ANTLR3 beginners overlook?
Just scan through the last six months posts and find that an awful lot
of people just assume that when you write:
'xxx'
that the rule goes off and looks in the character stream right at that
moment in time for 'x' 'x' 'x' and then they have no idea why their
literals conflict with other lexer rules and xxx does not return an ID
later on.
Hence, the best thing is not to use this until you understand how it is
all goes together. To be honest, even then I am not sure that I see the
advantage myself.
Jim
More information about the antlr-interest
mailing list