Noeud « Previous »: T2 Chunks, Noeud « Up »: T2 Samples



4.4.2.3 T2 Error Recovery

Another part of T2 is the improvement of your parser: it must be robust to some forms of errors. Observe that on the following input:

     (
       1;
       (2, 3);
       (4, 5);
       6
     )
     File 40: multiple-parse-errors.tig

several parse errors are reported, not merely the first one:

     $ tc multiple-parse-errors.tig
     error-->multiple-parse-errors.tig:3.4: syntax error, unexpected ",", expecting ";"
     error-->multiple-parse-errors.tig:4.4: syntax error, unexpected ",", expecting ";"
     =>3
     Example 41: tc multiple-parse-errors.tig

Of course, the exit status still reveals the parse error. Be sure that your error recovery does not break the rest of the compiler...

     $ tc -AD multiple-parse-errors.tig
     error-->multiple-parse-errors.tig:3.4: syntax error, unexpected ",", expecting ";"
     error-->multiple-parse-errors.tig:4.4: syntax error, unexpected ",", expecting ";"
     /* == Abstract Syntax Tree. == */
     (
        1;
        ();
        ();
        6
     )
     =>3
     Example 42: tc -AD multiple-parse-errors.tig