2020-05-22 22:08:37 +02:00
|
|
|
from termcolor import colored
|
|
|
|
|
|
|
|
from Interpreter.Repo import Repo
|
2020-05-24 17:56:15 +02:00
|
|
|
from Models.Interpreter.Error import Error
|
2020-05-22 22:08:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Utils:
|
|
|
|
|
|
|
|
def __init__(self, repo: Repo) -> None:
|
|
|
|
self.__repo = repo
|
2020-05-25 20:32:46 +02:00
|
|
|
self.line_number: int = 0
|
2020-05-22 22:08:37 +02:00
|
|
|
|
|
|
|
def input(self, prefix: str) -> str:
|
|
|
|
return input(prefix)
|
|
|
|
|
|
|
|
def output(self, text: str) -> None:
|
|
|
|
print(f'-> {text}')
|
|
|
|
|
2020-05-24 17:56:15 +02:00
|
|
|
def error(self, error: Error) -> None:
|
|
|
|
self.__repo.error = error
|
2020-05-25 20:32:46 +02:00
|
|
|
print(colored(f'Error in line {self.line_number}\n{self.__repo.error.code}: {self.__repo.error.msg}', 'red'))
|
|
|
|
# exit()
|