resolve contribs conflict

This commit is contained in:
parrt 2016-10-13 16:21:00 -07:00
commit 285c7fca6c
4 changed files with 38 additions and 14 deletions

7
.editorconfig Normal file
View File

@ -0,0 +1,7 @@
root = true
[*.{java,stg}]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

View File

@ -94,4 +94,5 @@ YYYY/MM/DD, github id, Full name, email
2016/03/28, gagern, Martin von Gagern, gagern@ma.tum.de
2016/08/11, BurtHarris, Ralph "Burt" Harris, Burt_Harris_antlr4@azxs.33mail.com
2016/08/19, andjo403, Andreas Jonson, andjo403@hotmail.com
2016/10/13, cgudrian, Christian Gudrian, christian.gudrian@gmx.de
2016/10/13, cgudrian, Christian Gudrian, christian.gudrian@gmx.de
2016/10/13, nielsbasjes, Niels Basjes, niels@basjes.nl

View File

@ -96,10 +96,16 @@ ATNConfig.prototype.checkContext = function(params, config) {
}
};
ATNConfig.prototype.hashString = function() {
return "" + this.state.stateNumber + "/" + this.alt + "/" +
(this.context===null ? "" : this.context.hashString()) +
"/" + this.semanticContext.hashString();
};
// An ATN configuration is equal to another if both have
// the same state, they predict the same alternative, and
// syntactic/semantic contexts are the same.
///
ATNConfig.prototype.equals = function(other) {
if (this === other) {
return true;
@ -114,16 +120,23 @@ ATNConfig.prototype.equals = function(other) {
}
};
ATNConfig.prototype.shortHashString = function() {
ATNConfig.prototype.hashStringForConfigSet = function() {
return "" + this.state.stateNumber + "/" + this.alt + "/" + this.semanticContext;
};
ATNConfig.prototype.hashString = function() {
return "" + this.state.stateNumber + "/" + this.alt + "/" +
(this.context===null ? "" : this.context.hashString()) +
"/" + this.semanticContext.hashString();
ATNConfig.prototype.equalsForConfigSet = function(other) {
if (this === other) {
return true;
} else if (! (other instanceof ATNConfig)) {
return false;
} else {
return this.state.stateNumber===other.state.stateNumber &&
this.alt===other.alt &&
this.semanticContext.equals(other.semanticContext);
}
};
ATNConfig.prototype.toString = function() {
return "(" + this.state + "," + this.alt +
(this.context!==null ? ",[" + this.context.toString() + "]" : "") +
@ -171,6 +184,11 @@ LexerATNConfig.prototype.equals = function(other) {
}
};
LexerATNConfig.prototype.hashStringForConfigSet = LexerATNConfig.prototype.hashString;
LexerATNConfig.prototype.equalsForConfigSet = LexerATNConfig.prototype.eqials;
LexerATNConfig.prototype.checkNonGreedyDecision = function(source, target) {
return source.passedThroughNonGreedyDecision ||
(target instanceof DecisionState) && target.nonGreedy;

View File

@ -41,19 +41,17 @@ var SemanticContext = require('./SemanticContext').SemanticContext;
var merge = require('./../PredictionContext').merge;
function hashATNConfig(c) {
return c.shortHashString();
return c.hashStringForConfigSet();
}
function equalATNConfigs(a, b) {
if ( a===b ) {
return true;
}
if ( a===null || b===null ) {
} else if ( a===null || b===null ) {
return false;
}
return a.state.stateNumber===b.state.stateNumber &&
a.alt===b.alt && a.semanticContext.equals(b.semanticContext);
}
} else
return a.equalsForConfigSet(b);
}
function ATNConfigSet(fullCtx) {