cclang/src/Interpreter/Utils.py

23 lines
583 B
Python
Raw Normal View History

from termcolor import colored
from Interpreter.Repo import Repo
2020-05-24 17:56:15 +02:00
from Models.Interpreter.Error import Error
class Utils:
def __init__(self, repo: Repo) -> None:
self.__repo = repo
2020-05-25 20:32:46 +02:00
self.line_number: int = 0
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()