Created
April 17, 2017 01:15
-
-
Save markx/231c1d74197611840ebd77b73701fd1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require('readline'); | |
function READ(x) { | |
return x; | |
} | |
function EVAL(x) { | |
return x; | |
} | |
function PRINT(x) { | |
return x; | |
} | |
function rep(x) { | |
return PRINT(EVAL(READ(x))); | |
} | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
prompt: 'user> ' | |
}); | |
rl.prompt(); | |
rl.on('line', (input) => { | |
const result = rep(input); | |
console.log(result); | |
rl.prompt(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@markx regarding your query on #mal: Try setting readline.createInterface(... "terminal": false) otherwise it messes with the ability of the runtest script to test it. Also you might want that configurable because for normal interactive usage turning off terminal mode is annoying (no line editing or history). The node readline module is slightly screwy with regards to tty handling.