Skip to content

Commit

Permalink
Enforce boolean expression priority
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Sep 19, 2024
1 parent a36da34 commit 7e860a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pyecoreocl/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ def visitBooleanBinaryOperation(self, ctx):
self.visit(ctx.right)
self.inline(")")
return
self.inline("(")
self.visit(ctx.left)
self.inline(f" {operator} ")
self.visit(ctx.right)
self.inline(")")

def visitCallExpression(self, ctx):
self.visit(ctx.expression)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_expressions_strict.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def test__booleans():
assert !true! is True
assert !false! is False

assert (!not true!) is False
assert (!not false!) is True
assert !not true! is False
assert !not false! is True

assert !(true or true)! is True
assert !(true or false)! is True
assert !true or false! is True
assert !(false or true)! is True
assert !(false or false)! is False

Expand Down

0 comments on commit 7e860a4

Please sign in to comment.