ITS GENERATING AN EXECUTABLE LETS GOOOO
This commit is contained in:
@@ -52,6 +52,9 @@ class LabelRefNode:
|
||||
@dataclass
|
||||
class LineRefNode:
|
||||
line: int
|
||||
@dataclass
|
||||
class BoolNode:
|
||||
value: bool
|
||||
|
||||
def generate_ast(tokens: list[Token], code: str) -> RootNode:
|
||||
root_node = RootNode([])
|
||||
@@ -97,6 +100,12 @@ def generate_ast(tokens: list[Token], code: str) -> RootNode:
|
||||
else:
|
||||
traceback(code, "SyntaxError", "Expected instruction, not string.")
|
||||
|
||||
elif token.type == TokenType.BOOL:
|
||||
if current_node_type == "inst":
|
||||
current_node.arguments.append(BoolNode(token.value))
|
||||
else:
|
||||
traceback(code, "SyntaxError", "Expected instruction, not string.")
|
||||
|
||||
elif token.type == TokenType.INTEGER or token.type == TokenType.FLOAT:
|
||||
if current_node_type == "inst":
|
||||
current_node.arguments.append(NumberNode(token.value))
|
||||
@@ -154,6 +163,9 @@ def generate_ast(tokens: list[Token], code: str) -> RootNode:
|
||||
|
||||
elif token.type == TokenType.LABEL_DECLERATION:
|
||||
scope.statements.append(LabelDecNode(token.value))
|
||||
|
||||
elif token.type == TokenType.COMMENT:
|
||||
continue
|
||||
|
||||
elif token.type == TokenType.EOF:
|
||||
root_node.statements.append(current_node)
|
||||
|
Reference in New Issue
Block a user