[DevState] Added and tested with python sly
This commit is contained in:
		| @@ -2,7 +2,6 @@ from typing import Optional | ||||
|  | ||||
| from Interpreter.Validator import Validator | ||||
| from Interpreter.Lexer import Lexer | ||||
| # from Interpreter.Parser_Old import Parser | ||||
| from Interpreter.Parser import Parser | ||||
| from Interpreter.Repo import Repo | ||||
| from Interpreter.Utils import Utils | ||||
| @@ -27,10 +26,10 @@ class Interpreter: | ||||
|         tokens = [] | ||||
|         ast: Optional[AbstractSyntaxTree] = None | ||||
|  | ||||
|         if self.__repo.is_error is None: | ||||
|         if self.__repo.error is None: | ||||
|             tokens = self.__lexer.tokenize(line_str) | ||||
|  | ||||
|         if self.__repo.is_error is None: | ||||
|         if self.__repo.error is None: | ||||
|             ast = self.__parser.parse(tokens) | ||||
|  | ||||
|         """ print('#####\n') | ||||
|   | ||||
| @@ -70,4 +70,4 @@ class Repo: | ||||
|         self.bool_values = [Booleans.Right.value, Booleans.Wrong.value] | ||||
|  | ||||
|         # runtime | ||||
|         self.is_error = None | ||||
|         self.error = None | ||||
|   | ||||
| @@ -16,6 +16,11 @@ class Utils: | ||||
|         print(f'-> {text}') | ||||
|  | ||||
|     def error(self, error: Error) -> None: | ||||
|         self.__repo.is_error = error | ||||
|         print(colored(f'Error in line {self.__repo.line_number}\n{self.__repo.is_error.msg}', 'red')) | ||||
|         self.__repo.error = error | ||||
|         print(colored(f'Error in line {self.__repo.line_number}\n{self.__repo.error.msg}', 'red')) | ||||
|         # exit() | ||||
|  | ||||
|     def runtime_error(self, error: Error) -> None: | ||||
|         self.__repo.error = error | ||||
|         print(colored(f'{self.__repo.error.msg}', 'red')) | ||||
|         # exit() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user