// @import readline.ck // @import types/boxed/*.ck // @import types/MalObject.ck // @import types/mal/MalAtom.ck // @import types/mal/MalError.ck // @import types/mal/MalNil.ck // @import types/mal/MalFalse.ck // @import types/mal/MalTrue.ck // @import types/mal/MalInt.ck // @import types/mal/MalString.ck // @import types/mal/MalSymbol.ck // @import types/mal/MalKeyword.ck // @import types/mal/MalList.ck // @import types/mal/MalVector.ck // @import types/mal/MalHashMap.ck // @import util/*.ck // @import reader.ck // @import printer.ck fun MalObject READ(string input) { return Reader.read_str(input); } fun MalObject EVAL(MalObject m) { return m; } fun string PRINT(MalObject m) { return Printer.pr_str(m, true); } fun string errorMessage(MalObject m) { (m$MalError).value() @=> MalObject value; if( value.type == "string" ) { return Printer.pr_str(value, false); } else { return "exception: " + Printer.pr_str(value, true); } } fun string rep(string input) { READ(input) @=> MalObject m; if( m.type == "error" ) { return errorMessage(m); } else { return PRINT(EVAL(m)); } } fun void main() { int done; while( !done ) { Readline.readline("user> ") => string input; if( input != null ) { rep(input) => string output; if( output == "empty input" ) { // proceed immediately with prompt } else { Util.println(output); } } else { true => done; } } } main();