Bison uses a special error token (called ‘error’) that one can use in a Bison parser to recover from errors. Is there a way to return this specific token from a scanner generated by Flex?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The ‘error’ token is not really a token. It’s used for error handling only.
On http://dinosaur.compilertools.net/yacc/index.html you can read: The token name error is reserved for error handling, and should not be used naively.
In my own parser I use the error token like this (to parse a C-like macro-language:
If the user makes an error, yacc/bison will go on until the next semi-colon (end of a statement) and then go on with the next statement.