cclang/src/Interpreter/Interpreter.py

29 lines
806 B
Python
Raw Normal View History

from Interpreter.Validator import Validator
from Interpreter.Lexer import Lexer
from Interpreter.Parser import Parser
from Interpreter.Repo import Repo
from Interpreter.Utils import Utils
class Interpreter:
def __init__(self, repo: Repo, utils: Utils) -> None:
self.__repo = repo
self.__utils = utils
self.__lexer = Lexer(repo, utils)
self.__parser = Parser(repo, utils)
self.__validator = Validator(repo, utils)
def interpret(self, line: str) -> bool:
toks = []
if self.__repo.error is None:
toks = self.__lexer.tokenize(line)
if self.__repo.error is None:
self.__parser.parse(toks)
if self.__repo.error is None:
self.__validator.validate()
return self.__repo.error is None