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

SCM Repository

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

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

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

revision 34, Thu Feb 11 00:38:12 2010 UTC revision 35, Thu Feb 11 01:04:20 2010 UTC
# Line 8  Line 8 
8    
9      val main : (string * string list) -> OS.Process.status      val main : (string * string list) -> OS.Process.status
10    
11        val test : string -> unit
12    
13    end = struct    end = struct
14    
15      fun err s = TextIO.output (TextIO.stdErr, s)      fun err s = TextIO.output (TextIO.stdErr, s)
16      fun err1 c =  TextIO.output1 (TextIO.stdErr, c)      fun err1 c =  TextIO.output1 (TextIO.stdErr, c)
17      fun errnl s = (err s; err1 #"\n")      fun errnl s = (err s; err1 #"\n")
18    
19      fun quit true = OS.Process.exit OS.Process.success      fun quitWithError () = raise Fail "error"
       | quit false = OS.Process.exit OS.Process.failure  
20    
21    (* check for errors and report them if there are any *)    (* check for errors and report them if there are any *)
22      fun checkForErrors errStrm = (      fun checkForErrors errStrm = (
23            Error.report (TextIO.stdErr, errStrm);            Error.report (TextIO.stdErr, errStrm);
24            if Error.anyErrors errStrm            if Error.anyErrors errStrm
25              then quit false              then quitWithError ()
26              else ())              else ())
27    
28      fun doFile filename = let      fun doFile filename = let
# Line 29  Line 30 
30            val inS = TextIO.openIn filename            val inS = TextIO.openIn filename
31            in            in
32              case Parser.parseFile (errStrm, inS)              case Parser.parseFile (errStrm, inS)
33               of NONE => quit false               of NONE => (checkForErrors errStrm; quitWithError ())
34                | SOME pt => checkForErrors errStrm                | SOME pt => checkForErrors errStrm
35              (* end case *);              (* end case *);
36              TextIO.closeIn inS              TextIO.closeIn inS
37            end            end
38    
39      fun main (name: string, args: string list) =      fun main (name: string, args: string list) =
40            (List.app doFile args; quit true)            (List.app doFile args; OS.Process.success)
41          handle exn => (          handle exn => (
42            err (concat [            err (concat [
43                "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);                "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);
44                List.app (fn s => err (concat ["  raised at ", s, "\n"]))                List.app (fn s => err (concat ["  raised at ", s, "\n"]))
45                  (SMLofNJ.exnHistory exn);                  (SMLofNJ.exnHistory exn);
46                quit false)                quitWithError())
47    
48        fun test file = (main ("", [file]); print "** Success!!\n")
49    
50    end    end

Legend:
Removed from v.34  
changed lines
  Added in v.35

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