VARIABLESSSS
This commit is contained in:
32
main.py
32
main.py
@@ -1,14 +1,20 @@
|
||||
from lexer import Lexer
|
||||
from plasma_parser import Parser
|
||||
from compiler import Compiler
|
||||
from AST import Program
|
||||
import json
|
||||
|
||||
LEXER_DEBUG: bool = True
|
||||
PARSER_DEBUG: bool = True
|
||||
from llvmlite import ir
|
||||
from llvmlite.binding import targets
|
||||
from ctypes import CFUNCTYPE, c_int, c_float
|
||||
|
||||
LEXER_DEBUG: bool = False
|
||||
PARSER_DEBUG: bool = False
|
||||
COMPILER_DEBUG: bool = True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open("tests/parser.pla") as f:
|
||||
with open("tests/test.pla") as f:
|
||||
code: str = f.read()
|
||||
|
||||
if LEXER_DEBUG:
|
||||
@@ -19,11 +25,27 @@ if __name__ == "__main__":
|
||||
l: Lexer = Lexer(source=code)
|
||||
p: Parser = Parser(lexer=l)
|
||||
|
||||
program: Program = p.parse_program()
|
||||
if len(p.errors) > 0:
|
||||
for err in p.errors:
|
||||
print(err)
|
||||
exit(1)
|
||||
|
||||
if PARSER_DEBUG:
|
||||
print("===== PARSER DEBUG =====")
|
||||
program: Program = p.parse_program()
|
||||
#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.")
|
||||
print("Wrote AST to debug/ast.json successfully.")
|
||||
|
||||
c: Compiler = Compiler()
|
||||
c.compile(program)
|
||||
|
||||
module: ir.Module = c.module
|
||||
module.triple = targets.get_default_triple()
|
||||
|
||||
if COMPILER_DEBUG:
|
||||
with open("debug/ir.ll", "w") as f:
|
||||
f.write(str(module))
|
||||
Reference in New Issue
Block a user