Test uncaught throw, catchless try* . Fix 46 impls.
[jackhill/mal.git] / coffee / step1_read_print.coffee
1 readline = require "./node_readline.coffee"
2 reader = require "./reader.coffee"
3 printer = require "./printer.coffee"
4
5 # read
6 READ = (str) -> reader.read_str str
7
8 # eval
9 EVAL = (ast, env) -> ast
10
11 # print
12 PRINT = (exp) -> printer._pr_str exp, true
13
14 # repl
15 rep = (str) -> PRINT(EVAL(READ(str), {}))
16
17 # repl loop
18 while (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
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? then console.log exc.stack
27 else console.log exc
28
29 # vim: ts=2:sw=2