aboutsummaryrefslogtreecommitdiff
path: root/scala/step0_repl.scala
blob: 5ec94fe6c7b624bda62c64d57a3f063f37956963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
object step0_repl {
  def READ(str: String): String = {
    str
  }

  def EVAL(str: String, env: String): String = {
    str
  }

  def PRINT(str: String): String = {
    str
  }

  def REP(str: String): String = {
    PRINT(EVAL(READ(str), ""))
  }

  def main(args: Array[String]) {
    var line:String = null
    while ({line = readLine("user> "); line != null}) {
      try {
        println(REP(line))
      } catch {
        case e : Exception => {
          println("Error: " + e.getMessage)
          println("    " + e.getStackTrace.mkString("\n    "))
        }
      }
    }
  }
}

// vim: ts=2:sw=2