AST is working!!!!
This commit is contained in:
18
main.py
18
main.py
@@ -1,6 +1,10 @@
|
||||
from lexer import Lexer
|
||||
from plasma_parser import Parser
|
||||
from AST import Program
|
||||
import json
|
||||
|
||||
LEXER_DEBUG: bool = True
|
||||
PARSER_DEBUG: bool = True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -10,4 +14,16 @@ if __name__ == "__main__":
|
||||
if LEXER_DEBUG:
|
||||
debug_lex: Lexer = Lexer(source=code)
|
||||
while debug_lex.current_char is not None:
|
||||
print(debug_lex.next_token())
|
||||
print(debug_lex.next_token())
|
||||
|
||||
l: Lexer = Lexer(source=code)
|
||||
p: Parser = Parser(lexer=l)
|
||||
|
||||
if PARSER_DEBUG:
|
||||
print("===== PARSER DEBUG =====")
|
||||
program: Program = p.parse_program()
|
||||
|
||||
with open("debug/ast.json", "w") as f:
|
||||
json.dump(program.json(), f, indent=4)
|
||||
|
||||
print("Wrote AST to debug/ast.json successfully.")
|
||||
Reference in New Issue
Block a user