mirror of
https://github.com/Alvin-Zilverstand/femcode.git
synced 2026-03-06 11:06:47 +01:00
feat: Implement booleans (Kawaii/Cringe)
This commit is contained in:
12
examples/booleans.fem
Normal file
12
examples/booleans.fem
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user