diff --git a/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java b/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java index dc2d0bd7bc4..cefae41e28e 100644 --- a/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java +++ b/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java @@ -247,6 +247,15 @@ protected Result equalToConcreteSyntax(ConcreteSyntaxResult that) { return bool(true, ctx); } + if (TreeAdapter.isCycle(left) && TreeAdapter.isCycle(right)) { + IConstructor type1 = TreeAdapter.getCycleType(left); + IConstructor type2 = TreeAdapter.getCycleType(right); + int length1 = TreeAdapter.getCycleLength(left); + int length2 = TreeAdapter.getCycleLength(right); + + return bool(type1.equals(type2) && length1 == length2, ctx); + } + return bool(false, ctx); } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/ParseTreeEquality.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/ParseTreeEquality.rsc new file mode 100644 index 00000000000..11f86ab5448 --- /dev/null +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/ParseTreeEquality.rsc @@ -0,0 +1,10 @@ +module lang::rascal::tests::concrete::ParseTreeEquality + +import ParseTree; + +bool testCycleEquality() { + Tree cycle1 = cycle(sort("X"), 3); + Tree cycle2 = cycle(sort("X"), 3); + + return cycle1 == cycle2; +}