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