equal
deleted
inserted
replaced
3 // - includes a lexer and a parser |
3 // - includes a lexer and a parser |
4 // - performs tail-call optimisations |
4 // - performs tail-call optimisations |
5 // |
5 // |
6 // call with |
6 // call with |
7 // |
7 // |
8 // amm fun.sc main defs.fun |
8 // amm funt.sc main defs.fun |
9 // amm fun.sc main fact.fun |
9 // amm funt.sc main fact.fun |
10 // |
10 // |
11 // or |
11 // or |
12 // |
12 // |
13 // amm fun.sc run defs.fun |
13 // amm funt.sc run defs.fun |
14 // amm fun.sc run fact.fun |
14 // amm funt.sc run fact.fun |
15 // |
15 // |
16 // the first prints out the JVM instructions |
16 // the first prints out the JVM instructions |
17 // the second runs the generated class files |
17 // the second runs the generated class files |
18 |
18 |
19 |
19 |
64 x ++ "_" ++ counter.toString() |
64 x ++ "_" ++ counter.toString() |
65 } |
65 } |
66 |
66 |
67 // convenient string interpolations |
67 // convenient string interpolations |
68 // for instructions, labels and methods |
68 // for instructions, labels and methods |
69 import scala.language.implicitConversions |
69 extension (sc: StringContext) { |
70 import scala.language.reflectiveCalls |
70 def i(args: Any*): String = " " ++ sc.s(args:_*) ++ "\n" // instructions |
71 |
71 def l(args: Any*): String = sc.s(args:_*) ++ ":\n" // labels |
72 implicit def sring_inters(sc: StringContext) = new { |
72 def m(args: Any*): String = sc.s(args:_*) ++ "\n" // methods |
73 def i(args: Any*): String = " " ++ sc.s(args:_*) ++ "\n" |
|
74 def l(args: Any*): String = sc.s(args:_*) ++ ":\n" |
|
75 def m(args: Any*): String = sc.s(args:_*) ++ "\n" |
|
76 } |
73 } |
77 |
74 |
78 |
75 |
79 type Env = Map[String, Int] |
76 type Env = Map[String, Int] |
80 |
77 |