SCM Repository
View of /trunk/src/compiler/driver/main.sml
Parent Directory
|
Revision Log
Revision 110 -
(download)
(annotate)
Wed Jun 23 19:28:48 2010 UTC (10 years, 9 months ago) by jhr
File size: 1596 byte(s)
Wed Jun 23 19:28:48 2010 UTC (10 years, 9 months ago) by jhr
File size: 1596 byte(s)
Moving compiler sources into src/compiler
(* main.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. *) structure Main : sig val main : (string * string list) -> OS.Process.status val test : string -> unit end = struct fun err s = TextIO.output (TextIO.stdErr, s) fun err1 c = TextIO.output1 (TextIO.stdErr, c) fun errnl s = (err s; err1 #"\n") fun quitWithError () = raise Fail "error" (* check for errors and report them if there are any *) fun checkForErrors errStrm = ( Error.report (TextIO.stdErr, errStrm); if Error.anyErrors errStrm then quitWithError () else ()) fun doFile filename = let val errStrm = Error.mkErrStream filename val inS = TextIO.openIn filename val checkTypes = Typechecker.check errStrm in case Parser.parseFile (errStrm, inS) of NONE => (checkForErrors errStrm; quitWithError ()) | SOME pt => let val _ = checkForErrors errStrm; val ast = (checkTypes pt) handle Typechecker.Error => AST.Program[] in checkForErrors errStrm; ASTPP.output (TextIO.stdOut, ast) (* DEBUG *) end (* end case *); TextIO.closeIn inS end fun main (name: string, args: string list) = (List.app doFile args; OS.Process.success) handle exn => ( err (concat [ "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]); List.app (fn s => err (concat [" raised at ", s, "\n"])) (SMLofNJ.exnHistory exn); quitWithError()) fun test file = (main ("", [file]); print "** Success!!\n") end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |