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

SCM Repository

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

Diff of /branches/vis15/src/compiler/driver/main.sml

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

revision 3444, Fri Nov 20 01:11:12 2015 UTC revision 3445, Fri Nov 20 15:47:57 2015 UTC
# Line 16  Line 16 
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      exception ERROR      fun quitWithError srcFile = raise Error.ERROR
   
     fun quitWithError srcFile = raise ERROR  
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 =
# Line 34  Line 32 
32            else ()            else ()
33    
34    (* compiler front end (parsing, typechecking, and simplification *)    (* compiler front end (parsing, typechecking, and simplification *)
35      fun frontEnd filename = let      fun frontEnd' (errStrm, filename) = let
           val errStrm = Error.mkErrStream filename  
36            val _ = if OS.FileSys.access(filename, [OS.FileSys.A_READ])            val _ = if OS.FileSys.access(filename, [OS.FileSys.A_READ])
37                  then ()                  then ()
38                  else (                  else (
39                    err(concat["source file \"", filename, "\" does not exist or is not readable\n"]);                    err(concat["source file \"", filename, "\" does not exist or is not readable\n"]);
40                    raise ERROR)                    raise Error.ERROR)
41          (***** PARSING *****)          (***** PARSING *****)
42            val parseTree = PhaseTimer.withTimer Timers.timeParser (fn () => let            val parseTree = PhaseTimer.withTimer Timers.timeParser (fn () => let
43                  val inS = TextIO.openIn filename                  val inS = TextIO.openIn filename
# Line 73  Line 70 
70              ()              ()
71            end            end
72    
73      (* a wrapper around the front-end that handles the Error.ERROR exception and reports
74       * the error messages.
75       *)
76        fun frontEnd filename = let
77              val errStrm = Error.mkErrStream filename
78              fun finish () = (
79                    if Error.anyErrors errStrm
80                      then (
81                        Error.report (TextIO.stdErr, errStrm);
82                        quitWithError (Error.sourceFile errStrm))
83                    else if Error.anyWarnings errStrm
84                      then Error.report (TextIO.stdErr, errStrm)
85                      else ())
86              in
87                (frontEnd' (errStrm, filename) handle exn => (finish (); raise exn))
88                before finish()
89              end
90    
91      fun doFile (target : Target.desc, filename) = let      fun doFile (target : Target.desc, filename) = let
92            val baseName = (case OS.Path.splitBaseExt filename            val baseName = (case OS.Path.splitBaseExt filename
93                   of {base, ext=SOME "diderot"} => base                   of {base, ext=SOME "diderot"} => base
# Line 94  Line 109 
109    
110      fun usage (cmd, long) = TextIO.output(TextIO.stdErr, Options.usage (cmd, long))      fun usage (cmd, long) = TextIO.output(TextIO.stdErr, Options.usage (cmd, long))
111    
112      fun handleExn ERROR = OS.Process.failure      fun handleExn Error.ERROR = OS.Process.failure
113        | handleExn exn = (        | handleExn exn = (
114            err (concat [            err (concat [
115                "uncaught exception ", General.exnName exn,                "uncaught exception ", General.exnName exn,

Legend:
Removed from v.3444  
changed lines
  Added in v.3445

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