diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-06-10 18:28:43 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-06-10 18:28:43 -0400 |
commit | c1c6013533ba8eaa3b41924bcd61d99a4da27955 (patch) | |
tree | 21e70479e0bc1cf28935d2d80700c1c3063ddc36 /src/compiler.sml | |
parent | ecf88cd1a7c5d137a732c4c8eb4d34c5e845ccaf (diff) |
Translation to Cjr
Diffstat (limited to 'src/compiler.sml')
-rw-r--r-- | src/compiler.sml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/compiler.sml b/src/compiler.sml index 26ff6e2b..4276ed46 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -112,6 +112,15 @@ fun cloconv eenv cenv filename = else SOME (Cloconv.cloconv file) +fun cjrize eenv cenv filename = + case cloconv eenv cenv filename of + NONE => NONE + | SOME file => + if ErrorMsg.anyErrors () then + NONE + else + SOME (Cjrize.cjrize file) + fun testParse filename = case parse filename of NONE => print "Failed\n" @@ -173,4 +182,25 @@ fun testCloconv filename = handle FlatEnv.UnboundNamed n => print ("Unbound named " ^ Int.toString n ^ "\n") +fun testCjrize filename = + (case cjrize ElabEnv.basis CoreEnv.basis filename of + NONE => print "Failed\n" + | SOME file => + (Print.print (CjrPrint.p_file CjrEnv.basis file); + print "\n")) + handle CjrEnv.UnboundNamed n => + print ("Unbound named " ^ Int.toString n ^ "\n") + +fun compile filename = + case cjrize ElabEnv.basis CoreEnv.basis filename of + NONE => () + | SOME file => + let + val outf = TextIO.openOut "/tmp/lacweb.c" + val s = TextIOPP.openOut {dst = outf, wid = 80} + in + Print.fprint s (CjrPrint.p_file CjrEnv.basis file); + TextIO.closeOut outf + end + end |