[antlr-interest] parsing same file more than once
Andy Tripp
antlr at jazillian.com
Thu Mar 23 11:39:47 PST 2006
I'm not sure if this is the cause or not, but when I reuse my parser,
I call reset() as you do, but also set traceDepth to 0.
Andy
Mach Ray wrote:
>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 =
>lexer.getInputState();
> lex_state->initialize(infile, frules.c_str());
>
> parser.getInputState()->reset();
> parser.setFilename(frules);
>
> parser.file();
>// ...
>
>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
>
>Thanks
>Mach
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam? Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
>
>
More information about the antlr-interest
mailing list