[antlr-interest] howto ignore unknown tokenstreams/recordsets

Ric Klaren ric.klaren at gmail.com
Mon Jan 17 06:59:25 PST 2005

On Mon, 17 Jan 2005 13:32:58 +0100 (MET), Oliver Kowalke
<oliver.kowalke at gmx.de> wrote:
> I'm writing a parser which parses a dokument (datasets separated by
> semicolon).
> How can I ignore unknown datasets (in my example recordsets X and Y)?

It depends a bit on what defines an unknown recordset. If you know
those start with X and Y then you can just skip them in the lexer like
whitespace. Or you can use tokenstream filtering between lexer and
parser. Although you should take care that there's no (or very
controlled) feedback from parser to lexer (when using tokenstream
filtering). Another approach might be to make some custom error
handlers in your parser that skip the unrecognized bits, that might
interfere with normal error handling though.



More information about the antlr-interest mailing list