[antlr-interest] Performance question.

Ric Klaren ric.klaren at gmail.com
Thu Feb 15 00:43:05 PST 2007


Hi,

On 2/15/07, Alex Shneyderman <a.shneyderman at gmail.com> wrote:
> try {
>   Java15Lexer lexer = new Java15Lexer(new FileInputStream(file));
>   Java15Parser parser = new Java15Parser(lexer);
>   parser.compilationUnit();
> } catch (Throwable t) {
>   System.out.println ("Can't parse: " + file.getAbsolutePath() + "; "
> + t.getMessage());
> }

Don't destroy the parser and lexer between runs but reinitialize them
for the new input with help of InputBuffers. I'm don't know what the
java invocations are for this of the top of my head. But there should
be some reset methods on the inputbuffer used for the lexer and you
might have to add some reset or reinitialize methods to your lexer and
parser depending on what amount state you keep.

Cheers,

Ric


More information about the antlr-interest mailing list