[antlr-interest] Is there a safe and easy way to reuse LEXER and PARSER objects on C target?

Ronghui Yu stoneyrh at gmail.com
Thu Dec 10 08:20:52 PST 2009


Hi, All,

On my project, I have a parser for parsing different statements again and
again. In order to save a little time on initialization, I would like to
reuse the LEXER and PARSER objects created the first time, something like
this:

if (bInitialized)
{
    reinitialize();
}
else
{
   initialize();
   bInitialized = true;
}

The problem now is how to write reinitialize() safely. I have no idea on
which fields of LEXER or PARSER objects must be reset to which status. Then
my current code works most of the time, but it encounters NULL pointer
occasionally(I am sure the grammar file is good because if I don't reuse the
LEXER and PARSER objects, everything goes fine).

Anybody could give me some ideas?

Thanks in advance.

-- 
===========================
Regards
Ronghui Yu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091211/8d89f0c4/attachment.html 


More information about the antlr-interest mailing list