aboutsummaryrefslogtreecommitdiff
path: root/js/step1_read_print.js
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-06 16:40:55 -0500
committerJoel Martin <github@martintribe.org>2014-04-06 16:40:55 -0500
commit31b4416181158b0e49e0a09da8056298b8522ba2 (patch)
tree39ca29f0841823cb8208a93ff59c942466457934 /js/step1_read_print.js
parentb079f51028571bc603b8d43761c29ff56273bffc (diff)
downloadmal-31b4416181158b0e49e0a09da8056298b8522ba2.tar.gz
mal-31b4416181158b0e49e0a09da8056298b8522ba2.zip
JS: fix web interface.
Diffstat (limited to 'js/step1_read_print.js')
-rw-r--r--js/step1_read_print.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/js/step1_read_print.js b/js/step1_read_print.js
index 264b6c6..ef9b6bc 100644
--- a/js/step1_read_print.js
+++ b/js/step1_read_print.js
@@ -1,8 +1,8 @@
-var types = require('./types');
-var reader = require('./reader');
-var printer = require('./printer');
if (typeof module !== 'undefined') {
+ var types = require('./types');
var readline = require('./node_readline');
+ var reader = require('./reader');
+ var printer = require('./printer');
}
// read
@@ -29,7 +29,8 @@ if (typeof require === 'undefined') {
readline.rlwrap(function(line) { return rep(line); },
function(exc) {
if (exc instanceof reader.BlankException) { return; }
- if (exc.stack) { console.log(exc.stack); } else { console.log(exc); }
+ if (exc.stack) { printer.println(exc.stack); }
+ else { printer.println(exc); }
});
} else if (require.main === module) {
// Synchronous node.js commandline mode
@@ -37,10 +38,11 @@ if (typeof require === 'undefined') {
var line = readline.readline("user> ");
if (line === null) { break; }
try {
- if (line) { console.log(rep(line)); }
+ if (line) { printer.println(rep(line)); }
} catch (exc) {
if (exc instanceof reader.BlankException) { continue; }
- if (exc.stack) { console.log(exc.stack); } else { console.log(exc); }
+ if (exc.stack) { printer.println(exc.stack); }
+ else { printer.println(exc); }
}
}
} else {