[antlr-interest] Lexer: Default token?

Eric Holmberg eric at omnicurious.com
Sat Jul 22 12:53:23 PDT 2006


I have a case where depending upon the context of the parse, I want to
either parse all tokens or ignore then, but still save them to the AST
(hidden tokens are fine).  The problem is that there aren't any rules for
the characters defined in the lexer, so the lexer throws a parse exception.

Is there a way, in the lexer, to specify a default token type such that if a
character/character-sequence doesn't match any of the token rules, then it
gets packaged up in this default token type?

I can always do this by hand, but it's tedious and gets tricky for rules
that match comments, etc.

-Eric



More information about the antlr-interest mailing list