diff --git a/examples/booleans.fem b/examples/booleans.fem new file mode 100644 index 0000000..720651e --- /dev/null +++ b/examples/booleans.fem @@ -0,0 +1,12 @@ +my_bool is Kawaii + +Femboy Feminine my_bool Femboycore + UwU Boy "It's Kawaii!" +Periodt + +Femboy Feminine Cringe Femboycore + UwU Boy "This won't print." +Periodt +Androgyny Femboycore + UwU Boy "This will print." +Periodt \ No newline at end of file diff --git a/src/interpreter.py b/src/interpreter.py index 7edcf4f..93d8787 100644 --- a/src/interpreter.py +++ b/src/interpreter.py @@ -26,6 +26,9 @@ class Interpreter: def visit_String(self, node): return node.value + def visit_Boolean(self, node): + return node.value + def visit_BinOp(self, node): left_val = self.visit(node.left) right_val = self.visit(node.right) diff --git a/src/parser.py b/src/parser.py index 8b4a4f1..376e047 100644 --- a/src/parser.py +++ b/src/parser.py @@ -11,6 +11,11 @@ class String(AST): self.token = token self.value = token.value +class Boolean(AST): + def __init__(self, token): + self.token = token + self.value = token.value + class BinOp(AST): def __init__(self, left, op, right): self.left = left @@ -240,8 +245,10 @@ class Parser: if self.peek_next_token().type == 'LPAREN': # Assuming '(' is the next token for a function call return self.parse_function_call(token) return Variable(token) + elif token.type == 'KAWAII' or token.type == 'CRINGE': + return Boolean(token) else: - raise Exception(f"Expected integer, string or identifier, got {token.type}") + raise Exception(f"Expected integer, string, boolean or identifier, got {token.type}") def term(self): node = self.factor()