function calls work!!!

This commit is contained in:
SpookyDervish
2025-10-15 06:59:29 +11:00
parent 170146ee7e
commit 049db7c53a
6 changed files with 119 additions and 15 deletions

16
AST.py
View File

@@ -16,6 +16,7 @@ class NodeType(Enum):
# Expressions
InfixExpression = "InfixExpression"
CallExpression = "CallExpression"
# Literals
IntegerLiteral = "IntegerLiteral"
@@ -231,4 +232,19 @@ class InfixExpression(Expression):
"operator": self.operator,
"right_node": self.right_node.json()
}
class CallExpression(Expression):
def __init__(self, function: Expression = None, arguments: list[Expression] = None) -> None:
self.function = function
self.arguments = arguments
def type(self) -> NodeType:
return NodeType.CallExpression
def json(self) -> dict:
return {
"type": self.type().value,
"function": self.function.json(),
"arguments": [arg.json() for arg in self.arguments]
}
# endregion