Permalink
Browse files

Equality of productions based on content (not id) to prevent caching …

…issues when re-using parse table reader
  • Loading branch information...
jasperdenkers committed Jun 19, 2018
1 parent adfe52b commit 87bc75129104c0e21c834172c896a357810ca73d
@@ -1,5 +1,7 @@
package org.spoofax.jsglr2.parsetable;
import java.util.Objects;
import org.metaborg.parsetable.IProduction;
import org.metaborg.parsetable.ProductionType;
@@ -25,8 +27,8 @@
public Production(int productionId, String sort, String startSymbolSort, String descriptor, Boolean isContextFree,
Boolean isLayout, Boolean isLiteral, Boolean isLexical, Boolean isLexicalRhs, Boolean isSkippableInParseForest,
Boolean isList, Boolean isOptional, Boolean isStringLiteral, Boolean isNumberLiteral, Boolean isOperator, Boolean isLongestMatch,
ProductionAttributes attributes) {
Boolean isList, Boolean isOptional, Boolean isStringLiteral, Boolean isNumberLiteral, Boolean isOperator,
Boolean isLongestMatch, ProductionAttributes attributes) {
this.productionId = productionId;
this.sort = sort;
this.startSymbolSort = startSymbolSort;
@@ -149,7 +151,14 @@ public static ProductionType typeFromInt(int productionType) {
Production that = (Production) o;
return productionId == that.productionId;
return productionId == that.productionId && Objects.equals(sort, that.sort)
&& Objects.equals(startSymbolSort, that.startSymbolSort) && Objects.equals(descriptor, that.descriptor)
&& isContextFree == that.isContextFree && isLayout == that.isLayout && isLiteral == that.isLiteral
&& isLexical == that.isLexical && isLexicalRhs == that.isLexicalRhs
&& isSkippableInParseForest == that.isSkippableInParseForest && isList == that.isList
&& isOptional == that.isOptional && isStringLiteral == that.isStringLiteral
&& isNumberLiteral == that.isNumberLiteral && isOperator == that.isOperator
&& isLongestMatch == that.isLongestMatch && Objects.equals(attributes, that.attributes);
}
@Override public boolean isIgnoreLayoutConstraint() {
@@ -1,5 +1,7 @@
package org.spoofax.jsglr2.parsetable;
import java.util.Objects;
import org.metaborg.parsetable.ProductionType;
import org.spoofax.interpreter.terms.IStrategoNamed;
import org.spoofax.interpreter.terms.IStrategoTerm;
@@ -45,4 +47,23 @@ public boolean isCompletionOrRecovery() {
return isCompletion || isLiteralCompletion || isPlaceholderInsertion || isRecover;
}
@Override public boolean equals(Object o) {
if(this == o) {
return true;
}
if(o == null || getClass() != o.getClass()) {
return false;
}
ProductionAttributes that = (ProductionAttributes) o;
return type.equals(that.type) && Objects.equals(constructorTerm, that.constructorTerm)
&& Objects.equals(constructor, that.constructor) && isRecover == that.isRecover
&& isBracket == that.isBracket && isCompletion == that.isCompletion
&& isPlaceholderInsertion == that.isPlaceholderInsertion && isLiteralCompletion == that.isLiteralCompletion
&& isIgnoreLayout == that.isIgnoreLayout && isNewlineEnforced == that.isNewlineEnforced
&& isLongestMatch == that.isLongestMatch && isCaseInsensitive == that.isCaseInsensitive
&& isIndentPaddingLexical == that.isIndentPaddingLexical && isFlatten == that.isFlatten;
}
}

0 comments on commit 87bc751

Please sign in to comment.