Skip to content

Commit

Permalink
Add not operators (#1582)
Browse files Browse the repository at this point in the history
Add the unary operator not and bitwise not.
Initially implemented in C & Python simply because I use those the most
Surprised this wasn't implemented previously, not sure if there was a
reason why

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
alexander-clarke and pre-commit-ci[bot] authored Oct 26, 2024
1 parent f6b4f85 commit 9e44876
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lang/c/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ def code_operator_and():
def code_operator_or():
actions.auto_insert(" || ")

def code_operator_not():
actions.auto_insert("!")

def code_operator_bitwise_and():
actions.auto_insert(" & ")

Expand All @@ -284,6 +287,9 @@ def code_operator_bitwise_exclusive_or():
def code_operator_bitwise_exclusive_or_assignment():
actions.auto_insert(" ^= ")

def code_operator_bitwise_not():
actions.auto_insert("~")

def code_operator_bitwise_left_shift():
actions.auto_insert(" << ")

Expand Down
6 changes: 6 additions & 0 deletions lang/python/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ def code_operator_and():
def code_operator_or():
actions.auto_insert(" or ")

def code_operator_not():
actions.auto_insert("not ")

def code_operator_in():
actions.auto_insert(" in ")

Expand All @@ -238,6 +241,9 @@ def code_operator_bitwise_exclusive_or():
def code_operator_bitwise_exclusive_or_assignment():
actions.auto_insert(" ^= ")

def code_operator_bitwise_not():
actions.auto_insert("~")

def code_operator_bitwise_left_shift():
actions.auto_insert(" << ")

Expand Down
3 changes: 3 additions & 0 deletions lang/tags/operators_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def code_operator_bitwise_and():
def code_operator_bitwise_or():
"""code_operator_bitwise_or"""

def code_operator_bitwise_not():
"""code_operator_bitwise_not"""

def code_operator_bitwise_exclusive_or():
"""code_operator_bitwise_exclusive_or"""

Expand Down
1 change: 1 addition & 0 deletions lang/tags/operators_bitwise.talon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tag: user.code_operators_bitwise
#bitwise operators
[op] bitwise and: user.code_operator_bitwise_and()
[op] bitwise or: user.code_operator_bitwise_or()
[op] bitwise not: user.code_operator_bitwise_not()

# TODO: split these out into separate logical and bitwise operator commands

Expand Down
3 changes: 3 additions & 0 deletions lang/tags/operators_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def code_operator_and():
def code_operator_or():
"""code_operator_or"""

def code_operator_not():
"""code_operator_not"""

def code_operator_in():
"""code_operator_in"""

Expand Down
1 change: 1 addition & 0 deletions lang/tags/operators_math.talon
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ op mod: user.code_operator_modulo()
# logical operators
(op | logical) and: user.code_operator_and()
(op | logical) or: user.code_operator_or()
(op | logical) not: user.code_operator_not()

# set operators
(op | is) in: user.code_operator_in()
Expand Down

0 comments on commit 9e44876

Please sign in to comment.