How do I get Bison to stop on error in the input file?
I tried using the ‘error’ action but it doesn’t seem to help.
The parser processes the entire input file even after it hits an error.
rules:
rules rule
| rules error { declaration_context = false; YYABORT; }
| rule
;
A parser with no
erroractions in the grammar will bail out of theyyparsefunction after the first syntax error occurs. Continued parsing after a syntax error is only possible if you have error production rules. If those do not successfully recover the parse, more errors will follow and this works its way toward a termination sooner or later.Reference: http://www.gnu.org/software/bison/manual/bison.html (2.1.5)