diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-06 16:40:55 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-06 16:40:55 -0500 |
| commit | 31b4416181158b0e49e0a09da8056298b8522ba2 (patch) | |
| tree | 39ca29f0841823cb8208a93ff59c942466457934 /js/step3_env.js | |
| parent | b079f51028571bc603b8d43761c29ff56273bffc (diff) | |
| download | mal-31b4416181158b0e49e0a09da8056298b8522ba2.tar.gz mal-31b4416181158b0e49e0a09da8056298b8522ba2.zip | |
JS: fix web interface.
Diffstat (limited to 'js/step3_env.js')
| -rw-r--r-- | js/step3_env.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/js/step3_env.js b/js/step3_env.js index 41e21c1..1000437 100644 --- a/js/step3_env.js +++ b/js/step3_env.js @@ -1,9 +1,9 @@ -var types = require('./types'); -var reader = require('./reader'); -var printer = require('./printer'); -var Env = require('./env').Env; if (typeof module !== 'undefined') { + var types = require('./types'); var readline = require('./node_readline'); + var reader = require('./reader'); + var printer = require('./printer'); + var Env = require('./env').Env; } // read @@ -80,7 +80,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 @@ -88,10 +89,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 { |
