mirror of
https://github.com/kanaka/mal.git
synced 2024-09-21 02:27:10 +03:00
dd7a4f55f3
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*.
29 lines
665 B
JavaScript
29 lines
665 B
JavaScript
import rl from './node_readline.js'
|
|
const readline = rl.readline
|
|
import { BlankException, read_str } from './reader'
|
|
import { pr_str } from './printer'
|
|
|
|
// read
|
|
const READ = str => read_str(str)
|
|
|
|
// eval
|
|
const EVAL = (ast, env) => ast
|
|
|
|
// print
|
|
const PRINT = exp => pr_str(exp, true)
|
|
|
|
// repl
|
|
const REP = str => PRINT(EVAL(READ(str), {}))
|
|
|
|
while (true) {
|
|
let line = readline('user> ')
|
|
if (line == null) break
|
|
try {
|
|
if (line) { console.log(REP(line)) }
|
|
} catch (exc) {
|
|
if (exc instanceof BlankException) { continue }
|
|
if (exc instanceof Error) { console.warn(exc.stack) }
|
|
else { console.warn(`Error: ${exc}`) }
|
|
}
|
|
}
|