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

SCM Repository

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

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

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

revision 237, Thu Aug 5 23:17:27 2010 UTC revision 238, Thu Aug 5 23:17:46 2010 UTC
# Line 36  Line 36 
36                    val _ = checkForErrors errStrm                    val _ = checkForErrors errStrm
37                    val ast = (checkTypes pt) handle Typechecker.Error => AST.Program[]                    val ast = (checkTypes pt) handle Typechecker.Error => AST.Program[]
38                    val _ = checkForErrors errStrm                    val _ = checkForErrors errStrm
39                    val _ = ASTPP.output (TextIO.stdOut, ast) (* DEBUG *)                    val _ = ASTPP.output (Log.logFile(), ast) (* DEBUG *)
40                    val simple = Simplify.transform ast                    val simple = Simplify.transform ast
41                    val _ = SimplePP.output (TextIO.stdOut, simple)                    val _ = SimplePP.output (Log.logFile(), simple)
42                    val highIL = Translate.translate simple                    val highIL = Translate.translate simple
43                    in                    in
44                      ()                      ()
# Line 47  Line 47 
47              TextIO.closeIn inS              TextIO.closeIn inS
48            end            end
49    
50      fun main (name: string, args: string list) =      fun doOptions args = let
51            if Inputs.initFromArgs args            val log = ref false
52              then            val defs = ref []
53                (List.app doFile args; OS.Process.success)            fun doOpts [file] = {log = !log, defs = !defs, file = file}
54                | doOpts ("-log"::r) = (log := true; doOpts r)
55                | doOpts (opt::r) = (defs := opt :: !defs; doOpts r)
56              in
57                doOpts args
58              end
59    
60        fun main (name: string, args: string list) = let
61              val {log, defs, file} = doOptions args
62              val {base, ...} = OS.Path.splitBaseExt file
63              in
64                if Inputs.initFromArgs defs
65                  then (Log.init(base ^ ".log"); doFile file; OS.Process.success)
66                handle exn => (                handle exn => (
67                  err (concat [                  err (concat [
68                      "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);                      "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);
# Line 58  Line 70 
70                        (SMLofNJ.exnHistory exn);                        (SMLofNJ.exnHistory exn);
71                      quitWithError())                      quitWithError())
72              else (err "invalid command-line inputs\n"; quitWithError())              else (err "invalid command-line inputs\n"; quitWithError())
73              end
74    
75      fun test file = (main ("", [file]); print "** Success!!\n")      fun test file = (main ("", [file]); print "** Success!!\n")
76    

Legend:
Removed from v.237  
changed lines
  Added in v.238

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