Commit | Line | Data |
---|---|---|
32d0a1cf | 1 | import Compat; |
6c4c14bd JM |
2 | import types.Types.MalType; |
3 | import reader.*; | |
4 | import printer.*; | |
5 | ||
6 | class Step1_read_print { | |
7 | // READ | |
8 | static function READ(str:String):MalType { | |
9 | return Reader.read_str(str); | |
10 | } | |
11 | ||
12 | // EVAL | |
13 | static function EVAL(ast:MalType, env:String) { | |
14 | return ast; | |
15 | } | |
16 | ||
17 | ||
18 | static function PRINT(exp:MalType):String { | |
19 | return Printer.pr_str(exp, true); | |
20 | } | |
21 | ||
22 | // repl | |
23 | static function rep(line:String) { | |
24 | return PRINT(EVAL(READ(line), "")); | |
25 | } | |
26 | ||
27 | public static function main() { | |
6c4c14bd JM |
28 | while (true) { |
29 | try { | |
32d0a1cf | 30 | var line = Compat.readline("user> "); |
6c4c14bd | 31 | if (line == "") { continue; } |
32d0a1cf | 32 | Compat.println(rep(line)); |
6c4c14bd JM |
33 | } catch (exc:BlankLine) { |
34 | continue; | |
35 | } catch (exc:haxe.io.Eof) { | |
32d0a1cf | 36 | Compat.exit(0); |
6c4c14bd | 37 | } catch (exc:Dynamic) { |
dd7a4f55 | 38 | Compat.println("Error: " + exc); |
6c4c14bd JM |
39 | } |
40 | } | |
41 | } | |
42 | } |