14 lines
475 B
Python
14 lines
475 B
Python
from core.tokens import BinaryPredicate
|
|
from core.exceptions import runtimeError
|
|
|
|
def evalBinaryPredicate(op: BinaryPredicate, a, b):
|
|
try:
|
|
match op:
|
|
case BinaryPredicate.LT:
|
|
return a < b
|
|
case BinaryPredicate.GT:
|
|
return a > b
|
|
case BinaryPredicate.EQ:
|
|
return a == b
|
|
except Exception as e:
|
|
raise runtimeError(f'cannot apply {repr(op)} to {repr(a)} and {repr(b)}') from e |