[antlr-interest] How to reuse lexer object and parser object

Ronghui Yu stoneyrh at gmail.com
Wed Oct 8 23:59:19 PDT 2008


Hi, Jim,

Sorry to bother you again.
As I mentioned before, I use the same lexer and parser object for parsing
different SQL statements.
When using ANTLR3.0.1, everything works fine, but when upgrade to ANTLR3.1,
I found that it is necessary to save the
ctx->pParser->rec->state->tokenNames before calling setTokenStream, and
restore it to the previous value after.

But we found that it is not enough yet. Sometimes, it needs to set
ctx->pParser->rec->state->tokFactory to NULL, otherwise, it will result in
crash. What I do now is closing the tokFactory and setting it to NULL.

The problem is, I am not sure if there are other fields I need to reset, or
what values I should set them to.
Could you give me some advices?
Or if possible, you may provide an API for doing this job.

Thanks a lot.


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


More information about the antlr-interest mailing list