Skip to content

Commit

Permalink
Merge pull request #1 from patriciali/master
Browse files Browse the repository at this point in the history
turn off debugging
  • Loading branch information
syrnick authored Feb 23, 2017
2 parents 18bcf72 + aa766b3 commit 3adfed5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/jison.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ generator.constructor = function Jison_Generator (grammar, opt) {
this.moduleInclude = grammar.moduleInclude || '';

this.DEBUG = options.debug || false;
this.enableDebugLogs = options.enableDebugLogs || false;
this.numExpectedConflictStates = options.numExpectedConflictStates || 0;
if (this.DEBUG) this.mix(generatorDebug); // mixin debug methods

this.processGrammar(grammar);
Expand Down Expand Up @@ -831,7 +833,9 @@ lrGeneratorMixin.parseTable = function parseTable (itemSets) {
if (sol.bydefault) {
self.conflicts++;
if (!self.DEBUG) {
self.warn('Conflict in grammar: multiple actions possible when lookahead token is ',stackSymbol,' in state ',k, "\n- ", printAction(sol.r, self), "\n- ", printAction(sol.s, self));
if (self.enableDebugLogs) {
self.warn('Conflict in grammar: multiple actions possible when lookahead token is ',stackSymbol,' in state ',k, "\n- ", printAction(sol.r, self), "\n- ", printAction(sol.s, self));
}
conflictedStates[k] = true;
}
if (self.options.noDefaultResolve) {
Expand All @@ -856,11 +860,13 @@ lrGeneratorMixin.parseTable = function parseTable (itemSets) {
});

if (!self.DEBUG && self.conflicts > 0) {
self.warn("\nStates with conflicts:");
each(conflictedStates, function (val, state) {
self.warn('State '+state);
self.warn(' ',itemSets.item(state).join("\n "));
});
if (this.numExpectedConflictStates !== self.conflicts) {
self.warn("\nStates with conflicts:");
each(conflictedStates, function (val, state) {
self.warn('State '+state);
self.warn(' ',itemSets.item(state).join("\n "));
});
}
}

return states;
Expand Down

0 comments on commit 3adfed5

Please sign in to comment.