[antlr-interest] parsing same file more than once

Mach Ray mach_ray at yahoo.com
Thu Mar 23 07:44:19 PST 2006

Dear all,

I want to parse the same file multiple times,
depending on the number of input arguments. The input
file name is an extern variable defined in the
grammar. Here is a segment of the main function. 

// ...
if (frules.substr(frules.find('.')) == ".rules"){

ifstream infile (frules.c_str(), ios::in);
if( !infile.is_open() ){
   cerr << "Error in opening the conversion rules
file"      << endl;
   return 1;
for( int i = 2; i < argc; i++ ){
   xml_file = argv[i]; // a global variable

   XML2OWLLexer lexer(std::cin);
   XML2OWLParser parser(lexer);
   LexerSharedInputState lex_state =  
   lex_state->initialize(infile, frules.c_str());
// ...

The first execution of the for loop is witout any
error. During the second execution, the parse throws
the following error
cont.rules:1:1: unexpected end of file


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the antlr-interest mailing list