TC-2 Error Recovery
Your parser must be robust to (some) syntactic errors. Observe that on the following input several parse errors are reported, not merely the first one:
(
1;
(2, 3);
(4, 5);
6
)
$ tc multiple-parse-errors.tig
multiple-parse-errors.tig:3.3-5: syntax error, unexpected ",", expecting ;
multiple-parse-errors.tig:4.3-5: syntax error, unexpected ",", expecting ;
$ echo $?
3
Of course, the exit status still reveals the parse error. Error recovery must not break the rest of the compiler.
$ tc -XA multiple-parse-errors.tig
/* == Abstract Syntax Tree. == */
function _main() =
(
(
1;
();
();
6
);
()
)
multiple-parse-errors.tig:3.3-5: syntax error, unexpected ",", expecting ;
multiple-parse-errors.tig:4.3-5: syntax error, unexpected ",", expecting ;
$ echo $?
3