[antlr-interest] MismatchedTokenException and how to find errors in ANTLRWorks

Guntis Ozols guntiso at latnet.lv
Thu Feb 14 02:06:11 PST 2008


> I've learned that "the customer is always right" is good policy on bug
> reports--not that he is right about the specifics, but that he is usually
> right that "there is a problem".

Wise

> As Guntis points out, in this case it is not the literals that are
> the problem but the confusion arising from combined grammars which
> hide the lexer.

I like antlr because of combined grammars, I think it is the right direction.

And I think that the root of the problem in this case
is antlrs broken lexer (please, forgive me again)

> > > There isn't anything wrong with the tool, it is doing what you tell it
> > > to do. The token isnt anonymous, it is called T66 or whatever,

I guess I should be thankful it is not called AK-47.
Is java.util.AbstractMap$2$1.class anonymous?

> > runtime doesn't know that you created it by specifying it in the parser.
> > So, I don't see why "anonymous token" would help you at all.

It would help me at design time to see I have a potential problem.
Not me, actually, I've already learned my lesson. It could help
others and could save many man-hours by clearly showing what is
going on.

> > Criticism of the tool should be postponed until you
> > truly understand what the tool is doing

By that time, I'll be a pro at avoiding traps and obstacles to the
point I will not notice them, so it will be too late to report anything.

BTW I think I understand what the tool is doing in this particular
case and I was not asking for help, was I? Adding
System.err.println("Anonymous token in parser rule: " + lit);
to AssignTokenTypesWalker.assignStringTypes(Grammar) works well for me.

Guntis



More information about the antlr-interest mailing list