diff src/compiler.sml @ 5:258261a53842

Elaborating files
author Adam Chlipala <adamc@hcoop.net>
date Sat, 26 Jan 2008 16:02:47 -0500
parents 5c3cc348e9e6
children f1c36df29ed7
line wrap: on
line diff
--- a/src/compiler.sml	Sat Jan 26 15:29:09 2008 -0500
+++ b/src/compiler.sml	Sat Jan 26 16:02:47 2008 -0500
@@ -47,18 +47,41 @@
 	val (absyn, _) = LacwebP.parse (30, lexer, parseerror, ())
     in
         TextIO.closeIn file;
-        SOME absyn
+        if ErrorMsg.anyErrors () then
+            NONE
+        else
+            SOME absyn
     end
     handle LrParser.ParseError => NONE
 
+fun elaborate env filename =
+    case parse filename of
+        NONE => NONE
+      | SOME file =>
+        let
+            val out = Elaborate.elabFile env file
+        in
+            if ErrorMsg.anyErrors () then
+                NONE
+            else
+                SOME out
+        end
+            
+
 fun testParse filename =
     case parse filename of
-        NONE => print "Parse error\n"
+        NONE => print "Failed\n"
       | SOME file =>
-        if ErrorMsg.anyErrors () then
-            print "Recoverable parse error\n"
-        else
-            (Print.print (SourcePrint.p_file file);
-             print "\n")
+        (Print.print (SourcePrint.p_file file);
+         print "\n")
+
+fun testElaborate filename =
+    (case elaborate ElabEnv.empty filename of
+         NONE => print "Failed\n"
+       | SOME (_, file) =>
+         (Print.print (ElabPrint.p_file ElabEnv.empty file);
+          print "\n"))
+    handle ElabEnv.UnboundNamed n =>
+           print ("Unbound named " ^ Int.toString n ^ "\n")
 
 end