32 lines
782 B
Python
32 lines
782 B
Python
from src.ast.stmt import Stmt
|
|
from src.interpreter.interpreter import Interpreter
|
|
from src.lexer import Lexer
|
|
from src.parser.parser import Parser
|
|
from src.token import Token
|
|
|
|
|
|
def main():
|
|
source: str = """() {} +- += / /= // sefs + {, )
|
|
}:: *
|
|
"This is a string"
|
|
3.1415
|
|
123
|
|
"This is
|
|
another string" """
|
|
path: str = "examples/10_while.peb"
|
|
with open(path, "r") as f:
|
|
source = f.read()
|
|
lexer: Lexer = Lexer()
|
|
tokens: list[Token] = lexer.process(source, path)
|
|
print(list(filter(lambda t: t.type not in Parser.IGNORE, tokens)))
|
|
|
|
parser: Parser = Parser()
|
|
program: list[Stmt] = parser.parse(tokens)
|
|
|
|
interpreter: Interpreter = Interpreter()
|
|
interpreter.interpret(program)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|