Skip to content

Commit b994911

Browse files
committed
fix of operator clashing
1 parent 21b2a04 commit b994911

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/main/java/com/igormaznitsa/prologparser/tokenizer/TreeItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ PrologTerm convertToTermAndRelease() {
254254
}
255255

256256
if (!isPrecedenceOrderOk()) {
257-
if (this.rightBranch != null || this.leftBranch != null) {
257+
if (this.rightBranch != null ^ this.leftBranch != null) {
258258
final Op operator = (Op) wrapper.getWrappedTerm();
259259
if (operator.getOpAssoc() == OpAssoc.XF || operator.getOpAssoc() == OpAssoc.YF || operator.getOpAssoc() == OpAssoc.FX || operator.getOpAssoc() == OpAssoc.FY) {
260260
final PrologTerm that = this.rightBranch != null

src/test/java/com/igormaznitsa/prologparser/IntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,7 @@ public void testOperatorAsFunctor() throws Exception {
969969
public void testPairOfOperatorsWithIncompatiblePrecedence() throws Exception {
970970
assertEquals("-(discontiguous)", parseEd("-discontiguous.").next().toString());
971971
assertEquals("a : b :> c :> d", parseEd("a:b:>c:>d.", DefaultParserContext.of(ParserContext.FLAG_NONE, Op.make(500, XFY, ":>"))).next().toString());
972+
assertThrows(PrologParserException.class, () -> parseEd("X=(a,b,c; dynamic d).").next());
972973
assertThrows(PrologParserException.class, () -> parseEd("a :- b :- c.").next());
973974
assertThrows(PrologParserException.class, () -> parseEd("?-mother(pam,bob);").next());
974975
}

0 commit comments

Comments
 (0)