|
1 // A Small Compiler for the WHILE Language |
|
2 // |
|
3 // - includes arrays and a small parser for |
|
4 // WHILE programs |
|
5 // |
|
6 // - transpiles BF programs into WHILE programs |
|
7 // and compiles and runs them |
|
8 // |
|
9 // Call with |
|
10 // |
|
11 // scala compile_arr.scala |
|
12 |
|
13 // Mandelbrot |
|
14 // mand.j size 232266 |
|
15 // mand.class size 21787 |
|
16 // running time 16 secs |
|
17 |
|
18 // the abstract syntax trees |
|
19 abstract class Stmt |
|
20 abstract class AExp |
|
21 abstract class BExp |
|
22 type Block = List[Stmt] |
|
23 |
|
24 // statements |
|
25 case object Skip extends Stmt |
|
26 case class ArrayDef(s: String, n: Int) extends Stmt |
|
27 case class If(a: BExp, bl1: Block, bl2: Block) extends Stmt |
|
28 case class While(b: BExp, bl: Block) extends Stmt |
|
29 case class Assign(s: String, a: AExp) extends Stmt // var := exp |
|
30 case class AssignA(s: String, a1: AExp, a2: AExp) extends Stmt // arr[exp1] := exp2 |
|
31 case class Write(s: String) extends Stmt |
|
32 case class Read(s: String) extends Stmt |
|
33 |
|
34 // arithmetic expressions |
|
35 case class Var(s: String) extends AExp |
|
36 case class Num(i: Int) extends AExp |
|
37 case class Aop(o: String, a1: AExp, a2: AExp) extends AExp |
|
38 case class Ref(s: String, a: AExp) extends AExp |
|
39 |
|
40 // boolean expressions |
|
41 case object True extends BExp |
|
42 case object False extends BExp |
|
43 case class Bop(o: String, a1: AExp, a2: AExp) extends BExp |
|
44 |
|
45 |
|
46 // compiler headers needed for the JVM |
|
47 // (contains an init method, as well as methods for read and write) |
|
48 val beginning = """ |
|
49 .class public XXX.XXX |
|
50 .super java/lang/Object |
|
51 |
|
52 .method public static write(I)V |
|
53 .limit locals 1 |
|
54 .limit stack 2 |
|
55 getstatic java/lang/System/out Ljava/io/PrintStream; |
|
56 iload 0 |
|
57 i2c ; Int => Char |
|
58 invokevirtual java/io/PrintStream/print(C)V ; println(I)V => print(C)V |
|
59 return |
|
60 .end method |
|
61 |
|
62 .method public static main([Ljava/lang/String;)V |
|
63 .limit locals 200 |
|
64 .limit stack 200 |
|
65 |
|
66 ; COMPILED CODE STARTS |
|
67 |
|
68 """ |
|
69 |
|
70 val ending = """ |
|
71 ; COMPILED CODE ENDS |
|
72 return |
|
73 |
|
74 .end method |
|
75 """ |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 // for generating new labels |
|
81 var counter = -1 |
|
82 |
|
83 def Fresh(x: String) = { |
|
84 counter += 1 |
|
85 x ++ "_" ++ counter.toString() |
|
86 } |
|
87 |
|
88 // environments and instructions |
|
89 type Env = Map[String, Int] |
|
90 |
|
91 // convenient string interpolations |
|
92 // for instructions and labels |
|
93 import scala.language.implicitConversions |
|
94 import scala.language.reflectiveCalls |
|
95 |
|
96 implicit def sring_inters(sc: StringContext) = new { |
|
97 def i(args: Any*): String = " " ++ sc.s(args:_*) ++ "\n" |
|
98 def l(args: Any*): String = sc.s(args:_*) ++ ":\n" |
|
99 } |
|
100 |
|
101 def compile_op(op: String) = op match { |
|
102 case "+" => i"iadd" |
|
103 case "-" => i"isub" |
|
104 case "*" => i"imul" |
|
105 } |
|
106 |
|
107 |
|
108 def compile_num(i: Int) = |
|
109 if (0 <= i && i <= 5) i"iconst_$i" else |
|
110 if (-128 <= i && i <= 127) i"bipush $i" else i"ldc $i" |
|
111 |
|
112 def compile_aload(i: Int) = |
|
113 if (0 <= i && i <= 3) i"aload_$i" else i"aload $i" |
|
114 |
|
115 def compile_iload(i: Int) = |
|
116 if (0 <= i && i <= 3) i"iload_$i" else i"iload $i" |
|
117 |
|
118 def compile_istore(i: Int) = |
|
119 if (0 <= i && i <= 3) i"istore_$i" else i"istore $i" |
|
120 |
|
121 // arithmetic expression compilation |
|
122 def compile_aexp(a: AExp, env : Env) : String = a match { |
|
123 case Num(i) => compile_num(i) |
|
124 case Var(s) => compile_iload(env(s)) |
|
125 case Aop(op, a1, a2) => |
|
126 compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ compile_op(op) |
|
127 case Ref(s, a) => { |
|
128 val arr_safe = Fresh("Arr_safe") |
|
129 val arr_end = Fresh("Arr_end_") |
|
130 compile_aexp(a, env) ++ |
|
131 compile_aload(env(s)) ++ |
|
132 i"dup2" ++ |
|
133 i"arraylength" ++ |
|
134 i"if_icmple $arr_safe" ++ |
|
135 i"pop2" ++ |
|
136 i"iconst_0" ++ |
|
137 i"goto $arr_end" ++ |
|
138 l"$arr_safe" ++ |
|
139 i"swap" ++ |
|
140 i"iaload" ++ |
|
141 l"$arr_end" |
|
142 } |
|
143 } |
|
144 |
|
145 def compile_bop(op: String, jmp: String) = op match { |
|
146 case "==" => i"if_icmpne $jmp" |
|
147 case "!=" => i"if_icmpeq $jmp" |
|
148 case "<" => i"if_icmpge $jmp" |
|
149 } |
|
150 |
|
151 |
|
152 // boolean expression compilation |
|
153 def compile_bexp(b: BExp, env : Env, jmp: String) : String = b match { |
|
154 case True => "" |
|
155 case False => i"goto $jmp" |
|
156 case Bop(op, a1, a2) => |
|
157 compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ compile_bop(op, jmp) |
|
158 } |
|
159 |
|
160 // statement compilation |
|
161 def compile_stmt(s: Stmt, env: Env) : (String, Env) = s match { |
|
162 case Skip => ("", env) |
|
163 case Assign(x, a) => { |
|
164 val index = env.getOrElse(x, env.keys.size) // |
|
165 (compile_aexp(a, env) ++ compile_istore(index), env + (x -> index)) |
|
166 } |
|
167 case If(b, bl1, bl2) => { |
|
168 val if_else = Fresh("If_else") |
|
169 val if_end = Fresh("If_end") |
|
170 val (instrs1, env1) = compile_block(bl1, env) |
|
171 val (instrs2, env2) = compile_block(bl2, env1) |
|
172 (compile_bexp(b, env, if_else) ++ |
|
173 instrs1 ++ |
|
174 i"goto $if_end" ++ |
|
175 l"$if_else" ++ |
|
176 instrs2 ++ |
|
177 l"$if_end", env2) |
|
178 } |
|
179 case While(b, bl) => { |
|
180 val loop_begin = Fresh("Loop_begin") |
|
181 val loop_end = Fresh("Loop_end") |
|
182 val (instrs1, env1) = compile_block(bl, env) |
|
183 (l"$loop_begin" ++ |
|
184 compile_bexp(b, env, loop_end) ++ |
|
185 instrs1 ++ |
|
186 i"goto $loop_begin" ++ |
|
187 l"$loop_end", env1) |
|
188 } |
|
189 case Write(x) => |
|
190 (compile_iload(env(x)) ++ |
|
191 i"invokestatic XXX/XXX/write(I)V", env) |
|
192 case Read(x) => { |
|
193 val index = env.getOrElse(x, env.keys.size) |
|
194 (i"invokestatic XXX/XXX/read()I" ++ |
|
195 compile_istore(index), env + (x -> index)) |
|
196 } |
|
197 case ArrayDef(s: String, n: Int) => { |
|
198 val index = if (env.isDefinedAt(s)) throw new Exception("array def error") else |
|
199 env.keys.size |
|
200 (i"ldc $n" ++ |
|
201 i"newarray int" ++ |
|
202 i"astore $index", env + (s -> index)) |
|
203 } |
|
204 case AssignA(s, a1, a2) => { |
|
205 val arr_safe = Fresh("Arr_safe") |
|
206 val arr_end = Fresh("Arr_end_") |
|
207 val index = if (env.isDefinedAt(s)) env(s) else |
|
208 throw new Exception("array not defined") |
|
209 (compile_aexp(a1, env) ++ |
|
210 compile_aload(env(s)) ++ |
|
211 i"dup2" ++ |
|
212 i"arraylength" ++ |
|
213 i"if_icmple $arr_safe" ++ |
|
214 i"pop2" ++ |
|
215 i"goto $arr_end" ++ |
|
216 l"$arr_safe" ++ |
|
217 i"swap" ++ |
|
218 compile_aexp(a2, env) ++ |
|
219 i"iastore" ++ |
|
220 l"$arr_end", env) |
|
221 } |
|
222 } |
|
223 |
|
224 // compilation of a block (i.e. list of statements) |
|
225 def compile_block(bl: Block, env: Env) : (String, Env) = bl match { |
|
226 case Nil => ("", env) |
|
227 case s::bl => { |
|
228 val (instrs1, env1) = compile_stmt(s, env) |
|
229 val (instrs2, env2) = compile_block(bl, env1) |
|
230 (instrs1 ++ instrs2, env2) |
|
231 } |
|
232 } |
|
233 |
|
234 |
|
235 // main compilation function for blocks |
|
236 def compile(bl: Block, class_name: String) : String = { |
|
237 val instructions = compile_block(bl, Map())._1 |
|
238 (beginning ++ instructions ++ ending).replaceAllLiterally("XXX", class_name) |
|
239 } |
|
240 |
|
241 |
|
242 // Fibonacci numbers as a test-case |
|
243 val fib_test = |
|
244 List(Read("n"), // read n; |
|
245 Assign("minus1",Num(0)), // minus1 := 0; |
|
246 Assign("minus2",Num(1)), // minus2 := 1; |
|
247 Assign("temp",Num(0)), // temp := 0; |
|
248 While(Bop("<",Num(0),Var("n")), // while n > 0 do { |
|
249 List(Assign("temp",Var("minus2")), // temp := minus2; |
|
250 Assign("minus2",Aop("+",Var("minus1"),Var("minus2"))), |
|
251 // minus2 := minus1 + minus2; |
|
252 Assign("minus1",Var("temp")), // minus1 := temp; |
|
253 Assign("n",Aop("-",Var("n"),Num(1))))), // n := n - 1 }; |
|
254 Write("minus1")) // write minus1 |
|
255 |
|
256 // prints out the JVM-assembly instructions for fib |
|
257 // |
|
258 // println(compile(fib_test, "fib")) |
|
259 // |
|
260 // can be assembled by hand with |
|
261 // |
|
262 // java -jar jvm/jasmin-2.4/jasmin.jar fib.j |
|
263 // |
|
264 // and started with |
|
265 // |
|
266 // java fib/fib |
|
267 |
|
268 import scala.util._ |
|
269 import scala.sys.process._ |
|
270 |
|
271 def time_needed[T](i: Int, code: => T) = { |
|
272 val start = System.nanoTime() |
|
273 for (j <- 2 to i) code |
|
274 val result = code |
|
275 val end = System.nanoTime() |
|
276 ((end - start) / (i * 1.0e9), result) |
|
277 } |
|
278 |
|
279 def compile_to_file(bl: Block, class_name: String) : Unit = |
|
280 Using(new java.io.FileWriter(class_name + ".j")) { |
|
281 _.write(compile(bl, class_name)) |
|
282 } |
|
283 |
|
284 def compile_and_run(bl: Block, class_name: String) : Unit = { |
|
285 println(s"Start compilation of $class_name") |
|
286 compile_to_file(bl, class_name) |
|
287 println("generated .j file") |
|
288 (s"java -jar jvm/jasmin-2.4/jasmin.jar ${class_name}.j").!! |
|
289 println("generated .class file ") |
|
290 println("Time: " + time_needed(3, (s"java ${class_name}/${class_name}").!)._1) |
|
291 } |
|
292 |
|
293 |
|
294 val arr_test = |
|
295 List(ArrayDef("a", 10), |
|
296 ArrayDef("b", 2), |
|
297 AssignA("a", Num(0), Num(10)), |
|
298 Assign("x", Ref("a", Num(0))), |
|
299 Write("x"), |
|
300 AssignA("b", Num(1), Num(5)), |
|
301 Assign("x", Ref("b", Num(1))), |
|
302 Write("x")) |
|
303 |
|
304 |
|
305 //compile_and_run(arr_test, "a") |
|
306 |
|
307 //==================== |
|
308 // Parser Combinators |
|
309 //==================== |
|
310 |
|
311 import scala.language.implicitConversions |
|
312 import scala.language.reflectiveCalls |
|
313 |
|
314 // more convenience for the semantic actions later on |
|
315 case class ~[+A, +B](_1: A, _2: B) |
|
316 |
|
317 type IsSeq[A] = A => Seq[_] |
|
318 |
|
319 abstract class Parser[I : IsSeq, T] { |
|
320 def parse(ts: I): Set[(T, I)] |
|
321 |
|
322 def parse_all(ts: I) : Set[T] = |
|
323 for ((head, tail) <- parse(ts); if (tail.isEmpty)) yield head |
|
324 } |
|
325 |
|
326 class SeqParser[I : IsSeq, T, S](p: => Parser[I, T], q: => Parser[I, S]) extends Parser[I, ~[T, S]] { |
|
327 def parse(sb: I) = |
|
328 for ((head1, tail1) <- p.parse(sb); |
|
329 (head2, tail2) <- q.parse(tail1)) yield (new ~(head1, head2), tail2) |
|
330 } |
|
331 |
|
332 class AltParser[I : IsSeq, T](p: => Parser[I, T], q: => Parser[I, T]) extends Parser[I, T] { |
|
333 def parse(sb: I) = p.parse(sb) ++ q.parse(sb) |
|
334 } |
|
335 |
|
336 class FunParser[I : IsSeq, T, S](p: => Parser[I, T], f: T => S) extends Parser[I, S] { |
|
337 def parse(sb: I) = |
|
338 for ((head, tail) <- p.parse(sb)) yield (f(head), tail) |
|
339 } |
|
340 |
|
341 |
|
342 import scala.util.matching.Regex |
|
343 case class RegexParser(reg: Regex) extends Parser[String, String] { |
|
344 def parse(sb: String) = reg.findPrefixMatchOf(sb) match { |
|
345 case None => Set() |
|
346 case Some(m) => Set((m.matched, m.after.toString)) |
|
347 } |
|
348 } |
|
349 |
|
350 def StringParser(s: String) = RegexParser(Regex.quote(s).r) |
|
351 |
|
352 |
|
353 implicit def string2parser(s : String) = StringParser(s) |
|
354 |
|
355 implicit def ParserOps[I : IsSeq, T](p: Parser[I, T]) = new { |
|
356 def | (q : => Parser[I, T]) = new AltParser[I, T](p, q) |
|
357 def ==>[S] (f: => T => S) = new FunParser[I, T, S](p, f) |
|
358 def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q) |
|
359 } |
|
360 |
|
361 implicit def StringOps(s: String) = new { |
|
362 def | (q : => Parser[String, String]) = new AltParser[String, String](s, q) |
|
363 def | (r: String) = new AltParser[String, String](s, r) |
|
364 def ==>[S] (f: => String => S) = new FunParser[String, String, S](s, f) |
|
365 def ~[S](q : => Parser[String, S]) = |
|
366 new SeqParser[String, String, S](s, q) |
|
367 def ~ (r: String) = |
|
368 new SeqParser[String, String, String](s, r) |
|
369 } |
|
370 |
|
371 |
|
372 val NumParser = RegexParser("[0-9]+".r) ==> (s => s.toInt : Int) |
|
373 val IdParser = RegexParser("[a-z][a-z,0-9]*".r) |
|
374 |
|
375 |
|
376 |
|
377 // Grammar Rules for WHILE with arrays |
|
378 |
|
379 lazy val AExp: Parser[String, AExp] = |
|
380 (Te ~ "+" ~ AExp) ==> { case x ~ _ ~ z => Aop("+", x, z):AExp } | |
|
381 (Te ~ "-" ~ AExp) ==> { case x ~ _ ~ z => Aop("-", x, z):AExp } | Te |
|
382 lazy val Te: Parser[String, AExp] = |
|
383 (Fa ~ "*" ~ Te) ==> { case x ~ _ ~ z => Aop("*", x, z):AExp } | Fa |
|
384 lazy val Fa: Parser[String, AExp] = |
|
385 ("(" ~ AExp ~ ")") ==> { case _ ~ y ~ _ => y } | |
|
386 (IdParser ~ "[" ~ AExp ~ "]") ==> { case x ~ _ ~ y ~ _ => Ref(x, y) } | |
|
387 IdParser ==> Var | |
|
388 NumParser ==> Num |
|
389 |
|
390 // boolean expressions |
|
391 lazy val BExp: Parser[String, BExp] = |
|
392 (AExp ~ "=" ~ AExp) ==> { case x ~ y ~ z => Bop("=", x, z):BExp } | |
|
393 (AExp ~ "!=" ~ AExp) ==> { case x ~ y ~ z => Bop("!=", x, z):BExp } | |
|
394 (AExp ~ "<" ~ AExp) ==> { case x ~ y ~ z => Bop("<", x, z):BExp } | |
|
395 (AExp ~ ">" ~ AExp) ==> { case x ~ y ~ z => Bop("<", z, x):BExp } | |
|
396 ("true" ==> ((_) => True:BExp )) | |
|
397 ("false" ==> ((_) => False:BExp )) | |
|
398 ("(" ~ BExp ~ ")") ==> { case x ~ y ~ z => y} |
|
399 |
|
400 lazy val Stmt: Parser[String, Stmt] = |
|
401 ("skip" ==> (_ => Skip: Stmt)) | |
|
402 (IdParser ~ ":=" ~ AExp) ==> { case x ~ y ~z => Assign(x, z): Stmt } | |
|
403 (IdParser ~ "[" ~ AExp ~ "]" ~ ":=" ~ AExp) ==> { |
|
404 case x ~ _ ~ z ~ _ ~ _ ~ u => AssignA(x, z, u): Stmt } | |
|
405 ("if" ~ BExp ~ "then" ~ Block ~ "else" ~ Block) ==> |
|
406 { case _ ~ y ~ _ ~ u ~ _ ~w => If(y, u, w): Stmt } | |
|
407 ("while" ~ BExp ~ "do" ~ Block) ==> { case _ ~ y ~ _ ~ w => While(y, w) } | |
|
408 ("new(" ~ IdParser ~ "[" ~ NumParser ~ "])") ==> { |
|
409 case _ ~ y ~ _ ~ u ~ _ => ArrayDef(y, u) } | |
|
410 ("write" ~ IdParser) ==> { case _ ~ y => Write(y) } |
|
411 |
|
412 lazy val Stmts: Parser[String, Block] = |
|
413 (Stmt ~ ";" ~ Stmts) ==> { case x ~ _ ~ z => x :: z : Block } | |
|
414 (Stmt ==> ((s) => List(s) : Block)) |
|
415 |
|
416 |
|
417 lazy val Block: Parser[String, Block] = |
|
418 ("{" ~ Stmts ~ "}") ==> { case _ ~ y ~ _ => y} | |
|
419 (Stmt ==> (s => List(s))) |
|
420 |
|
421 //Stmts.parse_all("x2:=5+a") |
|
422 //Stmts.parse_all("x2:=5+a[3+a]") |
|
423 //Stmts.parse_all("a[x2+3]:=5+a[3+a]") |
|
424 //Block.parse_all("{x:=5;y:=8}") |
|
425 //Block.parse_all("if(false)then{x:=5}else{x:=10}") |
|
426 |
|
427 |
|
428 |
|
429 val fib = """ |
|
430 n := 10; |
|
431 minus1 := 0; |
|
432 minus2 := 1; |
|
433 temp:=0; |
|
434 while (n > 0) do { |
|
435 temp := minus2; |
|
436 minus2 := minus1 + minus2; |
|
437 minus1 := temp; |
|
438 n := n - 1}; |
|
439 result := minus2; |
|
440 write result |
|
441 """.replaceAll("\\s+", "") |
|
442 |
|
443 val fib_prog = Stmts.parse_all(fib).toList |
|
444 //compile_and_run(fib_prog.head, "fib") |
|
445 |
|
446 //====================================== |
|
447 // BF transpiler into WHILE with arrays |
|
448 //====================================== |
|
449 |
|
450 // simple BF instructions translation |
|
451 def instr(c: Char) : String = c match { |
|
452 case '>' => "ptr := ptr + 1;" |
|
453 case '<' => "ptr := ptr - 1;" |
|
454 case '+' => "mem[ptr] := mem[ptr] + 1;" |
|
455 case '-' => "mem[ptr] := mem[ptr] - 1;" |
|
456 case '.' => "x := mem[ptr]; write x;" |
|
457 //case ',' => "XXX" // "ptr = getchar();\n" |
|
458 case '[' => "while (mem[ptr] != 0) do {" |
|
459 case ']' => "skip};" |
|
460 case _ => "" |
|
461 } |
|
462 |
|
463 def instrs(prog: String) : String = |
|
464 prog.toList.map(instr).mkString |
|
465 |
|
466 |
|
467 // Note: the mandelbrot.bf program is so large that |
|
468 // it does not fit inside the limitations of what the |
|
469 // JVM imposes on methods (only 64K of instructions). |
|
470 // Therefore some optimisations are first applied to |
|
471 // BF programs before WHILE programs are created. The |
|
472 // optimisations are |
|
473 // |
|
474 // - replacing BF-loops of the form [-] |
|
475 // - combining single increment/decrement instructions |
|
476 // |
|
477 // The size of the resulting .j-file is 270K. |
|
478 |
|
479 def splice(cs: List[Char], acc: List[(Char, Int)]) : List[(Char, Int)] = (cs, acc) match { |
|
480 case (Nil, acc) => acc |
|
481 case (c :: cs, Nil) => splice(cs, List((c, 1))) |
|
482 case (c :: cs, (d, n) :: acc) => |
|
483 if (c == d) splice(cs, (c, n + 1) :: acc) |
|
484 else splice(cs, (c, 1) :: (d, n) :: acc) |
|
485 } |
|
486 |
|
487 def spl(s: String) = splice(s.toList, Nil).reverse |
|
488 |
|
489 def instr2(c: Char, n: Int) : String = c match { |
|
490 case '>' => s"ptr := ptr + $n;" |
|
491 case '<' => s"ptr := ptr - $n;" |
|
492 case '0' => s"mem[ptr] := 0;" |
|
493 case '+' => s"mem[ptr] := mem[ptr] + $n;" |
|
494 case '-' => s"mem[ptr] := mem[ptr] - $n;" |
|
495 case '.' => s"x := mem[ptr]; write x;" |
|
496 case '[' => "while (mem[ptr] != 0) do {" * n |
|
497 case ']' => "skip};" * n |
|
498 case _ => "" |
|
499 } |
|
500 |
|
501 def instrs2(prog: String) : String = |
|
502 spl(prog.replaceAll("""\[-\]""", "0")).map{ case (c, n) => instr2(c, n) }.mkString |
|
503 |
|
504 def bf_str(prog: String) : String = { |
|
505 "new(mem[30000]);" ++ |
|
506 "ptr := 15000;" ++ |
|
507 instrs2(prog) ++ |
|
508 "skip" |
|
509 } |
|
510 |
|
511 def bf_run(prog: String, name: String) = { |
|
512 println(s"BF pre-processing of $name") |
|
513 val bf_string = bf_str(prog).replaceAll("\\s", "") |
|
514 println(s"BF parsing (program length ${bf_string.length} characters)") |
|
515 val (time, bf_prog) = time_needed(1, Stmts.parse_all(bf_string).toList.head) |
|
516 println(s"BF generated WHILE program (needed $time for parsing)") |
|
517 compile_and_run(bf_prog, name) |
|
518 } |
|
519 |
|
520 // a benchmark program (counts down from 'Z' to 'A') |
|
521 val bf0 = """>++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++ |
|
522 [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++ |
|
523 ++++++++[>++++++++++[>++++++++++[>++++++++++[>+ |
|
524 +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.""" |
|
525 |
|
526 bf_run(bf0, "bench") |
|
527 |
|
528 // Sierpinski triangle |
|
529 val bf1 = """++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[ |
|
530 ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<< |
|
531 ]>.>+[>>]>+]""" |
|
532 |
|
533 bf_run(bf1, "sier") |
|
534 |
|
535 // Helo World! |
|
536 bf_run("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++ |
|
537 ..+++.>>.<-.<.+++.------.--------.>>+.>++.""", "hello") |
|
538 |
|
539 // Fibonacci |
|
540 val bf2 = """+++++++++++ |
|
541 >+>>>>++++++++++++++++++++++++++++++++++++++++++++ |
|
542 >++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+> |
|
543 +<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[- |
|
544 <-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<< |
|
545 -]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]] |
|
546 >[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++ |
|
547 +++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++ |
|
548 ++++++++++++++++++++++++++++++++++++++++++++.[-]<< |
|
549 <<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<< |
|
550 [-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-] |
|
551 [-]++++++++++.""" |
|
552 |
|
553 bf_run(bf2, "fibs") |
|
554 |
|
555 // Mandelbrot Set |
|
556 //---------------- |
|
557 // |
|
558 // Note: Parsing of the generated WHILE program (around 60K in size) |
|
559 // takes approximately 10 minutes |
|
560 |
|
561 |
|
562 |
|
563 bf_run("""A mandelbrot set fractal viewer in brainf*** written by Erik Bosman |
|
564 +++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ |
|
565 >>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+ |
|
566 <<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>> |
|
567 >+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>> |
|
568 >>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>> |
|
569 >>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>> |
|
570 >>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>> |
|
571 [>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<< |
|
572 <<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[ |
|
573 >>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[ |
|
574 >+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->>[ |
|
575 -<<+>>]<<[->>+>>+<<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>>>>>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