[antlr-interest] Resetting the the input stream in a C++ lexer?

McCall, Kurt Kurt.E.McCall at nasa.gov
Mon Apr 11 10:01:36 PDT 2005


This should be a simple question for someone out there.   I need to call my
C++ parser repeatedly, each time on a different character string.   Trouble
is, I don't know how to reset the lexer to point to each new string.  Here
is what I've tried:

char *text1 = "This is the first expression";
char *text2 = "This is the second expression";

istringstream *inlex = new istringstream(text1);
ExprLexer *lexer = new ExprLexer(*inlex);
ExprParser *parser = new ExprParser(*lexer);

// parse the first expression
parser->start_rule();

// reset the istringstream object and parse the second expression
inlex->str(text2);
parser->start_rule();


It keeps parsing the first string over and over.  What am I missing?

Thanks for any help,
Kurt

-------------------------------------
Kurt McCall
Modeling and Simulation Branch / EV43
NASA MSFC
(256) 961-4501




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050411/9d0417bb/attachment.html


More information about the antlr-interest mailing list