Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /trunk/src/driver/main.sml
ViewVC logotype

Annotation of /trunk/src/driver/main.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88 - (view) (download)

1 : jhr 33 (* main.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure Main : sig
8 :    
9 :     val main : (string * string list) -> OS.Process.status
10 :    
11 : jhr 35 val test : string -> unit
12 :    
13 : jhr 33 end = struct
14 :    
15 :     fun err s = TextIO.output (TextIO.stdErr, s)
16 :     fun err1 c = TextIO.output1 (TextIO.stdErr, c)
17 :     fun errnl s = (err s; err1 #"\n")
18 :    
19 : jhr 35 fun quitWithError () = raise Fail "error"
20 : jhr 33
21 :     (* check for errors and report them if there are any *)
22 :     fun checkForErrors errStrm = (
23 :     Error.report (TextIO.stdErr, errStrm);
24 :     if Error.anyErrors errStrm
25 : jhr 35 then quitWithError ()
26 : jhr 33 else ())
27 :    
28 :     fun doFile filename = let
29 :     val errStrm = Error.mkErrStream filename
30 :     val inS = TextIO.openIn filename
31 : jhr 86 val checkTypes = Typechecker.check errStrm
32 : jhr 33 in
33 :     case Parser.parseFile (errStrm, inS)
34 : jhr 35 of NONE => (checkForErrors errStrm; quitWithError ())
35 : jhr 70 | SOME pt => (
36 :     checkForErrors errStrm;
37 : jhr 88 ignore (checkTypes pt) handle Typechecker.Error => ();
38 : jhr 86 checkForErrors errStrm)
39 : jhr 33 (* end case *);
40 :     TextIO.closeIn inS
41 :     end
42 :    
43 :     fun main (name: string, args: string list) =
44 : jhr 35 (List.app doFile args; OS.Process.success)
45 : jhr 33 handle exn => (
46 :     err (concat [
47 :     "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);
48 :     List.app (fn s => err (concat [" raised at ", s, "\n"]))
49 :     (SMLofNJ.exnHistory exn);
50 : jhr 35 quitWithError())
51 : jhr 33
52 : jhr 35 fun test file = (main ("", [file]); print "** Success!!\n")
53 :    
54 : jhr 33 end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0