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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33 - (view) (download)
Original Path: trunk/src/driver/main.sml

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 :     end = struct
12 :    
13 :     fun err s = TextIO.output (TextIO.stdErr, s)
14 :     fun err1 c = TextIO.output1 (TextIO.stdErr, c)
15 :     fun errnl s = (err s; err1 #"\n")
16 :    
17 :     fun quit true = OS.Process.exit OS.Process.success
18 :     | quit false = OS.Process.exit OS.Process.failure
19 :    
20 :     (* check for errors and report them if there are any *)
21 :     fun checkForErrors errStrm = (
22 :     Error.report (TextIO.stdErr, errStrm);
23 :     if Error.anyErrors errStrm
24 :     then quit false
25 :     else ())
26 :    
27 :     fun doFile filename = let
28 :     val errStrm = Error.mkErrStream filename
29 :     val inS = TextIO.openIn filename
30 :     in
31 :     case Parser.parseFile (errStrm, inS)
32 :     of NONE => quit false
33 :     | SOME pt => checkForErrors errStrm
34 :     (* end case *);
35 :     TextIO.closeIn inS
36 :     end
37 :    
38 :     fun main (name: string, args: string list) =
39 :     (List.app doFile args; quit true)
40 :     handle exn => (
41 :     err (concat [
42 :     "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);
43 :     List.app (fn s => err (concat [" raised at ", s, "\n"]))
44 :     (SMLofNJ.exnHistory exn);
45 :     quit false)
46 :    
47 :     end

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