Working on #48 : Working
This commit is contained in:
+15
-31
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user