[antlr-interest] MismatchedTokenException and how to find errors in ANTLRWorks
Matt Benson
gudnabrsam at yahoo.com
Tue Feb 12 12:03:47 PST 2008
--- Gavin Lambert <antlr at mirality.co.nz> wrote:
> At 08:39 13/02/2008, Matt Benson wrote:
> >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?
>
> I gave my answer to that question yesterday (though
> more
> briefly). As I see it, there are two big drawbacks
> to using
> literal strings in the parser:
>
> 1. The generated code becomes filled with references
> to "T32" and
> "T63" etc rather than anything meaningful, making it
> harder to
> understand. (And also complicating things if you
> want to generate
> an AST later on.)
>
> 2. It's too easy to forget that each quoted string
> produces a
> lexer rule (which may conflict with other rules),
> making it harder
> to find the source of ambiguity problems. In
> addition, "'x' 'y'"
> is not the same as "'xy'" in the parser, though it
> is in the
> lexer; this can cause confusion.
>
>
Thanks, Gavin. Now flip the coin: what, if anything,
is _good_ about literals in the parser outside of a
rapid prototyping context?
-Matt
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the antlr-interest
mailing list