Commit | Line | Data |
---|---|---|
891c3f3b JM |
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 | ||
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 | |
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 |