[antlr-interest] Incremental Parsing?

Benji Smith benji at benjismith.net
Mon Jul 16 17:51:26 PDT 2007


Is it possible (and straightforward) to implement an incremental
parser with antlr?

The reason I ask is that I recently wrote a JavaCC parser for CSV
files (which correctly handles quoted fields, quote escaping, and
fields containing newline characters (a huge pain in the ass if you're
trying to parse CSV without writing a grammar)).

The JavaCC parser works well, except that I can't parse the file
record-by-record. I have to parse the entire file, returning a
collection of Record objects at the end.

With small files, that's fine. But I sometimes need to parse CSV files
with millions of records, and it'd be very nice to simply pull the
next record (as long as it complies with the grammar), much like you'd
pull the next token from a TokenStream.

Any tips on performing incremental parsing with antlr?

Thanks!

--benji smith


More information about the antlr-interest mailing list