You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
649 B
39 lines
649 B
#! /usr/bin/env node
|
|
|
|
import readline from "readline";
|
|
import vm from "./vm.js";
|
|
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout,
|
|
prompt: 'λ '
|
|
});
|
|
|
|
rl.prompt();
|
|
|
|
var last;
|
|
|
|
rl.on('line', (line) => {
|
|
try {
|
|
if (line.trim().length == 0) {
|
|
rl.prompt();
|
|
}
|
|
else {
|
|
last = vm.evaluateString(line);
|
|
if (last == undefined) {
|
|
rl.prompt();
|
|
}
|
|
else {
|
|
console.log(last);
|
|
vm.env.bindings["it"] = last;
|
|
}
|
|
}
|
|
}
|
|
catch (e) {
|
|
console.log(e.errormessage);
|
|
}
|
|
rl.prompt();
|
|
}).on('close', () => {
|
|
console.log('Bye');
|
|
process.exit(0);
|
|
});
|
|
|