1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 02:27:10 +03:00
mal/haxe/Step1_read_print.hx
Joel Martin dd7a4f55f3 Test uncaught throw, catchless try* . Fix 46 impls.
Fixes made to: ada, c, chuck, clojure, coffee, common-lisp, cpp,
crystal, d, dart, elm, erlang, es6, factor, fsharp, gnu-smalltalk,
groovy, guile, haxe, hy, js, livescript, matlab, miniMAL, nasm, nim,
objc, objpascal, ocaml, perl, perl6, php, plsql, ps, python, r,
rpython, ruby, scheme, swift3, tcl, ts, vb, vimscript, wasm, yorick.

Catchless try* test is an optional test. Not all implementations
support catchless try* but a number were fixed so they at least don't
crash on catchless try*.
2018-12-12 14:18:26 -06:00

43 lines
983 B
Haxe

import Compat;
import types.Types.MalType;
import reader.*;
import printer.*;
class Step1_read_print {
// READ
static function READ(str:String):MalType {
return Reader.read_str(str);
}
// EVAL
static function EVAL(ast:MalType, env:String) {
return ast;
}
// PRINT
static function PRINT(exp:MalType):String {
return Printer.pr_str(exp, true);
}
// repl
static function rep(line:String) {
return PRINT(EVAL(READ(line), ""));
}
public static function main() {
while (true) {
try {
var line = Compat.readline("user> ");
if (line == "") { continue; }
Compat.println(rep(line));
} catch (exc:BlankLine) {
continue;
} catch (exc:haxe.io.Eof) {
Compat.exit(0);
} catch (exc:Dynamic) {
Compat.println("Error: " + exc);
}
}
}
}