Skip to content

Commit 910f3c2

Browse files
committed
Merge remote-tracking branch 'remotes/CecilLee/master': merged zaach#260, all tests pass, as before.
# Conflicts: # lib/jison.js # package.json
2 parents cbf0bde + 3271b0d commit 910f3c2

File tree

5 files changed

+58
-48
lines changed

5 files changed

+58
-48
lines changed

lib/jison.js

+23-18
Original file line numberDiff line numberDiff line change
@@ -2104,29 +2104,33 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) {
21042104
}
21052105
});
21062106

2107-
return gotoSet.isEmpty() ? gotoSet : this.closureOperation(gotoSet);
2107+
return gotoSet;
21082108
};
21092109

21102110
/*
21112111
* Create unique set of item sets
21122112
*/
21132113
lrGeneratorMixin.canonicalCollection = function canonicalCollection() {
21142114
var item1 = new this.Item(this.productions[0], 0, [this.EOF]);
2115-
var firstState = this.closureOperation(new this.ItemSet(item1)),
2115+
var firstStateNoClosure = new this.ItemSet(item1),
2116+
firstState = this.closureOperation(firstStateNoClosure),
21162117
states = new Set(firstState),
21172118
marked = 0,
21182119
self = this,
2119-
itemSet;
2120+
itemSet,
2121+
markedSymbols;
21202122

21212123
states.has = {};
2122-
states.has[firstState] = 0;
2124+
states.has[firstStateNoClosure.valueOf()] = 0;
21232125

21242126
if (devDebug > 0) Jison.print('canonicalCollection: ', states.has);
21252127

21262128
while (marked !== states.size()) {
21272129
itemSet = states.item(marked);
2130+
markedSymbols = {};
21282131
itemSet.forEach(function CC_itemSet_forEach(item) {
2129-
if (item.markedSymbol && item.markedSymbol !== self.EOF) {
2132+
if (item.markedSymbol && !markedSymbols[item.markedSymbol] && item.markedSymbol !== self.EOF) {
2133+
markedSymbols[item.markedSymbol] = true;
21302134
self.canonicalCollectionInsert(item.markedSymbol, itemSet, states, marked);
21312135
}
21322136
});
@@ -2138,22 +2142,23 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() {
21382142

21392143
// Pushes a unique state into the queue. Some parsing algorithms may perform additional operations
21402144
lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) {
2141-
var g = this.gotoOperation(itemSet, symbol);
2142-
if (!g.predecessors) {
2143-
g.predecessors = {};
2144-
}
2145-
// add g to queue if not empty or duplicate
2146-
if (!g.isEmpty()) {
2147-
var gv = g.valueOf(),
2148-
i = states.has[gv];
2149-
if (i === -1 || typeof i === 'undefined') {
2150-
states.has[gv] = states.size();
2145+
var g = this.gotoOperation(itemSet, symbol),
2146+
state = states.has[g.valueOf()];
2147+
2148+
if (state !== undefined) {
2149+
itemSet.edges[symbol] = state; // store goto transition for table
2150+
states.item(state).predecessors[symbol].push(stateNum);
2151+
} else {
2152+
// add g to queue if not empty or duplicate
2153+
if (!g.isEmpty()) {
2154+
states.has[g.valueOf()] = states.size();
2155+
g = this.closureOperation(g);
2156+
if (!g.predecessors) {
2157+
g.predecessors = {};
2158+
}
21512159
itemSet.edges[symbol] = states.size(); // store goto transition for table
21522160
states.push(g);
21532161
g.predecessors[symbol] = [stateNum];
2154-
} else {
2155-
itemSet.edges[symbol] = i; // store goto transition for table
2156-
states.item(i).predecessors[symbol].push(stateNum);
21572162
}
21582163
}
21592164
};

lib/util/transform-parser.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/lex-parser

web/content/assets/js/jison.js

+28-23
Original file line numberDiff line numberDiff line change
@@ -2111,29 +2111,33 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) {
21112111
}
21122112
});
21132113

2114-
return gotoSet.isEmpty() ? gotoSet : this.closureOperation(gotoSet);
2114+
return gotoSet;
21152115
};
21162116

21172117
/*
21182118
* Create unique set of item sets
21192119
*/
21202120
lrGeneratorMixin.canonicalCollection = function canonicalCollection() {
21212121
var item1 = new this.Item(this.productions[0], 0, [this.EOF]);
2122-
var firstState = this.closureOperation(new this.ItemSet(item1)),
2122+
var firstStateNoClosure = new this.ItemSet(item1),
2123+
firstState = this.closureOperation(firstStateNoClosure),
21232124
states = new Set(firstState),
21242125
marked = 0,
21252126
self = this,
2126-
itemSet;
2127+
itemSet,
2128+
markedSymbols;
21272129

21282130
states.has = {};
2129-
states.has[firstState] = 0;
2131+
states.has[firstStateNoClosure.valueOf()] = 0;
21302132

21312133
if (devDebug > 0) Jison.print('canonicalCollection: ', states.has);
21322134

21332135
while (marked !== states.size()) {
21342136
itemSet = states.item(marked);
2137+
markedSymbols = {};
21352138
itemSet.forEach(function CC_itemSet_forEach(item) {
2136-
if (item.markedSymbol && item.markedSymbol !== self.EOF) {
2139+
if (item.markedSymbol && !markedSymbols[item.markedSymbol] && item.markedSymbol !== self.EOF) {
2140+
markedSymbols[item.markedSymbol] = true;
21372141
self.canonicalCollectionInsert(item.markedSymbol, itemSet, states, marked);
21382142
}
21392143
});
@@ -2145,22 +2149,23 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() {
21452149

21462150
// Pushes a unique state into the queue. Some parsing algorithms may perform additional operations
21472151
lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) {
2148-
var g = this.gotoOperation(itemSet, symbol);
2149-
if (!g.predecessors) {
2150-
g.predecessors = {};
2151-
}
2152-
// add g to queue if not empty or duplicate
2153-
if (!g.isEmpty()) {
2154-
var gv = g.valueOf(),
2155-
i = states.has[gv];
2156-
if (i === -1 || typeof i === 'undefined') {
2157-
states.has[gv] = states.size();
2152+
var g = this.gotoOperation(itemSet, symbol),
2153+
state = states.has[g.valueOf()];
2154+
2155+
if (state !== undefined) {
2156+
itemSet.edges[symbol] = state; // store goto transition for table
2157+
states.item(state).predecessors[symbol].push(stateNum);
2158+
} else {
2159+
// add g to queue if not empty or duplicate
2160+
if (!g.isEmpty()) {
2161+
states.has[g.valueOf()] = states.size();
2162+
g = this.closureOperation(g);
2163+
if (!g.predecessors) {
2164+
g.predecessors = {};
2165+
}
21582166
itemSet.edges[symbol] = states.size(); // store goto transition for table
21592167
states.push(g);
21602168
g.predecessors[symbol] = [stateNum];
2161-
} else {
2162-
itemSet.edges[symbol] = i; // store goto transition for table
2163-
states.item(i).predecessors[symbol].push(stateNum);
21642169
}
21652170
}
21662171
};
@@ -17729,7 +17734,7 @@ if (typeof exports !== 'undefined') {
1772917734

1773017735

1773117736
},{"./typal":11,"assert":12}],10:[function(require,module,exports){
17732-
/* parser generated by jison 0.4.18-155 */
17737+
/* parser generated by jison 0.4.18-156 */
1773317738
/*
1773417739
* Returns a Parser object of the following structure:
1773517740
*
@@ -18757,7 +18762,7 @@ parse: function parse(input) {
1875718762
vstack.length = 0;
1875818763
stack_pointer = 0;
1875918764

18760-
// nuke the error hash info instances created during this run.
18765+
// nuke the error hash info instances created during this run.
1876118766
// Userland code must COPY any data/references
1876218767
// in the error hash instance(s) it is more permanently interested in.
1876318768
if (!do_not_nuke_errorinfos) {
@@ -18799,10 +18804,10 @@ parse: function parse(input) {
1879918804
lexer: lexer,
1880018805
parser: this,
1880118806

18802-
// and make sure the error info doesn't stay due to potential
18807+
// and make sure the error info doesn't stay due to potential
1880318808
// ref cycle via userland code manipulations.
1880418809
// These would otherwise all be memory leak opportunities!
18805-
//
18810+
//
1880618811
// Note that only array and object references are nuked as those
1880718812
// constitute the set of elements which can produce a cyclic ref.
1880818813
// The rest of the members is kept intact as they are harmless.
@@ -19055,7 +19060,7 @@ parser.originalParseError = parser.parseError;
1905519060
parser.originalQuoteName = parser.quoteName;
1905619061

1905719062

19058-
/* generated by jison-lex 0.3.4-155 */
19063+
/* generated by jison-lex 0.3.4-156 */
1905919064
var lexer = (function () {
1906019065
// See also:
1906119066
// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508

0 commit comments

Comments
 (0)