function calls work!!!
This commit is contained in:
16
AST.py
16
AST.py
@@ -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
|
||||
Reference in New Issue
Block a user