make REPL output optional with each call to `run`.
This commit is contained in:
parent
a3d013162c
commit
6fb482df27
10
src/repl.mjs
10
src/repl.mjs
|
@ -36,9 +36,13 @@ specials.set("!.env", _ => {
|
|||
|
||||
specials.set("!.clear", _ => console.clear());
|
||||
|
||||
specials.set("!.load combinators", _ => {
|
||||
combinators.forEach(c => run(c, false));
|
||||
});
|
||||
|
||||
|
||||
function run (line) {
|
||||
|
||||
function run (line, output = true) {
|
||||
if (specials.has(line)) {
|
||||
specials.get(line)();
|
||||
return;
|
||||
|
@ -48,12 +52,14 @@ function run (line) {
|
|||
const compiled = compile_line(env, parsed);
|
||||
|
||||
if (!compiled.valid) {
|
||||
print("invalid line!");
|
||||
if (output) print("invalid line!");
|
||||
return;
|
||||
}
|
||||
|
||||
env = compiled.env;
|
||||
|
||||
if (!output) return;
|
||||
|
||||
if (parsed.type === Line.Expression) {
|
||||
print(prettify(reduce(compiled.value)));
|
||||
|
||||
|
|
Loading…
Reference in New Issue