| 1 |
open Location |
open Location |
| 2 |
|
open Sys |
| 3 |
|
exception Usage of unit |
| 4 |
|
|
| 5 |
let () = |
let () = |
| 6 |
List.iter |
List.iter |
| 7 |
(fun (n,t) -> Typer.register_global_types [n, mk noloc (Ast.Internal t)]) |
(fun (n,t) -> Typer.register_global_types [n, mk noloc (Ast.Internal t)]) |
| 8 |
Builtin.types |
Builtin.types |
| 9 |
|
|
| 10 |
let input = Stream.of_channel stdin |
|
| 11 |
|
let input = if (Array.length argv > 2) or |
| 12 |
|
not (file_exists (Array.get argv 1)) then raise(Usage () ) |
| 13 |
|
else if Array.length argv = 1 then (Stream.of_channel stdin) |
| 14 |
|
else (Stream.of_channel (open_in (Array.get argv 1))) |
| 15 |
|
|
| 16 |
let ppf = Format.std_formatter |
let ppf = Format.std_formatter |
| 17 |
let prog () = |
let prog () = |
| 18 |
try Parser.prog input |
try Parser.prog input |
| 19 |
with |
with |
| 20 |
| Stdpp.Exc_located (loc, e) -> |
| Stdpp.Exc_located (loc, e) -> raise (Location (loc, e)) |
|
raise (Location (loc, e)) |
|
| 21 |
|
|
| 22 |
let rec print_exn ppf = function |
let rec print_exn ppf = function |
| 23 |
| Location ((i,j), exn) -> |
| Location ((i,j), exn) -> |
| 66 |
List.iter phrase p |
List.iter phrase p |
| 67 |
with (Failure _) as e -> raise e | exn -> print_exn ppf exn |
with (Failure _) as e -> raise e | exn -> print_exn ppf exn |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|