[antlr-interest] Could the parser and lexer be reused?
chainone at gmail.com
Sun Jan 4 19:57:41 PST 2009
There are many pieces of inputs , all of which should be parsed by one
parser.Such as :
However, this kind of inputs doesn't come all in one time. They arrive at
different time. Once one input arrives, it needs to be parsed immediately.
So the next piece of pseudo code shows how it is processed by my way:
void ParseOneInput(const char* data)
lex = StepDataEntryLexerNew(m_input);
tokens = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT,
parser = DataEntryParserNew (tokens);
Once one input arrives, Function ParseOneInput is called.
It works fine.
The question is , could the parser and lexer in ParseOneInput be reused?
If they could be reused, then it is unnecessary to create/destroy a lexer
and a parser every time an input arrives. If not, I believe it
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest