progs/bf/bfc0.scala
changeset 738 084e2843f478
parent 736 d3e477fe6c66
--- a/progs/bf/bfc0.scala	Tue Jul 21 00:12:34 2020 +0100
+++ b/progs/bf/bfc0.scala	Fri Jul 24 12:58:19 2020 +0100
@@ -1,7 +1,12 @@
-// A Transpiler for the Brainf*** language
-//=========================================
+// A Transpiler for the Brainf*** language to C
+//===============================================
+//
+// Call with
+//
+//  amm bfc0.sc <<bf_program.bf>>
+//
 
-import io.Source
+
 import scala.util._
 
 
@@ -64,21 +69,15 @@
   (end - start)/(n * 1.0e9)
 }
 
-// the mandelbrot program
-val b0 = load_bff("mandelbrot.bf")
+// Running Testcases
+//===================
 
-println(s"${time_needed(1, compile_run(b0))} secs")
+@doc(" the argument should be a BF program ")
+@main
+def main(fname: String) = {
+  val bf_str = os.read(os.pwd / fname)
+  println(s"${time_needed(1, run(bf_str))} secs")
+}  
 
 
 
-// a benchmark program (counts down from 'Z' to 'A')
-val b1 = """>++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++
-            [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++
-            ++++++++[>++++++++++[>++++++++++[>++++++++++[>+
-            +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++."""
-
-println(s"${time_needed(1, compile_run(b1))} secs")
-
-
-
-