Permalink
Browse files

In Node.js examples, require 'util' instead of 'sys' and call ast.toS…

…tring() when using console.log
  • Loading branch information...
1 parent 0e0363c commit 69d70c6c6d8a27033f8c20792df0c074c9c09fbc @orlandohill committed Mar 31, 2012
View
12 docs/book/book
@@ -796,7 +796,7 @@ var p = new parser.Parser();
var ast = p.parse("42");
// Print our AST
-console.log(ast);
+console.log(ast.toString());
-------------------------------------------------------------------------------
==== Run ====
@@ -1409,7 +1409,7 @@ public final class Calculator {
.src/example/javascript/nodejs_calculator.js
[source,javascript]
-------------------------------------------------------------------------------
-var sys = require('sys');
+var util = require('util');
var waxeye = require('waxeye');
var parser = require('./parser');
@@ -1483,16 +1483,16 @@ var stdin = process.openStdin();
stdin.setEncoding('utf8');
-sys.print('calc> ');
+util.print('calc> ');
// Read our input
stdin.on('data', function (line) {
- sys.puts(calc(line));
- sys.print('calc> ');
+ util.puts(calc(line));
+ util.print('calc> ');
});
stdin.on('end', function () {
- sys.print('\n');
+ util.print('\n');
});
-------------------------------------------------------------------------------
View
10 src/example/javascript/nodejs_calculator.js
@@ -5,7 +5,7 @@
* Licensed under the MIT license. See 'LICENSE' for details.
*/
-var sys = require('sys');
+var util = require('util');
var waxeye = require('waxeye');
var parser = require('./parser');
@@ -79,14 +79,14 @@ var stdin = process.openStdin();
stdin.setEncoding('utf8');
-sys.print('calc> ');
+util.print('calc> ');
// Read our input
stdin.on('data', function (line) {
- sys.puts(calc(line));
- sys.print('calc> ');
+ util.puts(calc(line));
+ util.print('calc> ');
});
stdin.on('end', function () {
- sys.print('\n');
+ util.print('\n');
});
View
3 src/example/javascript/nodejs_example.js
@@ -4,7 +4,6 @@
* Copyright (C) 2008-2010 Orlando Hill
* Licensed under the MIT license. See 'LICENSE' for details.
*/
-var sys = require('sys');
var parser = require('./parser');
// Create our parser
@@ -14,4 +13,4 @@ var p = new parser.Parser();
var ast = p.parse("42");
// Print our AST
-sys.puts(ast);
+console.log(ast.toString());
View
3 src/example/javascript/nodejs_stdin_example.js
@@ -4,7 +4,6 @@
* Copyright (C) 2008-2010 Orlando Hill
* Licensed under the MIT license. See 'LICENSE' for details.
*/
-var sys = require('sys');
var parser = require('./parser');
var input = "";
@@ -25,5 +24,5 @@ stdin.on('end', function () {
var ast = p.parse(input);
// Print our AST
- sys.puts(ast);
+ console.log(ast.toString());
});

0 comments on commit 69d70c6

Please sign in to comment.