§First level

On the lowest level, one parser should be able to answer if the input is correct or not, based on the internal grammar. The result is one boolean value, with some auxiliary info, like the position.

§Second level

On the next level, the parser should be able to recover from some syntax error, and continue with the following input so that more info could be provided in one run.

It seems someone else has already thought about this problem, and Bison has support for this.

A simple and useful strategy is simply to skip the rest of the current input line or current statement if an error is detected: stmt: error ‘;’ /* On error, skip until ‘;’ is read. */

To prevent an outpouring of error messages, the parser will output no error message for another syntax error that happens shortly after the first; only after three consecutive input tokens have been successfully shifted will error messages resume.