Navigation Menu

Skip to content

Commit

Permalink
Node compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
zaach committed Feb 8, 2010
1 parent 420c1d2 commit 6bb038a
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions lib/jison.js
Expand Up @@ -6,14 +6,23 @@ if (typeof exports === 'undefined') {
exports = {};
} else {
// assume we're in commonjs land
var system = require("system");
//var system = require("system");
var typal = require('./jison/util/typal').typal;
var Set = require('./jison/util/set').Set;
var RegExpLexer = require('./jison/lexer').RegExpLexer;
}

var Jison = exports.Jison = exports;

// detect print
if (typeof puts !== 'undefined') {
Jison.print = function print () { puts([].join.call(arguments, ' ')); };
} else if (typeof print !== 'undefined') {
Jison.print = print;
} else {
Jison.print = function print () {};
}

Jison.Parser = (function () {

// iterator utility
Expand Down Expand Up @@ -288,7 +297,7 @@ generator.createParser = function createParser () {
generator.trace = function trace () { };

generator.warn = function warn () {
print.apply(null,arguments);
Jison.print.apply(null,arguments);
};

generator.error = function error (msg) {
Expand All @@ -299,7 +308,7 @@ generator.error = function error (msg) {

var generatorDebug = {
trace: function trace () {
print.apply(null, arguments);
Jison.print.apply(null, arguments);
},
beforeprocessGrammar: function () {
this.trace("Processing grammar.");
Expand Down Expand Up @@ -1168,6 +1177,21 @@ var lalr = generator.beget(lookaheadMixin, lrGeneratorMixin, {

var LALRGenerator = exports.LALRGenerator = lalr.construct();

// LALR generator debug mixin

var lalrGeneratorDebug = {
trace: function trace () {
Jison.print.apply(null, arguments);
},
beforebuildNewGrammar: function () {
this.trace(this.states.size()+" states.");
this.trace("Building lookahead grammar.");
},
beforeunionLookaheads: function () {
this.trace("Computing lookaheads.");
}
};

/*
* Lookahead parser definitions
*
Expand Down

0 comments on commit 6bb038a

Please sign in to comment.