(* Tests going on after an error, as the parser does with try: a driver reads a file's symbols and reports each name `bad` as an error, several calls deep; the error comes back up through them, and the driver reads on from the next symbol. *) module Recover; import Out, Files, Diag, Scan; var failed, names: INT; proc deep(n: INT): ERROR; begin if n > 0 then try deep(n - 1); return nil; end; return Scan.mark("a bad name"); end; proc main*; var err: ERROR; begin if LEN(Scan.open(Files.arg(1))) # 0 then Diag.fatal("no file"); end; while Scan.tok # Scan.sEof do Scan.next; if Scan.tok = Scan.sIdent then INC(names); if Scan.nameOf(Scan.id) = "bad" then err := deep(5); if err # nil then INC(failed); end; end; end; end; Out.int(names); Out.str(" names, "); Out.int(failed); Out.str(" failed, "); Out.int(Diag.errors); Out.str(" errors\n"); Diag.finish; end; end Recover.