groovy: implement conj
[jackhill/mal.git] / coffee / step1_read_print.coffee
CommitLineData
891c3f3b
JM
1readline = require "./node_readline.coffee"
2reader = require "./reader.coffee"
3printer = require "./printer.coffee"
4
5# read
6READ = (str) -> reader.read_str str
7
8# eval
9EVAL = (ast, env) -> ast
10
11# print
12PRINT = (exp) -> printer._pr_str exp, true
13
14# repl
15rep = (str) -> PRINT(EVAL(READ(str), {}))
16
17# repl loop
18while (line = readline.readline("user> ")) != null
19 continue if line == ""
20 try
21 console.log rep line
22 catch exc
23 continue if exc instanceof reader.BlankException
4ed89670
JM
24 if exc.stack? and exc.stack.length > 2000
25 console.log exc.stack.slice(0,1000) + "\n ..." + exc.stack.slice(-1000)
26 else if exc.stack? console.log exc.stack
27 else console.log exc
891c3f3b
JM
28
29# vim: ts=2:sw=2