35 lines
948 B
Python
35 lines
948 B
Python
from src.ast.stmt import Stmt
|
|
from src.formatter import Formatter
|
|
from src.interpreter.interpreter import Interpreter
|
|
from src.interpreter.resolver import Resolver
|
|
from src.lexer import Lexer
|
|
from src.parser.parser import Parser
|
|
from src.token import Token
|
|
|
|
|
|
def main():
|
|
path: str = "examples/15_resolution.peb"
|
|
source: str = ""
|
|
with open(path, "r") as f:
|
|
source = f.read()
|
|
lexer: Lexer = Lexer(source, path)
|
|
tokens: list[Token] = lexer.process()
|
|
print(list(filter(lambda t: t.type not in Parser.IGNORE, tokens)))
|
|
|
|
parser: Parser = Parser(tokens)
|
|
program: list[Stmt] = parser.parse()
|
|
|
|
interpreter: Interpreter = Interpreter()
|
|
resolver: Resolver = Resolver(interpreter)
|
|
|
|
resolver.resolve(*program)
|
|
interpreter.interpret(program)
|
|
|
|
formatter: Formatter = Formatter()
|
|
with open("formatted.peb", "w") as f:
|
|
f.write(formatter.print(program))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|