[antlr-interest] Reusing Lexer/Parser instances
defordusa
defordusa at yahoo.com
Fri Jul 11 08:04:47 PDT 2003
My application needs to perform MANY small translations (on the order
of millions). In order to improve performance I would like to be able
to reuse instance of the lexer and parser.
I originally posted a question about using the PipedWriter and
PipedReader classes found in Java 1.3 and above, as I figured this
way I could write something in the PipedWriter, call the appropriate
parser rule and get the results. However, I have been unable to get
this to work as I appear to need to somehow get the lexer to stop
trying to read on the PipedReader and thus the lexer blocks on a read.
I have been able to reuse the lexer and parser instances calling
setInputState and setTokenBuffer on the lexer and parser
respectively. However, I still have the overhead of millions of
instances being created, dramatically reducing performance.
Is there a better way of doing this?
Here is a snippet of my code:
...
...
...
while( in.ready() )
{
lexer.setInputState(new LexerSharedInputState(new StringReader
(in.readLine())));
parser.setTokenBuffer( new TokenBuffer(lexer) );
parser.startRule();
}
...
...
...
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list