mirror of
https://github.com/kanaka/mal.git
synced 2024-09-20 01:57:09 +03:00
a05c086f05
- Use Vector class derived from Array - Use Array/Vector.from for initializing/cloning of Array/Vector - Remove most semi-colon line endings - More use of arrow functions - Use Object.assign to copy properties in _malfunc and function cloning. - Remove or inline a bunch of types.js functions that don't really need to be separate functions: _obj_type, _sequential_Q, _symbol, _symbol_Q, _vector, _vector_Q, _hash_map, _hash_map_Q - Simplify dependency list in Makefile - Remove some separate core.js functions by moving them into the core_ns declaration: _nth, keys, vals, with_meta. With node 7, babel is mostly just used for translating imports into CommonJS requires for node.
28 lines
640 B
JavaScript
28 lines
640 B
JavaScript
import { readline } from './node_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.stack) { console.log(exc.stack) }
|
|
else { console.log(`Error: ${exc}`) }
|
|
}
|
|
}
|