@@ -2111,29 +2111,33 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) {
2111
2111
}
2112
2112
});
2113
2113
2114
- return gotoSet.isEmpty() ? gotoSet : this.closureOperation(gotoSet) ;
2114
+ return gotoSet;
2115
2115
};
2116
2116
2117
2117
/*
2118
2118
* Create unique set of item sets
2119
2119
*/
2120
2120
lrGeneratorMixin.canonicalCollection = function canonicalCollection() {
2121
2121
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),
2123
2124
states = new Set(firstState),
2124
2125
marked = 0,
2125
2126
self = this,
2126
- itemSet;
2127
+ itemSet,
2128
+ markedSymbols;
2127
2129
2128
2130
states.has = {};
2129
- states.has[firstState ] = 0;
2131
+ states.has[firstStateNoClosure.valueOf() ] = 0;
2130
2132
2131
2133
if (devDebug > 0) Jison.print('canonicalCollection: ', states.has);
2132
2134
2133
2135
while (marked !== states.size()) {
2134
2136
itemSet = states.item(marked);
2137
+ markedSymbols = {};
2135
2138
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;
2137
2141
self.canonicalCollectionInsert(item.markedSymbol, itemSet, states, marked);
2138
2142
}
2139
2143
});
@@ -2145,22 +2149,23 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() {
2145
2149
2146
2150
// Pushes a unique state into the queue. Some parsing algorithms may perform additional operations
2147
2151
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
+ }
2158
2166
itemSet.edges[symbol] = states.size(); // store goto transition for table
2159
2167
states.push(g);
2160
2168
g.predecessors[symbol] = [stateNum];
2161
- } else {
2162
- itemSet.edges[symbol] = i; // store goto transition for table
2163
- states.item(i).predecessors[symbol].push(stateNum);
2164
2169
}
2165
2170
}
2166
2171
};
@@ -17729,7 +17734,7 @@ if (typeof exports !== 'undefined') {
17729
17734
17730
17735
17731
17736
},{"./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 */
17733
17738
/*
17734
17739
* Returns a Parser object of the following structure:
17735
17740
*
@@ -18757,7 +18762,7 @@ parse: function parse(input) {
18757
18762
vstack.length = 0;
18758
18763
stack_pointer = 0;
18759
18764
18760
- // nuke the error hash info instances created during this run.
18765
+ // nuke the error hash info instances created during this run.
18761
18766
// Userland code must COPY any data/references
18762
18767
// in the error hash instance(s) it is more permanently interested in.
18763
18768
if (!do_not_nuke_errorinfos) {
@@ -18799,10 +18804,10 @@ parse: function parse(input) {
18799
18804
lexer: lexer,
18800
18805
parser: this,
18801
18806
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
18803
18808
// ref cycle via userland code manipulations.
18804
18809
// These would otherwise all be memory leak opportunities!
18805
- //
18810
+ //
18806
18811
// Note that only array and object references are nuked as those
18807
18812
// constitute the set of elements which can produce a cyclic ref.
18808
18813
// The rest of the members is kept intact as they are harmless.
@@ -19055,7 +19060,7 @@ parser.originalParseError = parser.parseError;
19055
19060
parser.originalQuoteName = parser.quoteName;
19056
19061
19057
19062
19058
- /* generated by jison-lex 0.3.4-155 */
19063
+ /* generated by jison-lex 0.3.4-156 */
19059
19064
var lexer = (function () {
19060
19065
// See also:
19061
19066
// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
0 commit comments