By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,718 Members | 1,171 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,718 IT Pros & Developers. It's quick & easy.

Clearing parser state of a bison generated parser

P: 2
Iam using c lexer that is flex generated and a c++ parser that is bison generated. i have modified the parser to acccept only string input.
I am calling the parser function yyparse in a loop and reading line by line of user input. I stop the loop if the input is "quit".

The problem i am facing is that when input does'nt match any rule then, the parser stops abruptly, and at next iteration starts off
at same state, expecting the rule which was stopped (due to synatx error )to complete.
It works fine if the input is valid and matches a parser rule.
On syntax error i have redefined the yyerror function, that displays a simple error message.

How do i clear the state of the parser when the input does'nt match any parser rule, and at next iteration the parser starts afresh.
Oct 21 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.