diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-01-26 16:02:47 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-01-26 16:02:47 -0500 |
commit | e7e2ffc58a4f120801ae69217032948e511af213 (patch) | |
tree | 347ed14f320df53657cab27568e54eac47107d22 /src/compiler.sml | |
parent | 95beeda12defe36c4d4df42d3dee3bd753e19ff5 (diff) |
Elaborating files
Diffstat (limited to 'src/compiler.sml')
-rw-r--r-- | src/compiler.sml | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/compiler.sml b/src/compiler.sml index 967fcf3d..3e39dcc9 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -47,18 +47,41 @@ fun parse filename = 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 |