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

Contents of /driver/cduce.ml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (hide annotations)
Tue Jul 10 16:57:42 2007 UTC (5 years, 11 months ago) by abate
File size: 1248 byte(s)
[r2002-10-16 16:18:48 by cvscast] Empty log message

Original author: cvscast
Date: 2002-10-16 16:18:48+00:00
1 abate 10 open Location
2    
3     let input = Stream.of_channel stdin
4     let ppf = Format.std_formatter
5     let prog () =
6     try Parser.prog input
7     with
8     | Stdpp.Exc_located (loc, e) ->
9     raise (Location (loc, e))
10    
11     let rec print_exn ppf = function
12     | Location ((i,j), exn) ->
13     Format.fprintf ppf "Error at chars %i-%i@\n" i j;
14     print_exn ppf exn
15     | Typer.Constraint (s,t,msg) ->
16     Format.fprintf ppf "%s@\n" msg;
17     Format.fprintf ppf "%a is not a subtype of %a@\n"
18     Types.Print.print_descr s
19     Types.Print.print_descr t;
20     Format.fprintf ppf "as shown by %a@\n"
21     Types.Print.print_sample (Types.Sample.get (Types.diff s t))
22     | exn ->
23     Format.fprintf ppf "%s@\n" (Printexc.to_string exn)
24    
25     let phrase ph =
26     match ph.descr with
27     | Ast.EvalStatement e ->
28     let (fv,e) = Typer.expr e in
29     let t = Typer.compute_type Typer.Env.empty e in
30     Format.fprintf ppf "%a@\n" Types.Print.print_descr t;
31 abate 13 | Ast.TypeDecl _ -> ()
32 abate 10 | _ -> assert false
33    
34     let () =
35 abate 13 try
36     let p = prog () in
37     let type_decls =
38     List.fold_left
39     (fun accu ph -> match ph.descr with
40     | Ast.TypeDecl (x,t) -> (x,t) :: accu
41     | _ -> accu
42     ) [] p in
43     Typer.register_global_types type_decls;
44     List.iter phrase p
45 abate 10 with exn -> print_exn ppf exn
46    

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