| 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 = 1 then (Stream.of_channel stdin) |
| 12 |
|
else if (Array.length argv > 2) or |
| 13 |
|
not (file_exists (Array.get argv 1)) then raise(Usage () ) |
| 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) -> |
| 49 |
| Ast.EvalStatement e -> |
| Ast.EvalStatement e -> |
| 50 |
let (fv,e) = Typer.expr e in |
let (fv,e) = Typer.expr e in |
| 51 |
let t = Typer.type_check Typer.Env.empty e Types.any true in |
let t = Typer.type_check Typer.Env.empty e Types.any true in |
| 52 |
Format.fprintf ppf "%a@\n" Types.Print.print_descr t; |
Format.fprintf ppf "%a@\n" Types.Print.print_descr t |
| 53 |
| Ast.TypeDecl _ -> () |
| Ast.TypeDecl _ -> () |
| 54 |
| _ -> assert false |
| _ -> assert false |
| 55 |
|
|
| 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 |
|
|