comparison 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
comparison
equal deleted inserted replaced
28:104d43266b33 29:537db4ee89f4
110 if ErrorMsg.anyErrors () then 110 if ErrorMsg.anyErrors () then
111 NONE 111 NONE
112 else 112 else
113 SOME (Cloconv.cloconv file) 113 SOME (Cloconv.cloconv file)
114 114
115 fun cjrize eenv cenv filename =
116 case cloconv eenv cenv filename of
117 NONE => NONE
118 | SOME file =>
119 if ErrorMsg.anyErrors () then
120 NONE
121 else
122 SOME (Cjrize.cjrize file)
123
115 fun testParse filename = 124 fun testParse filename =
116 case parse filename of 125 case parse filename of
117 NONE => print "Failed\n" 126 NONE => print "Failed\n"
118 | SOME file => 127 | SOME file =>
119 (Print.print (SourcePrint.p_file file); 128 (Print.print (SourcePrint.p_file file);
171 (Print.print (FlatPrint.p_file FlatEnv.basis file); 180 (Print.print (FlatPrint.p_file FlatEnv.basis file);
172 print "\n")) 181 print "\n"))
173 handle FlatEnv.UnboundNamed n => 182 handle FlatEnv.UnboundNamed n =>
174 print ("Unbound named " ^ Int.toString n ^ "\n") 183 print ("Unbound named " ^ Int.toString n ^ "\n")
175 184
185 fun testCjrize filename =
186 (case cjrize ElabEnv.basis CoreEnv.basis filename of
187 NONE => print "Failed\n"
188 | SOME file =>
189 (Print.print (CjrPrint.p_file CjrEnv.basis file);
190 print "\n"))
191 handle CjrEnv.UnboundNamed n =>
192 print ("Unbound named " ^ Int.toString n ^ "\n")
193
194 fun compile filename =
195 case cjrize ElabEnv.basis CoreEnv.basis filename of
196 NONE => ()
197 | SOME file =>
198 let
199 val outf = TextIO.openOut "/tmp/lacweb.c"
200 val s = TextIOPP.openOut {dst = outf, wid = 80}
201 in
202 Print.fprint s (CjrPrint.p_file CjrEnv.basis file);
203 TextIO.closeOut outf
204 end
205
176 end 206 end