Merge pull request #380 from bjh21/bjh21-bbc-basic
[jackhill/mal.git] / io / step1_read_print.io
1 MalTypes
2 MalReader
3
4 READ := method(str, MalReader read_str(str))
5
6 EVAL := method(ast, env, ast)
7
8 PRINT := method(exp, exp malPrint(true))
9
10 RE := method(str, EVAL(READ(str), nil))
11
12 REP := method(str, PRINT(RE(str)))
13
14 loop(
15 line := MalReadline readLine("user> ")
16 if(line isNil, break)
17 if(line isEmpty, continue)
18 e := try(REP(line) println)
19 e catch(Exception,
20 ("Error: " .. (e error)) println
21 )
22 )