Working on #48 : Working

This commit is contained in:
2021-03-11 15:28:24 +01:00
parent 8f51893f53
commit 30c99b2d67
14 changed files with 60 additions and 55 deletions
+15 -31
View File
@@ -9,6 +9,21 @@ from core.sheerka.services.SheerkaExecute import ParserInput
from core.tokenizer import TokenKind, Token, LexerError
class ErrorSink:
def __init__(self):
self.sink = []
def add_error(self, error):
self.sink.append(error)
def clear(self):
self.sink.clear()
@property
def has_error(self):
return len(self.sink) > 0
@dataclass()
class Node:
pass
@@ -244,34 +259,3 @@ class BaseParserInputParser(BaseParser):
return list_a
class BaseExprParser(BaseParser):
def parse_input(self, context, parser_input, error_sink):
raise NotImplementedError
def reset_parser_input(self, parser_input: ParserInput, error_sink):
try:
error_sink.clear()
parser_input.reset(self.yield_eof)
except LexerError as e:
error_sink.add_error(e)
return False
parser_input.next_token()
return True
class ErrorSink:
def __init__(self):
self.sink = []
def add_error(self, error):
self.sink.append(error)
def clear(self):
self.sink.clear()
@property
def has_error(self):
return len(self.sink) > 0