diff -r f5214da1976e -r 8067d0a8ba04 progs/fun-bare.scala --- a/progs/fun-bare.scala Sun Jul 28 21:10:39 2019 +0100 +++ b/progs/fun-bare.scala Tue Jul 30 20:19:40 2019 +0100 @@ -1,5 +1,5 @@ // A Small Compiler for a Simple Functional Language -// (it does not use a parser and lexer) +// (it does not include a parser and lexer) // Abstract syntax trees abstract class Exp @@ -70,17 +70,18 @@ x ++ "_" ++ counter.toString() } -// convenient string interpolations -// for instructions, labels and methods +// convenient string interpolations for +// generating instructions, labels etc import scala.language.implicitConversions import scala.language.reflectiveCalls implicit def sring_inters(sc: StringContext) = new { - def i(args: Any*): String = " " ++ sc.s(args:_*) ++ "\n" - def l(args: Any*): String = sc.s(args:_*) ++ ":\n" - def m(args: Any*): String = sc.s(args:_*) ++ "\n" + def i(args: Any*): String = " " ++ sc.s(args:_*) ++ "\n" + def l(args: Any*): String = sc.s(args:_*) ++ ":\n" + def m(args: Any*): String = sc.s(args:_*) ++ "\n" } +// variable / index environments type Env = Map[String, Int] // compile expressions