Yacc lex uqestion
-
I apologize for the inconvenience this not a Qt question. I am using a library in my Qt application which is built and generated by lex and yacc compiler. When I am calling first time the function it's working fine, a good file. Next time running a bad file from within the same application for which it throws an error, from within the same application, now if I call next time for the good file also it throws the error. The problem is the error. If an error occurs then next time onwards it throws error for even for a good file. How can I clear the error stream so that it runs good for the good file. Any help is highly appreciated. Thanks Sujan
[code]
bool upgrade_model(char *model, string &newModel); //this function is exposed by the static library.
[/code][code]
string newmodel;
bool upgraded = upgrade_model("/home/red/good.model",&newmodel); // it runs fine
upgraded = upgrade_model("/home/red/bad.model",&newmodel); //it throws error
upgraded = upgrade_model("/home/red/good.model",&newmodel); //it throws error
[/code]How can I clear the error stream in the begining when a call is made to the function upgrade_model()
-
Hi :)
It seems that the problem is not with Yacc and Lex.
Usually, when I get this situation I reboot the computer to fix the problem ! -
You need to address the incorrect maintenance of state between runs with the author of the library.
-
Chris please suggest me something. author is inaccessible. I am calling YY_FLUSH_BUFFER; in the lex file. What else need to be done to clear the state. How can I make the state to come back to original state. Please help.
-
Since you seem to have direct access to the parser/lexer you should also consider the options discussed here, http://www.gnu.org/software/bison/manual/html_node/How-Can-I-Reset-the-Parser.html, which id GNU Bison specific but might give you a clue if you are using a different parser/lexer. The link to flex "Start Conditions" on that page should be: http://flex.sourceforge.net/manual/Start-Conditions.html#Start-Conditions
If the intermediate library is broken and the source/author is unavailable then you really have no choice but to replace the library.