aboutsummaryrefslogtreecommitdiff
path: root/neb/std/boolean.py
blob: e716a877c916c53dd9e797ba0c9ec3184428da29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from .. import TypeEnum, Environment, Arg, Builtin, evaluate, InterpretPanic
from ..structs import *

BOOLEAN = Environment()

def interpretEq(symbol, args, env, ns):
    # NOTE this currently only works for literals
    # compare types because 0 != #false in neb
    if type(args[0]) == type(args[1]) and args[0].value == args[1].value:
        return Bool(True)
    else:
        return Bool(False)

eq_arg = Arg("value", TypeEnum.LITERAL)
BOOLEAN.register("eq?", Builtin("eq?", interpretEq, [eq_arg, eq_arg], return_type=Type(":bool")))


def interpretNot(symbol, args, env, ns):
    return Bool(not args[0].value)

not_arg = Arg("not", TypeEnum.BOOL)
BOOLEAN.register("not", Builtin("not", interpretNot, [not_arg], return_type=Type(":bool")))