/[svn]/driver/cduce.ml
ViewVC logotype

Diff of /driver/cduce.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 19 by abate, Tue Jul 10 16:58:37 2007 UTC revision 22 by abate, Tue Jul 10 16:58:50 2007 UTC
# Line 1  Line 1 
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) ->
# Line 43  Line 49 
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    
# Line 60  Line 66 
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    

Legend:
Removed from v.19  
changed lines
  Added in v.22

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5