progs/fun.scala
changeset 323 4ce07c4abdb4
parent 311 6719e8d10a0d
child 380 1e88390e81aa
--- a/progs/fun.scala	Thu Apr 09 07:42:23 2015 +0100
+++ b/progs/fun.scala	Fri Apr 10 18:02:04 2015 +0100
@@ -115,8 +115,8 @@
 
 
 // regular expressions for the While language
-val SYM = RANGE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_")
-val DIGIT = RANGE("0123456789")
+val SYM = RANGE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_".toList)
+val DIGIT = RANGE("0123456789".toList)
 val ID = SYM ~ (SYM | DIGIT).% 
 val NUM = PLUS(DIGIT)
 val KEYWORD : Rexp = "if" | "then" | "else" | "write" | "def"
@@ -445,13 +445,15 @@
 
 def compile(class_name: String, input: String) : String = {
   val tks = tokenizer(input)
-  //println(Prog.parse(tks))
+  println(Prog.parse_single(tks).mkString("\n"))
   val ast = Prog.parse_single(tks)
   val instructions = ast.flatMap(compile_decl).mkString
   (library + instructions).replaceAllLiterally("XXX", class_name)
 }
 
 
+
+
 def compile_file(file_name: String) = {
   val class_name = file_name.split('.')(0)
   val output = compile(class_name, fromFile(file_name))
@@ -476,5 +478,6 @@
 
 
 //examples
-compile_run("defs.rec")
+compile_file("fact.rec")
+//compile_run("defs.rec")
 //compile_run("fact.rec")