1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
mal/ts/step1_read_print.ts
2017-02-23 05:17:53 +09:00

39 lines
687 B
TypeScript

import { readline } from "./node_readline";
import { MalType } from "./types";
import { readStr } from "./reader";
import { prStr } from "./printer";
function read(v: string): MalType {
return readStr(v);
}
function evalAST(v: any): any {
// TODO
return v;
}
function print(v: MalType): string {
return prStr(v);
}
function rep(v: string): string {
return print(evalAST(read(v)));
}
while (true) {
const line = readline("user> ");
if (line == null) {
break;
}
if (line === "") {
continue;
}
try {
console.log(rep(line));
} catch (e) {
const err: Error = e;
console.error(err.message);
}
}