Previous: TC-2 Chunks, Up: TC-2 Samples [Contents][Index]
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 error→multiple-parse-errors.tig:3.5: syntax error, unexpected ",", expecting ; error→multiple-parse-errors.tig:4.5: syntax error, unexpected ",", expecting ; ⇒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 error→multiple-parse-errors.tig:3.5: syntax error, unexpected ",", expecting ; error→multiple-parse-errors.tig:4.5: syntax error, unexpected ",", expecting ; /* == Abstract Syntax Tree. == */ function _main() = ( ( 1; (); (); 6 ); () ) ⇒3