[antlr-interest] Please HELP!!!

Ric Klaren klaren at cs.utwente.nl
Thu Feb 6 08:32:11 PST 2003


On Thu, Feb 06, 2003 at 02:17:17AM -0000, rmsanjivp <rmsanjivp at yahoo.com> wrote:
> MyLexer lexer(some istream object);
> then there is no way for me to specify the lexer to read from
> different input stream.
> Is there a way to change the input to lexer while I am parsing? Like
> telling lexer to read from one file initially and then from another
> file without re-instantiating the lexer?

a) check the includeFile example (if you want include file like behaviour)
b) check LexerSharedInputState.hpp (if you just want to reinitialize after
   a parse run) something like this:

   ifstream file;


   antlr::LexerSharedInputState lex_input = lexer->getInputState();
   lex_input->initialize(file, filename);

   // and reset parser (antlr) internal state

   // start parsing at the 'start' rule

   setFilename's are necessary to get correct errormessages. The
   inputstates need resets to prevent 'funny' things.


    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
     "Evil will always triumph, because Good is dumb." ---  Spaceballs


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list