I know it must be simple but I have not yet figured it out (or it is getting late at night...).
Once a parse exception has occuredt, which is caught by the 'onParseError' method, how to advance to the next line to enable recovery? I am feeding individual lines from the wrap() method to keep track of which line(s) have problems.
Tried to 'switchToStream' but the parser still has tokens in its queue. Can't keep on 'consume'ing as there may be invalid tokens after the one that cause the exception.
Somehow I feel that a token queue somewhere needs to be flushed - can't find it - help....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can re-write the grammar rule where you want to do the error-recovery (e.g. the rule that parses one line of input, if you have such a thing) along the lines of:
(void) parseLineWithRecovery ()
{
( oneLine() <end_of_line> )
catch (ParseException &ex) { // you get here if the
//oneLine rule went wrong
// so, consume tokens up to and eol
while (scanner.la()->id != MyScanner::end_of_line)
scanner.consume();
// call consume again to skip the eol itself
scanner.consume()
}
}
The MyScanner::end_of_line constant decl is generated by cppcc (i assumed the scanner is called MyScanner and the eol token is called end_of_line)
Basically, you can add a catch clause after any expansion if you want to recover when that expansion failed.
Hope that helps,
alec.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
internal compiler error.. don't know whether to laugh or be sad.... Can you send me the full error log ? Probably this one is related to some earlier errors.
There are some already-built win bins, if you don't feel like bothering with the compilation stuff you can try those.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Quite impressed with you CppCC!
I know it must be simple but I have not yet figured it out (or it is getting late at night...).
Once a parse exception has occuredt, which is caught by the 'onParseError' method, how to advance to the next line to enable recovery? I am feeding individual lines from the wrap() method to keep track of which line(s) have problems.
Tried to 'switchToStream' but the parser still has tokens in its queue. Can't keep on 'consume'ing as there may be invalid tokens after the one that cause the exception.
Somehow I feel that a token queue somewhere needs to be flushed - can't find it - help....
You can re-write the grammar rule where you want to do the error-recovery (e.g. the rule that parses one line of input, if you have such a thing) along the lines of:
(void) parseLineWithRecovery ()
{
( oneLine() <end_of_line> )
catch (ParseException &ex) { // you get here if the
//oneLine rule went wrong
// so, consume tokens up to and eol
while (scanner.la()->id != MyScanner::end_of_line)
scanner.consume();
// call consume again to skip the eol itself
scanner.consume()
}
}
The MyScanner::end_of_line constant decl is generated by cppcc (i assumed the scanner is called MyScanner and the eol token is called end_of_line)
Basically, you can add a catch clause after any expansion if you want to recover when that expansion failed.
Hope that helps,
alec.
Thanks - that did it.
Now on to memory leaks. Tried to compile CppCC with Microsoft VisualC++ (version 7), among many errors I got an "Internal Compiler Error".
Downloaded MinGW to give it a try ... as soon as I figure out how to set up the configuration files and get a proper compile going...
Cheers!
Dan
internal compiler error.. don't know whether to laugh or be sad.... Can you send me the full error log ? Probably this one is related to some earlier errors.
There are some already-built win bins, if you don't feel like bothering with the compilation stuff you can try those.
Yes the prebuilts work well here