fixes
This commit is contained in:
@@ -21,9 +21,13 @@ class Interpreter:
|
||||
if self.__repo.error is None:
|
||||
toks = self.__lexer.tokenize(line_str)
|
||||
|
||||
self.__repo.output_tokens(toks)
|
||||
|
||||
if self.__repo.error is None:
|
||||
self.__parser.parse(toks)
|
||||
|
||||
self.__repo.output_ast()
|
||||
|
||||
if self.__repo.error is None:
|
||||
self.__validator.validate()
|
||||
|
||||
|
@@ -134,5 +134,4 @@ class Lexer:
|
||||
if line[i - 1] == '*' and c == '/':
|
||||
self.__ml_comment = False
|
||||
|
||||
# self.__repo.output_tokens(self.__toks)
|
||||
return self.__toks
|
||||
|
@@ -74,6 +74,16 @@ class Parser:
|
||||
else:
|
||||
return Token('EOL', 'EOL')
|
||||
|
||||
def __add_ast(self, tok: Token) -> None:
|
||||
if self.__lib is not None and self.__class is None and self.__func is None:
|
||||
self.__lib.ast.append(tok)
|
||||
|
||||
elif self.__lib is not None and self.__class is not None and self.__func is None:
|
||||
self.__class.ast.append(tok)
|
||||
|
||||
elif self.__lib is not None and self.__class is not None and self.__func is not None:
|
||||
self.__func.ast.append(tok)
|
||||
|
||||
def __is_scope_started(self) -> bool:
|
||||
return self.__is_start_lib or self.__is_start_class or self.__is_start_func
|
||||
|
||||
|
@@ -58,3 +58,13 @@ class Repo:
|
||||
|
||||
print(outp_toks)
|
||||
# print('\n')
|
||||
|
||||
def output_ast(self) -> None:
|
||||
if len(self.ast) > 0:
|
||||
outp_toks = []
|
||||
for tok in self.ast:
|
||||
outp_toks.append({tok.value: tok.type})
|
||||
# print({tok.value: tok.type})
|
||||
|
||||
print(outp_toks)
|
||||
# print('\n')
|
||||
|
Reference in New Issue
Block a user