217 println(s"Start compilation of $class_name") |
261 println(s"Start compilation of $class_name") |
218 compile_to_file(bl, class_name) |
262 compile_to_file(bl, class_name) |
219 println("generated .j file") |
263 println("generated .j file") |
220 (s"java -jar jvm/jasmin-2.4/jasmin.jar ${class_name}.j").!! |
264 (s"java -jar jvm/jasmin-2.4/jasmin.jar ${class_name}.j").!! |
221 println("generated .class file ") |
265 println("generated .class file ") |
222 println("Time: " + time_needed(1, (s"java ${class_name}/${class_name}").!)._1) |
266 println("Time: " + time_needed(3, (s"java ${class_name}/${class_name}").!)._1) |
223 } |
267 } |
224 |
268 |
225 |
269 |
226 val arr_test = |
270 val arr_test = |
227 List(ArrayDef("a", 10), // new(a[10]) |
271 List(ArrayDef("a", 10), |
228 ArrayDef("b", 2), // new(b[2]) |
272 ArrayDef("b", 2), |
229 AssignA("a", Num(0), Num(10)), // a[0] := 10 |
273 AssignA("a", Num(0), Num(10)), |
230 Assign("x", Ref("a", Num(0))), // x := a[0] |
274 Assign("x", Ref("a", Num(0))), |
231 Write("x"), // write x |
275 Write("x"), |
232 AssignA("b", Num(2), Num(5)), // b[2] := 5 |
276 AssignA("b", Num(1), Num(5)), |
233 Assign("x", Ref("b", Num(1))), // x := b[1] |
277 Assign("x", Ref("b", Num(1))), |
234 Write("x")) // write x |
278 Write("x")) |
235 |
279 |
236 |
280 |
237 compile_and_run(arr_test, "a") |
281 //compile_and_run(arr_test, "a") |
238 |
282 |
|
283 //==================== |
|
284 // Parser Combinators |
|
285 //==================== |
|
286 |
|
287 import scala.language.implicitConversions |
|
288 import scala.language.reflectiveCalls |
|
289 |
|
290 // more convenience for the semantic actions later on |
|
291 case class ~[+A, +B](_1: A, _2: B) |
|
292 |
|
293 type IsSeq[A] = A => Seq[_] |
|
294 |
|
295 abstract class Parser[I : IsSeq, T] { |
|
296 def parse(ts: I): Set[(T, I)] |
|
297 |
|
298 def parse_all(ts: I) : Set[T] = |
|
299 for ((head, tail) <- parse(ts); if (tail.isEmpty)) yield head |
|
300 } |
|
301 |
|
302 class SeqParser[I : IsSeq, T, S](p: => Parser[I, T], q: => Parser[I, S]) extends Parser[I, ~[T, S]] { |
|
303 def parse(sb: I) = |
|
304 for ((head1, tail1) <- p.parse(sb); |
|
305 (head2, tail2) <- q.parse(tail1)) yield (new ~(head1, head2), tail2) |
|
306 } |
|
307 |
|
308 class AltParser[I : IsSeq, T](p: => Parser[I, T], q: => Parser[I, T]) extends Parser[I, T] { |
|
309 def parse(sb: I) = p.parse(sb) ++ q.parse(sb) |
|
310 } |
|
311 |
|
312 class FunParser[I : IsSeq, T, S](p: => Parser[I, T], f: T => S) extends Parser[I, S] { |
|
313 def parse(sb: I) = |
|
314 for ((head, tail) <- p.parse(sb)) yield (f(head), tail) |
|
315 } |
|
316 |
|
317 |
|
318 import scala.util.matching.Regex |
|
319 case class RegexParser(reg: Regex) extends Parser[String, String] { |
|
320 def parse(sb: String) = reg.findPrefixMatchOf(sb) match { |
|
321 case None => Set() |
|
322 case Some(m) => Set((m.matched, m.after.toString)) |
|
323 } |
|
324 } |
|
325 |
|
326 def StringParser(s: String) = RegexParser(Regex.quote(s).r) |
|
327 |
|
328 |
|
329 implicit def string2parser(s : String) = StringParser(s) |
|
330 |
|
331 implicit def ParserOps[I : IsSeq, T](p: Parser[I, T]) = new { |
|
332 def | (q : => Parser[I, T]) = new AltParser[I, T](p, q) |
|
333 def ==>[S] (f: => T => S) = new FunParser[I, T, S](p, f) |
|
334 def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q) |
|
335 } |
|
336 |
|
337 implicit def StringOps(s: String) = new { |
|
338 def | (q : => Parser[String, String]) = new AltParser[String, String](s, q) |
|
339 def | (r: String) = new AltParser[String, String](s, r) |
|
340 def ==>[S] (f: => String => S) = new FunParser[String, String, S](s, f) |
|
341 def ~[S](q : => Parser[String, S]) = |
|
342 new SeqParser[String, String, S](s, q) |
|
343 def ~ (r: String) = |
|
344 new SeqParser[String, String, String](s, r) |
|
345 } |
|
346 |
|
347 |
|
348 val NumParser = RegexParser("[0-9]+".r) ==> (s => s.toInt : Int) |
|
349 val IdParser = RegexParser("[a-z][a-z,0-9]*".r) |
|
350 |
|
351 |
|
352 |
|
353 // Grammar Rules for WHILE with arrays |
|
354 |
|
355 lazy val AExp: Parser[String, AExp] = |
|
356 (Te ~ "+" ~ AExp) ==> { case x ~ _ ~ z => Aop("+", x, z):AExp } | |
|
357 (Te ~ "-" ~ AExp) ==> { case x ~ _ ~ z => Aop("-", x, z):AExp } | Te |
|
358 lazy val Te: Parser[String, AExp] = |
|
359 (Fa ~ "*" ~ Te) ==> { case x ~ _ ~ z => Aop("*", x, z):AExp } | Fa |
|
360 lazy val Fa: Parser[String, AExp] = |
|
361 ("(" ~ AExp ~ ")") ==> { case _ ~ y ~ _ => y } | |
|
362 (IdParser ~ "[" ~ AExp ~ "]") ==> { case x ~ _ ~ y ~ _ => Ref(x, y) } | |
|
363 IdParser ==> Var | |
|
364 NumParser ==> Num |
|
365 |
|
366 // boolean expressions |
|
367 lazy val BExp: Parser[String, BExp] = |
|
368 (AExp ~ "=" ~ AExp) ==> { case x ~ y ~ z => Bop("=", x, z):BExp } | |
|
369 (AExp ~ "!=" ~ AExp) ==> { case x ~ y ~ z => Bop("!=", x, z):BExp } | |
|
370 (AExp ~ "<" ~ AExp) ==> { case x ~ y ~ z => Bop("<", x, z):BExp } | |
|
371 (AExp ~ ">" ~ AExp) ==> { case x ~ y ~ z => Bop("<", z, x):BExp } | |
|
372 ("true" ==> ((_) => True:BExp )) | |
|
373 ("false" ==> ((_) => False:BExp )) | |
|
374 ("(" ~ BExp ~ ")") ==> { case x ~ y ~ z => y} |
|
375 |
|
376 lazy val Stmt: Parser[String, Stmt] = |
|
377 ("skip" ==> (_ => Skip: Stmt)) | |
|
378 (IdParser ~ ":=" ~ AExp) ==> { case x ~ y ~z => Assign(x, z): Stmt } | |
|
379 (IdParser ~ "[" ~ AExp ~ "]" ~ ":=" ~ AExp) ==> { |
|
380 case x ~ _ ~ z ~ _ ~ _ ~ u => AssignA(x, z, u): Stmt } | |
|
381 ("if" ~ BExp ~ "then" ~ Block ~ "else" ~ Block) ==> |
|
382 { case _ ~ y ~ _ ~ u ~ _ ~w => If(y, u, w): Stmt } | |
|
383 ("while" ~ BExp ~ "do" ~ Block) ==> { case _ ~ y ~ _ ~ w => While(y, w) } | |
|
384 ("new(" ~ IdParser ~ "[" ~ NumParser ~ "])") ==> { |
|
385 case _ ~ y ~ _ ~ u ~ _ => ArrayDef(y, u) } | |
|
386 ("write" ~ IdParser) ==> { case _ ~ y => Write(y) } |
|
387 |
|
388 lazy val Stmts: Parser[String, Block] = |
|
389 (Stmt ~ ";" ~ Stmts) ==> { case x ~ _ ~ z => x :: z : Block } | |
|
390 (Stmt ==> ((s) => List(s) : Block)) |
|
391 |
|
392 |
|
393 lazy val Block: Parser[String, Block] = |
|
394 ("{" ~ Stmts ~ "}") ==> { case _ ~ y ~ _ => y} | |
|
395 (Stmt ==> (s => List(s))) |
|
396 |
|
397 //Stmts.parse_all("x2:=5+a") |
|
398 //Stmts.parse_all("x2:=5+a[3+a]") |
|
399 //Stmts.parse_all("a[x2+3]:=5+a[3+a]") |
|
400 //Block.parse_all("{x:=5;y:=8}") |
|
401 //Block.parse_all("if(false)then{x:=5}else{x:=10}") |
|
402 |
|
403 |
|
404 |
|
405 val fib = """ |
|
406 n := 10; |
|
407 minus1 := 0; |
|
408 minus2 := 1; |
|
409 temp:=0; |
|
410 while (n > 0) do { |
|
411 temp := minus2; |
|
412 minus2 := minus1 + minus2; |
|
413 minus1 := temp; |
|
414 n := n - 1}; |
|
415 result := minus2; |
|
416 write result |
|
417 """.replaceAll("\\s+", "") |
|
418 |
|
419 val fib_prog = Stmts.parse_all(fib).toList |
|
420 //compile_and_run(fib_prog.head, "fib") |
|
421 |
|
422 //====================================== |
|
423 // BF transpiler into WHILE with arrays |
|
424 //====================================== |
|
425 |
|
426 // simple BF instructions translation |
|
427 def instr(c: Char) : String = c match { |
|
428 case '>' => "ptr := ptr + 1;" |
|
429 case '<' => "ptr := ptr - 1;" |
|
430 case '+' => "mem[ptr] := mem[ptr] + 1;" |
|
431 case '-' => "mem[ptr] := mem[ptr] - 1;" |
|
432 case '.' => "x := mem[ptr]; write x;" |
|
433 //case ',' => "XXX" // "ptr = getchar();\n" |
|
434 case '[' => "while (mem[ptr] != 0) do {" |
|
435 case ']' => "skip};" |
|
436 case _ => "" |
|
437 } |
|
438 |
|
439 def instrs(prog: String) : String = |
|
440 prog.toList.map(instr).mkString |
|
441 |
|
442 |
|
443 // Note: the mandelbrot.bf program is so large that |
|
444 // it does not fit inside the limitations of what the |
|
445 // JVM imposes on methods (only 64K of instructions). |
|
446 // Therefore some optimisations are first applied to |
|
447 // BF programs before WHILE programs are created. The |
|
448 // optimisations are |
|
449 // |
|
450 // - replacing BF-loops of the form [-] |
|
451 // - combining single increment/decrement instructions |
|
452 // |
|
453 // The size of the resulting .j-file is 270K. |
|
454 |
|
455 def splice(cs: List[Char], acc: List[(Char, Int)]) : List[(Char, Int)] = (cs, acc) match { |
|
456 case (Nil, acc) => acc |
|
457 case (c :: cs, Nil) => splice(cs, List((c, 1))) |
|
458 case (c :: cs, (d, n) :: acc) => |
|
459 if (c == d) splice(cs, (c, n + 1) :: acc) |
|
460 else splice(cs, (c, 1) :: (d, n) :: acc) |
|
461 } |
|
462 |
|
463 def spl(s: String) = splice(s.toList, Nil).reverse |
|
464 |
|
465 def instr2(c: Char, n: Int) : String = c match { |
|
466 case '>' => s"ptr := ptr + $n;" |
|
467 case '<' => s"ptr := ptr - $n;" |
|
468 case '0' => s"mem[ptr] := 0;" |
|
469 case '+' => s"mem[ptr] := mem[ptr] + $n;" |
|
470 case '-' => s"mem[ptr] := mem[ptr] - $n;" |
|
471 case '.' => s"x := mem[ptr]; write x;" |
|
472 case '[' => "while (mem[ptr] != 0) do {" * n |
|
473 case ']' => "skip};" * n |
|
474 case _ => "" |
|
475 } |
|
476 |
|
477 def instrs2(prog: String) : String = |
|
478 spl(prog.replaceAll("""\[-\]""", "0")).map{ case (c, n) => instr2(c, n) }.mkString |
|
479 |
|
480 def bf_str(prog: String) : String = { |
|
481 "new(mem[30000]);" ++ |
|
482 "ptr := 15000;" ++ |
|
483 instrs2(prog) ++ |
|
484 "skip" |
|
485 } |
|
486 |
|
487 def bf_run(prog: String, name: String) = { |
|
488 println(s"BF pre-processing of $name") |
|
489 val bf_string = bf_str(prog).replaceAll("\\s", "") |
|
490 println(s"BF parsing (program length ${bf_string.length} characters)") |
|
491 val (time, bf_prog) = time_needed(1, Stmts.parse_all(bf_string).toList.head) |
|
492 println(s"BF generated WHILE program (needed $time for parsing)") |
|
493 compile_and_run(bf_prog, name) |
|
494 } |
|
495 |
|
496 // a benchmark program (counts down from 'Z' to 'A') |
|
497 val bf0 = """>++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++ |
|
498 [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++ |
|
499 ++++++++[>++++++++++[>++++++++++[>++++++++++[>+ |
|
500 +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.""" |
|
501 |
|
502 bf_run(bf0, "bench") |
|
503 |
|
504 // Sierpinski triangle |
|
505 val bf1 = """++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[ |
|
506 ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<< |
|
507 ]>.>+[>>]>+]""" |
|
508 |
|
509 bf_run(bf1, "sier") |
|
510 |
|
511 // Helo World! |
|
512 bf_run("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++ |
|
513 ..+++.>>.<-.<.+++.------.--------.>>+.>++.""", "hello") |
|
514 |
|
515 // Fibonacci |
|
516 val bf2 = """+++++++++++ |
|
517 >+>>>>++++++++++++++++++++++++++++++++++++++++++++ |
|
518 >++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+> |
|
519 +<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[- |
|
520 <-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<< |
|
521 -]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]] |
|
522 >[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++ |
|
523 +++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++ |
|
524 ++++++++++++++++++++++++++++++++++++++++++++.[-]<< |
|
525 <<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<< |
|
526 [-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]""" |
|
527 |
|
528 bf_run(bf2, "fibs") |
|
529 |
|
530 // Mandelbrot Set |
|
531 //---------------- |
|
532 // |
|
533 // Note: Parsing of the generated WHILE program (around 60K in size) |
|
534 // takes approximately 10 minutes |
|
535 |
|
536 |
|
537 |
|
538 bf_run("""A mandelbrot set fractal viewer in brainf*** written by Erik Bosman |
|
539 +++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ |
|
540 >>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+ |
|
541 <<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>> |
|
542 >+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>> |
|
543 >>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>> |
|
544 >>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>> |
|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