author | Christian Urban <christian.urban@kcl.ac.uk> |
Sat, 09 Nov 2024 06:31:45 +0000 | |
changeset 973 | f25d338d16c9 |
parent 696 | 3a5a7908517f |
permissions | -rw-r--r-- |
696
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
// A Small Compiler for the WHILE Language |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
// - includes arrays and a small parser for |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
// translated BF programs |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
// the abstract syntax trees |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
abstract class Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
abstract class AExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
abstract class BExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
type Block = List[Stmt] |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
// statements |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
case object Skip extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
case class Array(s: String, n: Int) extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
case class If(a: BExp, bl1: Block, bl2: Block) extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
case class While(b: BExp, bl: Block) extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
case class Assign(s: String, a: AExp) extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
case class AssignA(s: String, a1: AExp, a2: AExp) extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
case class Write(s: String) extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
case class Read(s: String) extends Stmt |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
// arithmetic expressions |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
case class Var(s: String) extends AExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
case class Num(i: Int) extends AExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
case class Aop(o: String, a1: AExp, a2: AExp) extends AExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
case class Ref(s: String, a: AExp) extends AExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
// boolean expressions |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
case object True extends BExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
case object False extends BExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
30 |
case class Bop(o: String, a1: AExp, a2: AExp) extends BExp |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
// compiler headers needed for the JVM |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
// (contains an init method, as well as methods for read and write) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
val beginning = """ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
.class public XXX |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
.super java/lang/Object |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
.method public static write : (I)V |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
.limit locals 1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
.limit stack 2 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
getstatic java/lang/System/out Ljava/io/PrintStream; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
iload 0 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
i2c ; Int => Char |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
invokevirtual java/io/PrintStream print (C)V |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
return |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
.end method |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
.method public static read : ()I |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
.limit locals 10 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
.limit stack 10 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
ldc 0 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
istore 1 ; this will hold our final integer |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
Label1: |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
getstatic java/lang/System/in Ljava/io/InputStream; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
invokevirtual java/io/InputStream read ()I |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
istore 2 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
iload 2 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
ldc 10 ; the newline delimiter |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
isub |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
ifeq Label2 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
iload 2 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
ldc 32 ; the space delimiter |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
isub |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
ifeq Label2 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
iload 2 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
ldc 48 ; we have our digit in ASCII, have to subtract it from 48 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
isub |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
ldc 10 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
iload 1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
imul |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
74 |
iadd |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
istore 1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
76 |
goto Label1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
Label2: |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
;when we come here we have our integer computed in local variable 1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
iload 1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
ireturn |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
.end method |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
.method public static main : ([Ljava/lang/String;)V |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
84 |
.limit locals 200 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
.limit stack 200 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
86 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
""" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
val ending = """ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
return |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
.end method |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
""" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
// for generating new labels |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
100 |
var counter = -1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
def Fresh(x: String) = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
103 |
counter += 1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
104 |
x ++ "_" ++ counter.toString() |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
105 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
106 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
// environments and instructions |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
type Env = Map[String, Int] |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
109 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
// convenient string interpolations |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
// for instructions and labels |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
import scala.language.implicitConversions |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
import scala.language.reflectiveCalls |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
implicit def sring_inters(sc: StringContext) = new { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
def i(args: Any*): String = " " ++ sc.s(args:_*) ++ "\n" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
def l(args: Any*): String = sc.s(args:_*) ++ ":\n" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
def compile_op(op: String) = op match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
case "+" => i"iadd" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
case "-" => i"isub" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
case "*" => i"imul" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
125 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
// arithmetic expression compilation |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
def compile_aexp(a: AExp, env : Env) : String = a match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
case Num(i) => i"ldc $i" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
129 |
case Var(s) => i"iload ${env(s)} \t\t; $s" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
130 |
case Aop(op, a1, a2) => |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
131 |
compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ compile_op(op) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
132 |
case Ref(s, a) => |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
i"aload ${env(s)}" ++ compile_aexp(a, env) ++ i"iaload" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
135 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
136 |
// boolean expression compilation |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
def compile_bexp(b: BExp, env : Env, jmp: String) : String = b match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
138 |
case True => "" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
139 |
case False => i"goto $jmp" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
140 |
case Bop("==", a1, a2) => |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ i"if_icmpne $jmp" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
142 |
case Bop("!=", a1, a2) => |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ i"if_icmpeq $jmp" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
case Bop("<", a1, a2) => |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
145 |
compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ i"if_icmpge $jmp" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
// statement compilation |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
149 |
def compile_stmt(s: Stmt, env: Env) : (String, Env) = s match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
case Skip => ("", env) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
151 |
case Assign(x, a) => { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
val index = env.getOrElse(x, env.keys.size) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
(compile_aexp(a, env) ++ i"istore $index \t\t; $x", env + (x -> index)) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
case If(b, bl1, bl2) => { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
val if_else = Fresh("If_else") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
val if_end = Fresh("If_end") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
val (instrs1, env1) = compile_block(bl1, env) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
val (instrs2, env2) = compile_block(bl2, env1) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
(compile_bexp(b, env, if_else) ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
instrs1 ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
i"goto $if_end" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
l"$if_else" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
instrs2 ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
l"$if_end", env2) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
case While(b, bl) => { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
168 |
val loop_begin = Fresh("Loop_begin") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
val loop_end = Fresh("Loop_end") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
val (instrs1, env1) = compile_block(bl, env) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
(l"$loop_begin" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
compile_bexp(b, env, loop_end) ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
instrs1 ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
i"goto $loop_begin" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
l"$loop_end", env1) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
case Write(x) => |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
(i"iload ${env(x)} \t\t; $x" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
i"invokestatic XXX write (I)V", env) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
case Read(x) => { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
val index = env.getOrElse(x, env.keys.size) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
(i"invokestatic XXX read ()I" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
i"istore $index \t\t; $x", env + (x -> index)) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
184 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
185 |
case Array(s: String, n: Int) => { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
186 |
val index = if (env.isDefinedAt(s)) throw new Exception("array def error") else |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
187 |
env.keys.size |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
188 |
(i"ldc $n" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
189 |
i"newarray int" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
190 |
i"astore $index", env + (s -> index)) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
191 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
192 |
case AssignA(s, a1, a2) => { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
193 |
val index = if (env.isDefinedAt(s)) env(s) else |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
194 |
throw new Exception("array not defined") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
(i"aload ${env(s)}" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
compile_aexp(a1, env) ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
compile_aexp(a2, env) ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
i"iastore", env) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
202 |
// compilation of a block (i.e. list of instructions) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
203 |
def compile_block(bl: Block, env: Env) : (String, Env) = bl match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
204 |
case Nil => ("", env) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
case s::bl => { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
val (instrs1, env1) = compile_stmt(s, env) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
val (instrs2, env2) = compile_block(bl, env1) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
(instrs1 ++ instrs2, env2) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
211 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
212 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
213 |
// main compilation function for blocks |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
214 |
def compile(bl: Block, class_name: String) : String = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
val instructions = compile_block(bl, Map.empty)._1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
(beginning ++ instructions.mkString ++ ending).replaceAllLiterally("XXX", class_name) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
217 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
218 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
219 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
220 |
// Fibonacci numbers as a test-case |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
221 |
val fib_test = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
List(Read("n"), // read n; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
223 |
Assign("minus1",Num(0)), // minus1 := 0; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
Assign("minus2",Num(1)), // minus2 := 1; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
225 |
Assign("temp",Num(0)), // temp := 0; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
226 |
While(Bop("<",Num(0),Var("n")), // while n > 0 do { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
227 |
List(Assign("temp",Var("minus2")), // temp := minus2; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
Assign("minus2",Aop("+",Var("minus1"),Var("minus2"))), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
// minus2 := minus1 + minus2; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
Assign("minus1",Var("temp")), // minus1 := temp; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
Assign("n",Aop("-",Var("n"),Num(1))))), // n := n - 1 }; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
232 |
Write("minus1")) // write minus1 |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
233 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
234 |
// prints out the JVM-assembly program |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
235 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
236 |
// println(compile(fib_test, "fib")) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
// can be assembled with |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
// |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
// java -jar jvm/jasmin-2.4/jasmin.jar fib.j |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
// |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
// and started with |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
// |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
244 |
// java fib/fib |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
245 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
246 |
import scala.util._ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
import scala.sys.process._ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
import scala.io |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
249 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
250 |
def compile_tofile(bl: Block, class_name: String) = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
251 |
val output = compile(bl, class_name) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
val fw = new java.io.FileWriter(class_name + ".j") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
fw.write(output) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
254 |
fw.close() |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
def compile_all(bl: Block, class_name: String) : Unit = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
compile_tofile(bl, class_name) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
println("compiled ") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
val test = ("python Krakatau/assemble.py " + class_name + ".j").!! |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
println("assembled ") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
263 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
def time_needed[T](i: Int, code: => T) = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
265 |
val start = System.nanoTime() |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
266 |
for (j <- 1 to i) code |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
267 |
val end = System.nanoTime() |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
(end - start)/(i * 1.0e9) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
272 |
def compile_run(bl: Block, class_name: String) : Unit = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
println("Start compilation") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
274 |
compile_all(bl, class_name) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
275 |
println("Time: " + time_needed(1, ("java " + class_name).!)) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
276 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
277 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
278 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
279 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
280 |
val arr_test = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
281 |
List(Array("a", 10), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
282 |
Array("b", 2), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
283 |
AssignA("a", Num(0), Num(10)), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
284 |
Assign("x", Ref("a", Num(0))), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
285 |
Write("x"), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
286 |
AssignA("b", Num(1), Num(5)), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
287 |
Assign("x", Ref("b", Num(1))), |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
288 |
Write("x")) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
289 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
290 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
291 |
//compile_run(arr_test, "a") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
292 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
293 |
//==================== |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
294 |
// Parser Combinators |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
//==================== |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
296 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
297 |
import scala.language.implicitConversions |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
298 |
import scala.language.reflectiveCalls |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
299 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
300 |
type IsSeq[A] = A => Seq[_] |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
301 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
302 |
abstract class Parser[I : IsSeq, T] { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
303 |
def parse(ts: I): Set[(T, I)] |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
304 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
305 |
def parse_all(ts: I) : Set[T] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
306 |
for ((head, tail) <- parse(ts); if (tail.isEmpty)) yield head |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
307 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
308 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
309 |
class SeqParser[I : IsSeq, T, S](p: => Parser[I, T], q: => Parser[I, S]) extends Parser[I, (T, S)] { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
310 |
def parse(sb: I) = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
311 |
for ((head1, tail1) <- p.parse(sb); |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
312 |
(head2, tail2) <- q.parse(tail1)) yield ((head1, head2), tail2) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
313 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
314 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
315 |
class AltParser[I : IsSeq, T](p: => Parser[I, T], q: => Parser[I, T]) extends Parser[I, T] { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
316 |
def parse(sb: I) = p.parse(sb) ++ q.parse(sb) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
317 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
318 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
319 |
class FunParser[I : IsSeq, T, S](p: => Parser[I, T], f: T => S) extends Parser[I, S] { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
320 |
def parse(sb: I) = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
321 |
for ((head, tail) <- p.parse(sb)) yield (f(head), tail) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
322 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
323 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
324 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
325 |
import scala.util.matching.Regex |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
326 |
case class RegexParser(reg: Regex) extends Parser[String, String] { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
327 |
def parse(sb: String) = reg.findPrefixMatchOf(sb) match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
328 |
case None => Set() |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
329 |
case Some(m) => Set((m.matched, m.after.toString)) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
330 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
331 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
332 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
333 |
def StringParser(s: String) = RegexParser(Regex.quote(s).r) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
334 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
335 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
336 |
implicit def string2parser(s : String) = StringParser(s) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
337 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
338 |
implicit def ParserOps[I : IsSeq, T](p: Parser[I, T]) = new { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
339 |
def | (q : => Parser[I, T]) = new AltParser[I, T](p, q) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
340 |
def ==>[S] (f: => T => S) = new FunParser[I, T, S](p, f) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
341 |
def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
342 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
343 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
344 |
implicit def StringOps(s: String) = new { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
345 |
def | (q : => Parser[String, String]) = new AltParser[String, String](s, q) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
346 |
def | (r: String) = new AltParser[String, String](s, r) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
347 |
def ==>[S] (f: => String => S) = new FunParser[String, String, S](s, f) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
348 |
def ~[S](q : => Parser[String, S]) = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
349 |
new SeqParser[String, String, S](s, q) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
350 |
def ~ (r: String) = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
351 |
new SeqParser[String, String, String](s, r) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
352 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
353 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
354 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
355 |
val NumParser = RegexParser("[0-9]+".r) ==> (s => s.toInt : Int) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
356 |
val IdParser = RegexParser("[a-z][a-z,0-9]*".r) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
357 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
358 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
359 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
360 |
// Grammar Rules |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
361 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
362 |
lazy val AExp: Parser[String, AExp] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
363 |
(Te ~ "+" ~ AExp) ==> { case ((x, _), z) => Aop("+", x, z):AExp } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
364 |
(Te ~ "-" ~ AExp) ==> { case ((x, _), z) => Aop("-", x, z):AExp } | Te |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
365 |
lazy val Te: Parser[String, AExp] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
366 |
(Fa ~ "*" ~ Te) ==> { case ((x, _), z) => Aop("*", x, z):AExp } | Fa |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
367 |
lazy val Fa: Parser[String, AExp] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
368 |
("(" ~ AExp ~ ")") ==> { case ((_, y), _) => y } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
369 |
(IdParser ~ "[" ~ AExp ~ "]") ==> { case (((x, _), y), _) => Ref(x, y) } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
370 |
IdParser ==> Var | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
371 |
NumParser ==> Num |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
372 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
373 |
// boolean expressions |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
374 |
lazy val BExp: Parser[String, BExp] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
375 |
(AExp ~ "=" ~ AExp) ==> { case ((x, y), z) => Bop("=", x, z):BExp } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
376 |
(AExp ~ "!=" ~ AExp) ==> { case ((x, y), z) => Bop("!=", x, z):BExp } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
377 |
(AExp ~ "<" ~ AExp) ==> { case ((x, y), z) => Bop("<", x, z):BExp } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
378 |
(AExp ~ ">" ~ AExp) ==> { case ((x, y), z) => Bop("<", z, x):BExp } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
379 |
("true" ==> ((_) => True:BExp )) | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
380 |
("false" ==> ((_) => False:BExp )) | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
381 |
("(" ~ BExp ~ ")") ==> { case ((x, y), z) => y} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
382 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
383 |
lazy val Stmt: Parser[String, Stmt] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
384 |
("skip" ==> (_ => Skip: Stmt)) | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
385 |
(IdParser ~ ":=" ~ AExp) ==> { case ((x, y), z) => Assign(x, z): Stmt } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
386 |
(IdParser ~ "[" ~ AExp ~ "]" ~ ":=" ~ AExp) ==> { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
387 |
case (((((x, y), z), v), w), u) => AssignA(x, z, u): Stmt } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
388 |
("if" ~ BExp ~ "then" ~ Block ~ "else" ~ Block) ==> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
389 |
{ case (((((x,y),z),u),v),w) => If(y, u, w): Stmt } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
390 |
("while" ~ BExp ~ "do" ~ Block) ==> { case (((x, y), z), w) => While(y, w) } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
391 |
("new" ~ IdParser ~ "[" ~ NumParser ~ "]") ==> { case ((((x, y), z), u), v) => Array(y, u) } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
392 |
("write" ~ IdParser) ==> { case (_, y) => Write(y) } |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
393 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
394 |
lazy val Stmts: Parser[String, Block] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
395 |
(Stmt ~ ";" ~ Stmts) ==> { case ((x, y), z) => x :: z : Block } | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
396 |
(Stmt ==> ((s) => List(s) : Block)) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
397 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
398 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
399 |
lazy val Block: Parser[String, Block] = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
400 |
("{" ~ Stmts ~ "}") ==> { case ((x, y), z) => y} | |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
401 |
(Stmt ==> (s => List(s))) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
402 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
403 |
//Stmts.parse_all("x2:=5+a") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
404 |
//Stmts.parse_all("x2:=5+a[3+a]") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
405 |
//Stmts.parse_all("a[x2+3]:=5+a[3+a]") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
406 |
//Block.parse_all("{x:=5;y:=8}") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
407 |
//Block.parse_all("if(false)then{x:=5}else{x:=10}") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
408 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
409 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
410 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
411 |
val fib = """ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
412 |
n := 10; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
413 |
minus1 := 0; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
414 |
minus2 := 1; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
415 |
temp:=0; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
416 |
while (n > 0) do { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
417 |
temp := minus2; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
418 |
minus2 := minus1 + minus2; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
419 |
minus1 := temp; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
420 |
n := n - 1}; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
421 |
result := minus2; |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
422 |
write result |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
423 |
""".replaceAll("\\s+", "") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
424 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
425 |
val fib_prog = Stmts.parse_all(fib).toList |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
426 |
//compile_run(fib_prog.head, "fib") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
427 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
428 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
429 |
// BF |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
430 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
431 |
// simple instructions |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
432 |
def instr(c: Char) : String = c match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
433 |
case '>' => "ptr := ptr + 1;" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
434 |
case '<' => "ptr := ptr - 1;" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
435 |
case '+' => "field[ptr] := field[ptr] + 1;" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
436 |
case '-' => "field[ptr] := field[ptr] - 1;" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
437 |
case '.' => "x := field[ptr]; write x;" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
438 |
//case ',' => "XXX" // "ptr = getchar();\n" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
439 |
case '[' => "while (field[ptr] != 0) do {" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
440 |
case ']' => "skip};" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
441 |
case _ => "" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
442 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
443 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
444 |
def instrs(prog: String) : String = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
445 |
prog.toList.map(instr).mkString |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
446 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
447 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
448 |
def splice(cs: List[Char], acc: List[(Char, Int)]) : List[(Char, Int)] = (cs, acc) match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
449 |
case (Nil, acc) => acc |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
450 |
case (c :: cs, Nil) => splice(cs, List((c, 1))) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
451 |
case (c :: cs, (d, n) :: acc) => |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
452 |
if (c == d) splice(cs, (c, n + 1) :: acc) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
453 |
else splice(cs, (c, 1) :: (d, n) :: acc) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
454 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
455 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
456 |
def spl(s: String) = splice(s.toList, Nil).reverse |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
457 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
458 |
def instr2(c: Char, n: Int) : String = c match { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
459 |
case '>' => "ptr := ptr + " + n.toString + ";" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
460 |
case '<' => "ptr := ptr - " + n.toString + ";" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
461 |
case '0' => "field[ptr] := 0;" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
462 |
case '+' => "field[ptr] := field[ptr] + " + n.toString + ";" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
463 |
case '-' => "field[ptr] := field[ptr] - " + n.toString + ";" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
464 |
case '.' => "x := field[ptr]; write x;" //* n |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
465 |
//case ',' => "*ptr = getchar();\n" * n |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
466 |
case '[' => "while (field[ptr] != 0) do {" * n |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
467 |
case ']' => "skip};" * n |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
468 |
case _ => "" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
469 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
470 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
471 |
def instrs2(prog: String) : String = |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
472 |
spl(prog.replaceAll("""\[-\]""", "0")).map{ case (c, n) => instr2(c, n) }.mkString |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
473 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
474 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
475 |
def bf_str(prog: String) : String = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
476 |
"\n" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
477 |
//"new field[30000];\n" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
478 |
"ptr := 15000;" ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
479 |
instrs2(prog) ++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
480 |
"skip" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
481 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
482 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
483 |
def bf_run(prog: String, name: String) = { |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
484 |
println("BF processing start") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
485 |
val bf_string = bf_str(prog).replaceAll("\\s", "") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
486 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
487 |
println(s"BF parsing start (string length ${bf_string.length})") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
488 |
val bf_prog = Stmts.parse_all(bf_string).toList.head |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
489 |
println(s"BF Compile start ${bf_string.toList.length} characters") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
490 |
compile_run(Array("field", 30000) :: bf_prog, name) |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
491 |
} |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
492 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
493 |
// a benchmark program (counts down from 'Z' to 'A') |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
494 |
val bf0 = """>++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
495 |
[>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
496 |
++++++++[>++++++++++[>++++++++++[>++++++++++[>+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
497 |
+++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.""" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
498 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
499 |
bf_run(bf0, "bench") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
500 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
501 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
502 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
503 |
val bf1 = """++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
504 |
->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
505 |
]>.>+[>>]>+]""" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
506 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
507 |
bf_run(bf1, "sier") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
508 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
509 |
bf_run("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
510 |
..+++.>>.<-.<.+++.------.--------.>>+.>++.""", "hello") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
511 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
512 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
513 |
val bf2 = """+++++++++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
514 |
>+>>>>++++++++++++++++++++++++++++++++++++++++++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
515 |
>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
516 |
+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
517 |
<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
518 |
-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]] |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
519 |
>[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
520 |
+++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
521 |
++++++++++++++++++++++++++++++++++++++++++++.[-]<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
522 |
<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
523 |
[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]""" |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
524 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
525 |
bf_run(bf2, "fibs") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
526 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
527 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
528 |
|
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
529 |
bf_run(""" A mandelbrot set fractal viewer in brainf*** written by Erik Bosman |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
530 |
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
531 |
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
532 |
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
533 |
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
534 |
>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
535 |
>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
536 |
>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
537 |
[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
538 |
<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
539 |
>>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
540 |
>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->>[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
541 |
-<<+>>]<<[->>+>>+<<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>>>>>]<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
542 |
<<[>[->>>>>>>>>+<<<<<<<<<]<<<<<<<<<<]>[->>>>>>>>>+<<<<<<<<<]<+>>>>>>>>]<<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
543 |
[>[-]<->>>>[-<<<<+>[<->-<<<<<<+>>>>>>]<[->+<]>>>>]<<<[->>>+<<<]<+<<<<<<<<<]>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
544 |
>>>>[>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>>[-<<<<<+>>>>>]<<<<<[->>>>>+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
545 |
<<<<<<[->>>[-<<<+>>>]<<<[->>>+>+<<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
546 |
>>>>>>>]<<<<<<<<<[>>[->>>>>>>>>+<<<<<<<<<]<<<<<<<<<<<]>>[->>>>>>>>>+<<<<<<<<<]<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
547 |
+>>>>>>>>]<<<<<<<<<[>[-]<->>>>[-<<<<+>[<->-<<<<<<+>>>>>>]<[->+<]>>>>]<<<[->>>+<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
548 |
<]<+<<<<<<<<<]>>>>>>>>>[>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
549 |
>>>>>>>>>>>>>>>>>>>>>>>]>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>+++++++++++++++[[>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
550 |
>>>>>]<<<<<<<<<-<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+>>>>>>>>>>>>>>>>>>>>>+<<<[<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
551 |
<<<]>>>>>>>>>[>>>[-<<<->>>]+<<<[->>>->[-<<<<+>>>>]<<<<[->>>>+<<<<<<<<<<<<<[<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
552 |
<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>[-<<<<->>>>]+<<<<[->>>>-<[-<<<+>>>]<<<[-> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
553 |
>>+<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
554 |
<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]<<<<<<<[->+>>>-<<<<]>>>>>>>>>+++++++++++++++++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
555 |
+++++++>>[-<<<<+>>>>]<<<<[->>>>+<<[-]<<]>>[<<<<<<<+<[-<+>>>>+<<[-]]>[-<<[->+>>>- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
556 |
<<<<]>>>]>>>>>>>>>>>>>[>>[-]>[-]>[-]>>>>>]<<<<<<<<<[<<<<<<<<<]>>>[-]>>>>>>[>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
557 |
[-<<<<+>>>>]<<<<[->>>>+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>[-<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
558 |
<+>>>>>>>>>]>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+>[- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
559 |
]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[>+>>>>>>>>]<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
560 |
<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>>[-<<<<<+>>>>>]<<<<<[->>>>>+<<<<<<[->>[-<<+>>]< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
561 |
<[->>+>+<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>>>>>]<<<<<<<<<[>[->>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
562 |
>>>>>+<<<<<<<<<]<<<<<<<<<<]>[->>>>>>>>>+<<<<<<<<<]<+>>>>>>>>]<<<<<<<<<[>[-]<->>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
563 |
[-<<<+>[<->-<<<<<<<+>>>>>>>]<[->+<]>>>]<<[->>+<<]<+<<<<<<<<<]>>>>>>>>>[>>>>>>[-< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
564 |
<<<<+>>>>>]<<<<<[->>>>>+<<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>+>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
565 |
]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>>[-<<<<<+>>>>>]<<<<<[->>>>>+<<<<<<[->>[-<<+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
566 |
>>]<<[->>+>>+<<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>>>>>]<<<<<<<<<[> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
567 |
[->>>>>>>>>+<<<<<<<<<]<<<<<<<<<<]>[->>>>>>>>>+<<<<<<<<<]<+>>>>>>>>]<<<<<<<<<[>[- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
568 |
]<->>>>[-<<<<+>[<->-<<<<<<+>>>>>>]<[->+<]>>>>]<<<[->>>+<<<]<+<<<<<<<<<]>>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
569 |
[>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
570 |
]>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
571 |
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>++++++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
572 |
+++++++[[>>>>>>>>>]<<<<<<<<<-<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-<<<<<<<+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
573 |
>>>>>>>]<<<<<<<[->>>>>>>+<<<<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
574 |
-]>>>]<<<<<<<<<[<<<<<<<<<]>>>>+>[-<-<<<<+>>>>>]>[-<<<<<<[->>>>>+<++<<<<]>>>>>[-< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
575 |
<<<<+>>>>>]<->+>]<[->+<]<<<<<[->>>>>+<<<<<]>>>>>>[-]<<<<<<+>>>>[-<<<<->>>>]+<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
576 |
[->>>>->>>>>[>>[-<<->>]+<<[->>->[-<<<+>>>]<<<[->>>+<<<<<<<<<<<<[<<<<<<<<<]>>>[-] |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
577 |
+>>>>>>[>>>>>>>>>]>+<]]+>>>[-<<<->>>]+<<<[->>>-<[-<<+>>]<<[->>+<<<<<<<<<<<[<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
578 |
<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
579 |
[<<<<<<<<<]>>>>[-<<<<+>>>>]<<<<[->>>>+>>>>>[>+>>[-<<->>]<<[->>+<<]>>>>>>>>]<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
580 |
<<<+<[>[->>>>>+<<<<[->>>>-<<<<<<<<<<<<<<+>>>>>>>>>>>[->>>+<<<]<]>[->>>-<<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
581 |
<<<<<+>>>>>>>>>>>]<<]>[->>>>+<<<[->>>-<<<<<<<<<<<<<<+>>>>>>>>>>>]<]>[->>>+<<<]<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
582 |
<<<<<<<<<<]>>>>[-]<<<<]>>>[-<<<+>>>]<<<[->>>+>>>>>>[>+>[-<->]<[->+<]>>>>>>>>]<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
583 |
<<<<<+<[>[->>>>>+<<<[->>>-<<<<<<<<<<<<<<+>>>>>>>>>>[->>>>+<<<<]>]<[->>>>-<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
584 |
<<<<<<<+>>>>>>>>>>]<]>>[->>>+<<<<[->>>>-<<<<<<<<<<<<<<+>>>>>>>>>>]>]<[->>>>+<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
585 |
]<<<<<<<<<<<]>>>>>>+<<<<<<]]>>>>[-<<<<+>>>>]<<<<[->>>>+>>>>>[>>>>>>>>>]<<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
586 |
[>[->>>>>+<<<<[->>>>-<<<<<<<<<<<<<<+>>>>>>>>>>>[->>>+<<<]<]>[->>>-<<<<<<<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
587 |
+>>>>>>>>>>>]<<]>[->>>>+<<<[->>>-<<<<<<<<<<<<<<+>>>>>>>>>>>]<]>[->>>+<<<]<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
588 |
<<<<<]]>[-]>>[-]>[-]>>>>>[>>[-]>[-]>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>[-< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
589 |
<<<+>>>>]<<<<[->>>>+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>+++++++++++++++[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
590 |
[>>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
591 |
[>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
592 |
[-<<+>>]<<[->>+>+<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>>>>>]<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
593 |
<[>[->>>>>>>>>+<<<<<<<<<]<<<<<<<<<<]>[->>>>>>>>>+<<<<<<<<<]<+>>>>>>>>]<<<<<<<<<[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
594 |
>[-]<->>>[-<<<+>[<->-<<<<<<<+>>>>>>>]<[->+<]>>>]<<[->>+<<]<+<<<<<<<<<]>>>>>>>>>[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
595 |
>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
596 |
>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>[-]>>>>+++++++++++++++[[>>>>>>>>>]<<<<<<<<<-<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
597 |
<<<<[<<<<<<<<<]>>>>>>>>>-]+[>>>[-<<<->>>]+<<<[->>>->[-<<<<+>>>>]<<<<[->>>>+<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
598 |
<<<<<<<<[<<<<<<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>[-<<<<->>>>]+<<<<[->>>>-<[- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
599 |
<<<+>>>]<<<[->>>+<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
600 |
>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>[-<<<+>>>]<<<[->>>+>>>>>>[>+>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
601 |
[-<<<->>>]<<<[->>>+<<<]>>>>>>>>]<<<<<<<<+<[>[->+>[-<-<<<<<<<<<<+>>>>>>>>>>>>[-<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
602 |
+>>]<]>[-<<-<<<<<<<<<<+>>>>>>>>>>>>]<<<]>>[-<+>>[-<<-<<<<<<<<<<+>>>>>>>>>>>>]<]> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
603 |
[-<<+>>]<<<<<<<<<<<<<]]>>>>[-<<<<+>>>>]<<<<[->>>>+>>>>>[>+>>[-<<->>]<<[->>+<<]>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
604 |
>>>>>>]<<<<<<<<+<[>[->+>>[-<<-<<<<<<<<<<+>>>>>>>>>>>[-<+>]>]<[-<-<<<<<<<<<<+>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
605 |
>>>>>>>]<<]>>>[-<<+>[-<-<<<<<<<<<<+>>>>>>>>>>>]>]<[-<+>]<<<<<<<<<<<<]>>>>>+<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
606 |
]>>>>>>>>>[>>>[-]>[-]>[-]>>>>]<<<<<<<<<[<<<<<<<<<]>>>[-]>[-]>>>>>[>>>>>>>[-<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
607 |
<+>>>>>>]<<<<<<[->>>>>>+<<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>+>[-<-<<<<+>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
608 |
>]>>[-<<<<<<<[->>>>>+<++<<<<]>>>>>[-<<<<<+>>>>>]<->+>>]<<[->>+<<]<<<<<[->>>>>+<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
609 |
<<<]+>>>>[-<<<<->>>>]+<<<<[->>>>->>>>>[>>>[-<<<->>>]+<<<[->>>-<[-<<+>>]<<[->>+<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
610 |
<<<<<<<<<[<<<<<<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>[-<<->>]+<<[->>->[-<<<+>>>]< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
611 |
<<[->>>+<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
612 |
<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>[-<<<+>>>]<<<[->>>+>>>>>>[>+>[-<->]<[->+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
613 |
<]>>>>>>>>]<<<<<<<<+<[>[->>>>+<<[->>-<<<<<<<<<<<<<+>>>>>>>>>>[->>>+<<<]>]<[->>>- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
614 |
<<<<<<<<<<<<<+>>>>>>>>>>]<]>>[->>+<<<[->>>-<<<<<<<<<<<<<+>>>>>>>>>>]>]<[->>>+<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
615 |
]<<<<<<<<<<<]>>>>>[-]>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]]>>>>[-<<<<+> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
616 |
>>>]<<<<[->>>>+>>>>>[>+>>[-<<->>]<<[->>+<<]>>>>>>>>]<<<<<<<<+<[>[->>>>+<<<[->>>- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
617 |
<<<<<<<<<<<<<+>>>>>>>>>>>[->>+<<]<]>[->>-<<<<<<<<<<<<<+>>>>>>>>>>>]<<]>[->>>+<<[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
618 |
->>-<<<<<<<<<<<<<+>>>>>>>>>>>]<]>[->>+<<]<<<<<<<<<<<<]]>>>>[-]<<<<]>>>>[-<<<<+>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
619 |
>>]<<<<[->>>>+>[-]>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>[>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
620 |
>>>]<<<<<<<<<[>[->>>>+<<<[->>>-<<<<<<<<<<<<<+>>>>>>>>>>>[->>+<<]<]>[->>-<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
621 |
<<<<<+>>>>>>>>>>>]<<]>[->>>+<<[->>-<<<<<<<<<<<<<+>>>>>>>>>>>]<]>[->>+<<]<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
622 |
<<<<]]>>>>>>>>>[>>[-]>[-]>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>[-]>[-]>>>>>[>>>>>[-<<<<+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
623 |
>>>>]<<<<[->>>>+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<+>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
624 |
]<<<<<[->>>>>+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>+++++++++++++++[[>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
625 |
>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[>+>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
626 |
>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->>[-<<+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
627 |
>>]<<[->>+>>+<<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>>>>>]<<<<<<<<<[> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
628 |
[->>>>>>>>>+<<<<<<<<<]<<<<<<<<<<]>[->>>>>>>>>+<<<<<<<<<]<+>>>>>>>>]<<<<<<<<<[>[- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
629 |
]<->>>>[-<<<<+>[<->-<<<<<<+>>>>>>]<[->+<]>>>>]<<<[->>>+<<<]<+<<<<<<<<<]>>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
630 |
[>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>>[-<<<<<+>>>>>]<<<<<[->>>>>+<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
631 |
<<[->>>[-<<<+>>>]<<<[->>>+>+<<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
632 |
>>>]<<<<<<<<<[>>[->>>>>>>>>+<<<<<<<<<]<<<<<<<<<<<]>>[->>>>>>>>>+<<<<<<<<<]<<+>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
633 |
>>>>>]<<<<<<<<<[>[-]<->>>>[-<<<<+>[<->-<<<<<<+>>>>>>]<[->+<]>>>>]<<<[->>>+<<<]<+ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
634 |
<<<<<<<<<]>>>>>>>>>[>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
635 |
>>>>>>>>>>>>>>>>>>>]>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>+++++++++++++++[[>>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
636 |
>]<<<<<<<<<-<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+>>>>>>>>>>>>>>>>>>>>>+<<<[<<<<<<<<<] |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
637 |
>>>>>>>>>[>>>[-<<<->>>]+<<<[->>>->[-<<<<+>>>>]<<<<[->>>>+<<<<<<<<<<<<<[<<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
638 |
]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>[-<<<<->>>>]+<<<<[->>>>-<[-<<<+>>>]<<<[->>>+< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
639 |
<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
640 |
>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>->>[-<<<<+>>>>]<<<<[->>>>+<<[-]<<]>>]<<+>>>>[-<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
641 |
->>>>]+<<<<[->>>>-<<<<<<.>>]>>>>[-<<<<<<<.>>>>>>>]<<<[-]>[-]>[-]>[-]>[-]>[-]>>>[ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
642 |
>[-]>[-]>[-]>[-]>[-]>[-]>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>[-]>>>>]<<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
643 |
[<<<<<<<<<]>+++++++++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>+>>>>>>>>>+<<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
644 |
<<<<<<[<<<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+[-]>>[>>>>>>>>>]<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
645 |
<<<<[>>>>>>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<[<<<<<<<<<]>>>>>>>[-]+>>>]<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
646 |
<<<<<<]]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+>>[>+>>>>[-<<<<->>>>]<<<<[->>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
647 |
>+<<<<]>>>>>>>>]<<+<<<<<<<[>>>>>[->>+<<]<<<<<<<<<<<<<<]>>>>>>>>>[>>>>>>>>>]<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
648 |
<<<<[>[-]<->>>>>>>[-<<<<<<<+>[<->-<<<+>>>]<[->+<]>>>>>>>]<<<<<<[->>>>>>+<<<<<<]< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
649 |
+<<<<<<<<<]>>>>>>>-<<<<[-]+<<<]+>>>>>>>[-<<<<<<<->>>>>>>]+<<<<<<<[->>>>>>>->>[>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
650 |
>>>[->>+<<]>>>>]<<<<<<<<<[>[-]<->>>>>>>[-<<<<<<<+>[<->-<<<+>>>]<[->+<]>>>>>>>]<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
651 |
<<<<[->>>>>>+<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>+<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
652 |
<<[<<<<<<<<<]>>>>>>>>>[>>>>>[-<<<<<->>>>>]+<<<<<[->>>>>->>[-<<<<<<<+>>>>>>>]<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
653 |
<<<[->>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>[-< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
654 |
<<<<<<->>>>>>>]+<<<<<<<[->>>>>>>-<<[-<<<<<+>>>>>]<<<<<[->>>>>+<<<<<<<<<<<<<<[<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
655 |
<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
656 |
<<[<<<<<<<<<]>>>>[-]<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>-<<<<<[<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
657 |
<<]]>>>]<<<<.>>>>>>>>>>[>>>>>>[-]>>>]<<<<<<<<<[<<<<<<<<<]>++++++++++[-[->>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
658 |
>+<<<<<<<<<]>>>>>>>>>]>>>>>+>>>>>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
659 |
<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+[-]>[>>>>>>>>>]<<<<<<<<<[>>>>>>>>[-<<<<<<<+>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
660 |
>]<<<<<<<[->>>>>>>+<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+>>]<<<<<<<<<<]]>>>>>>>>[-<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
661 |
<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+>[>+>>>>>[-<<<<<->>>>>]<<<<<[->>>>>+<<<<<]>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
662 |
>>]<+<<<<<<<<[>>>>>>[->>+<<]<<<<<<<<<<<<<<<]>>>>>>>>>[>>>>>>>>>]<<<<<<<<<[>[-]<- |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
663 |
>>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<<<<<<[->>>>>>>+<<<<<<<]<+<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
664 |
<<<]>>>>>>>>-<<<<<[-]+<<<]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>->[>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
665 |
>>>[->>+<<]>>>]<<<<<<<<<[>[-]<->>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
666 |
<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
667 |
+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
668 |
<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
669 |
<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
670 |
-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>> |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
671 |
>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++ |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
672 |
+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<< |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
673 |
<<<<<]]>>>]""", "mand") |
3a5a7908517f
added krakatau version and made the mandel program work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
674 |