file imports work!!!!!

This commit is contained in:
SpookyDervish
2025-10-18 07:21:19 +11:00
parent 24fcbb3fb7
commit 52686fa314
15 changed files with 210 additions and 73 deletions

35
AST.py
View File

@@ -17,11 +17,13 @@ class NodeType(Enum):
BreakStatement = "BreakStatement"
ContinueStatement = "ContinueStatement"
ForStatement = "ForStatement"
DependStatement = "DependStatement"
# Expressions
InfixExpression = "InfixExpression"
CallExpression = "CallExpression"
PrefixExpression = "PrefixExpression"
PostfixExpression = "PostfixExpression"
# Literals
IntegerLiteral = "IntegerLiteral"
@@ -295,7 +297,7 @@ class ContinueStatement(Statement):
}
class ForStatement(Statement):
def __init__(self, var_declaration: AssignmentStatement = None, condition: Expression = None, action: ReassignStatement = None, body: BlockStatement = None) -> None:
def __init__(self, var_declaration: AssignmentStatement = None, condition: Expression = None, action: Expression = None, body: BlockStatement = None) -> None:
self.var_declaration = var_declaration
self.condition = condition
self.action = action
@@ -309,7 +311,21 @@ class ForStatement(Statement):
"type": self.type().value,
"var_declaration": self.var_declaration.json(),
"condition": self.condition.json(),
"body": self.body.json()
"body": self.body.json(),
"action": self.action.json()
}
class DependStatement(Statement):
def __init__(self, file_path: str) -> None:
self.file_path = file_path
def type(self) -> NodeType:
return NodeType.DependStatement
def json(self) -> dict:
return {
"type": self.type().value,
"file_path": self.file_path
}
# endregion
@@ -360,4 +376,19 @@ class PrefixExpression(Expression):
"operator": self.operator,
"right_node": self.right_node.json()
}
class PostfixExpression(Expression):
def __init__(self, left_node: IdentifierLiteral, operator: str) -> None:
self.left_node = left_node
self.operator = operator
def type(self) -> NodeType:
return NodeType.PostfixExpression
def json(self) -> dict:
return {
"type": self.type().value,
"left_node": self.left_node.json(),
"operator": self.operator
}
# endregion