Mercurial > urweb
diff src/compiler.sml @ 29:537db4ee89f4
Translation to Cjr
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 10 Jun 2008 18:28:43 -0400 |
parents | 4ab19c19665f |
children | 1c91c5e6840f |
line wrap: on
line diff
--- a/src/compiler.sml Tue Jun 10 16:22:46 2008 -0400 +++ b/src/compiler.sml Tue Jun 10 18:28:43 2008 -0400 @@ -112,6 +112,15 @@ 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 @@ 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