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 35 - (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 :     in
32 :     case Parser.parseFile (errStrm, inS)
33 : jhr 35 of NONE => (checkForErrors errStrm; quitWithError ())
34 : jhr 33 | SOME pt => checkForErrors errStrm
35 :     (* end case *);
36 :     TextIO.closeIn inS
37 :     end
38 :    
39 :     fun main (name: string, args: string list) =
40 : jhr 35 (List.app doFile args; OS.Process.success)
41 : jhr 33 handle exn => (
42 :     err (concat [
43 :     "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);
44 :     List.app (fn s => err (concat [" raised at ", s, "\n"]))
45 :     (SMLofNJ.exnHistory exn);
46 : jhr 35 quitWithError())
47 : jhr 33
48 : jhr 35 fun test file = (main ("", [file]); print "** Success!!\n")
49 :    
50 : jhr 33 end

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