2020-05-22 22:08:37 +02:00
|
|
|
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)
|
|
|
|
|
2020-09-17 19:33:52 +02:00
|
|
|
def interpret(self, line_str: str) -> None:
|
|
|
|
"""
|
|
|
|
Interprets code line
|
|
|
|
:param line_str:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
tokens = []
|
|
|
|
|
|
|
|
if self.__repo.is_error is None:
|
|
|
|
tokens = self.__lexer.tokenize(line_str)
|
|
|
|
|
|
|
|
if self.__repo.is_error is None:
|
|
|
|
self.__parser.parse(tokens)
|
|
|
|
|
|
|
|
# if self.__repo.is_error is None:
|
|
|
|
# self.__validator.validate(self.__repo.AST)
|