5.5.1. Terminal Error handler

Start ocaml section to src/flx_terminate.mli[1 /1 ]
     1: # 5 "./lpsrc/flx_util.ipk"
     2: (** Misc compiler utilities *)
     3: 
     4: val terminate:
     5:   bool ->
     6:   exn ->
     7:   unit
     8: (** terminate the top level program in case of error *)
     9: 
End ocaml section to src/flx_terminate.mli[1]
Start ocaml section to src/flx_terminate.ml[1 /1 ]
     1: # 15 "./lpsrc/flx_util.ipk"
     2: open Flx_srcref
     3: open Flx_exceptions
     4: 
     5: let terminate rrp = let return_parity = not rrp in function
     6:   | Exit n ->
     7:     exit (if return_parity then n else (if n=0 then 1 else 0))
     8: 
     9:   | Flx_cexpr.Unknown_prec s ->
    10:     flush stdout; print_endline ("Unknown Precedence name '"^s^"'");
    11:     exit (if return_parity then 1 else 0)
    12: 
    13:   | LexError s ->
    14:     flush stdout; print_endline "LEX ERROR";
    15:     print_endline s;
    16:     exit (if return_parity then 1 else 0)
    17: 
    18:   | TokenError s ->
    19:     flush stdout; print_endline "TOKEN ERROR";
    20:     print_endline s;
    21:     exit (if return_parity then 1 else 0)
    22: 
    23:   | SyntaxError s ->
    24:     flush stdout; print_endline "SYNTAX ERROR";
    25:     print_endline s;
    26:     exit (if return_parity then 1 else 0)
    27: 
    28:   | ParseError s ->
    29:     flush stdout; print_endline "PARSE ERROR";
    30:     print_endline s;
    31:     exit (if return_parity then 1 else 0)
    32: 
    33:   | ClientError (sr,s) ->
    34:     flush stdout; print_endline "CLIENT ERROR";
    35:     print_endline s;
    36:     print_endline ("In " ^ long_string_of_src sr);
    37:     exit (if return_parity then 1 else 0)
    38: 
    39:   | ClientErrorn (srs,s) ->
    40:     flush stdout; print_endline "CLIENT ERROR";
    41:     print_endline s;
    42:     List.iter (fun sr ->
    43:       print_endline ("See: " ^ long_string_of_src sr)
    44:     )
    45:     srs
    46:     ;
    47:     exit (if return_parity then 1 else 0)
    48: 
    49:   | ClientError2 (sr,sr2,s) ->
    50:     flush stdout; print_endline "CLIENT ERROR";
    51:     print_endline s;
    52:     print_endline ("In " ^ long_string_of_src sr);
    53:     print_endline ("See also " ^ long_string_of_src sr2);
    54:     exit (if return_parity then 1 else 0)
    55: 
    56:   | SystemError (sr,s) ->
    57:     flush stdout; print_endline "FELIX COMPILER ERROR";
    58:     print_endline ("In " ^ long_string_of_src sr);
    59:     print_endline s;
    60:     exit (if return_parity then 1 else 0)
    61: 
    62: 
    63:   | Failure s ->
    64:     flush stdout; print_endline "SYSTEM FAILURE";
    65:     print_endline s;
    66:     exit (if return_parity then 1 else 0)
    67: 
    68:   | x ->
    69:     flush stdout; print_endline "EXCEPTION";
    70:     print_endline (Printexc.to_string x);
    71:     exit (if return_parity then 1 else 0)
    72: 
End ocaml section to src/flx_terminate.ml[1]