[antlr-interest] Performance of ANTLR-generated lexer/parsers

Ric Klaren ric.klaren at gmail.com
Sun Aug 27 04:47:36 PDT 2006


Charles Felstead wrote:
> Now what really surprised us is the speed of the parsers. We were expecting
> the ANTLR-generated parser to be much faster than the Xerces-based parser.
> After all, the ANTLR parser is specific to that one type of file I'm
> parsing
> whereas the Xerces is generic. Turns out the Xerces parser, is about 15-25%
> faster than the ANTLR one??!
> 
> So, my question is, can I flip some switches or configure the
> ANTLR-generated parser to improve the performance??

As Loring suggested using a flex lexer will probably get you a good
improvement. Another thing is to look critically at your grammar.
Depending on how you solve things in antlr things will be slow.

The most important rule of thumb is to shun syntactic predicates like
the plague (the construct with the '=>'). If you have one of these in
the lexer in the wrong spot then you can forget about any performance.

Cheers,

Ric

PS the antlr v3 C++ codegen is progressing but not ready yet. Hope to
get a lexing/parsing version out in the coming few weeks.



More information about the antlr-interest mailing list