This commit is contained in:
Eric Vergnaud 2015-09-30 22:07:46 +08:00
parent 3bdc4b7ee6
commit a3b27766fa
3 changed files with 10 additions and 10 deletions

View File

@ -78,7 +78,7 @@ ATN.prototype.nextTokensNoContext = function(s) {
return s.nextTokenWithinRule; return s.nextTokenWithinRule;
} }
s.nextTokenWithinRule = this.nextTokensInContext(s, null); s.nextTokenWithinRule = this.nextTokensInContext(s, null);
s.nextTokenWithinRule.readonly = true; s.nextTokenWithinRule.readOnly = true;
return s.nextTokenWithinRule; return s.nextTokenWithinRule;
}; };

View File

@ -78,7 +78,7 @@ function ATNConfigSet(fullCtx) {
// the sets and they must not change. This does not protect the other // the sets and they must not change. This does not protect the other
// fields; in particular, conflictingAlts is set after // fields; in particular, conflictingAlts is set after
// we've made this readonly. // we've made this readonly.
this.readonly = false; this.readOnly = false;
// Track the elements as they are added to the set; supports get(i)/// // Track the elements as they are added to the set; supports get(i)///
this.configs = []; this.configs = [];
@ -112,7 +112,7 @@ ATNConfigSet.prototype.add = function(config, mergeCache) {
if (mergeCache === undefined) { if (mergeCache === undefined) {
mergeCache = null; mergeCache = null;
} }
if (this.readonly) { if (this.readOnly) {
throw "This set is readonly"; throw "This set is readonly";
} }
if (config.semanticContext !== SemanticContext.NONE) { if (config.semanticContext !== SemanticContext.NONE) {
@ -168,7 +168,7 @@ Object.defineProperty(ATNConfigSet.prototype, "items", {
}); });
ATNConfigSet.prototype.optimizeConfigs = function(interpreter) { ATNConfigSet.prototype.optimizeConfigs = function(interpreter) {
if (this.readonly) { if (this.readOnly) {
throw "This set is readonly"; throw "This set is readonly";
} }
if (this.configLookup.length === 0) { if (this.configLookup.length === 0) {
@ -202,7 +202,7 @@ ATNConfigSet.prototype.equals = function(other) {
}; };
ATNConfigSet.prototype.hashString = function() { ATNConfigSet.prototype.hashString = function() {
if (this.readonly) { if (this.readOnly) {
if (this.cachedHashString === "-1") { if (this.cachedHashString === "-1") {
this.cachedHashString = this.hashConfigs(); this.cachedHashString = this.hashConfigs();
} }
@ -245,7 +245,7 @@ ATNConfigSet.prototype.containsFast = function(item) {
}; };
ATNConfigSet.prototype.clear = function() { ATNConfigSet.prototype.clear = function() {
if (this.readonly) { if (this.readOnly) {
throw "This set is readonly"; throw "This set is readonly";
} }
this.configs = []; this.configs = [];
@ -253,9 +253,9 @@ ATNConfigSet.prototype.clear = function() {
this.configLookup = new Set(); this.configLookup = new Set();
}; };
ATNConfigSet.prototype.setReadonly = function(readonly) { ATNConfigSet.prototype.setReadonly = function(readOnly) {
this.readonly = readonly; this.readOnly = readOnly;
if (readonly) { if (readOnly) {
this.configLookup = null; // can't mod, no need for lookup cache this.configLookup = null; // can't mod, no need for lookup cache
} }
}; };

View File

@ -1637,7 +1637,7 @@ ParserATNSimulator.prototype.addDFAState = function(dfa, D) {
return existing; return existing;
} }
D.stateNumber = dfa.states.length; D.stateNumber = dfa.states.length;
if (! D.configs.readonly) { if (! D.configs.readOnly) {
D.configs.optimizeConfigs(this); D.configs.optimizeConfigs(this);
D.configs.setReadonly(true); D.configs.setReadonly(true);
} }