Sha256: e711dfd5175448542fda3b861e82ba332eb6d2a97822448bab4424b97225320e
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
var input = process.openStdin(), output = process.stdout, vm = require("vm"), readline = require("readline").createInterface(input, output), sibilant = require("./sibilant"), context = undefined, cmdBuffer = "", util = require("util"); var createContext = (function() { var context = vm.createContext(); (module)["filename"] = (process.cwd() + "/exec"); (context)["module"] = module; (context)["require"] = require; (function() { for (var key in global) (function() { return (context)[key] = (global)[key]; })(); })(); return context; }); context = createContext(); var displayPrompt = (function() { readline.setPrompt(((function() { if ((cmdBuffer.length > 10)) { return ("..." + cmdBuffer.slice(-10)); } else { return (function() { if ((cmdBuffer.length > 0)) { return cmdBuffer; } else { return "sibilant"; } })(); } })() + "> ")); return readline.prompt(); }); readline.on("line", (function(cmd) { var jsLine = ""; (function() { try { cmdBuffer = (cmdBuffer + cmd); sibilant.tokenize(cmdBuffer).forEach((function(stmt) { return jsLine = (jsLine + sibilant.translate(stmt, "statement")); })); var result = vm.runInContext(jsLine, context, "sibilant-repl"); (readline.history)[0] = cmdBuffer; (function() { if (typeof(result) !== 'undefined') { return output.write(("result: " + util.inspect(result) + "\n")); } })(); (context)["_"] = result; return cmdBuffer = ""; } catch (e) { return (function() { if (e.message.match(/unexpected EOF/)) { cmdBuffer = (cmdBuffer + " "); return readline.history.shift(); } else { (readline.history)[0] = cmdBuffer; output.write((e.stack + "\n")); return cmdBuffer = ""; } })(); } })(); return displayPrompt(); })); readline.on("close", input.destroy); displayPrompt();
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sibilant-0.0.4 | js/sibilant/lib/repl.js |
sibilant-0.0.3 | js/sibilant/lib/repl.js |