bbc-basic: Slight tweak to heap size.
[jackhill/mal.git] / haxe / Step1_read_print.hx
1 import Compat;
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 // PRINT
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() {
28 while (true) {
29 try {
30 var line = Compat.readline("user> ");
31 if (line == "") { continue; }
32 Compat.println(rep(line));
33 } catch (exc:BlankLine) {
34 continue;
35 } catch (exc:haxe.io.Eof) {
36 Compat.exit(0);
37 } catch (exc:Dynamic) {
38 Compat.println("Error: " + exc);
39 }
40 }
41 }
42 }