05.11., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 005647c1 authored by di68kap's avatar di68kap

- TODO-notices added (new error_resuming behaviour, mandatory items for...

- TODO-notices added (new error_resuming behaviour, mandatory items for AllOf-Operator, error reporting fo ambiguous error configurations)
parent 6be46d0e
......@@ -938,12 +938,12 @@ class EBNFCompiler(Compiler):
# add custom error message if it has been declared for the currend definition
if custom_args:
current_symbol = next(reversed(self.rules.keys()))
# msgs = self.directives['error'].get(current_symbol, [])
# if msgs:
if current_symbol in self.directives['error']:
# use class field instead or direct representation of error messages!
custom_args.append('err_msgs=' + current_symbol + self.ERR_MSG_SUFFIX)
compiled = self.non_terminal(node, 'Series', custom_args)
# TODO: Maybe add a warning about ambiguous error messages in case there are several
# Series with mandatory items within the definiens of the same symbol?
node.result = saved_result
return compiled
......
......@@ -1409,17 +1409,9 @@ class Series(NaryOperator):
if pos < self.mandatory:
return None, text
else:
# Provide useful error messages
# TODO: Change to accomodate to resuming after errors are caught.
# match = text.search(Series.RX_ARGUMENT)
# i = max(1, text.index(match.regs[1][0])) if match else 1
i = 0
location = self.grammar.document_length__ - len(text_)
node = Node(None, text_[:i]).init_pos(location)
# self.grammar.tree__.add_error(
# node, Error("§ %s violation" % parser.repr, location, Error.MESSAGE))
# # node.errors.append(Error("§ %s violation" % parser.repr,
# # location, Error.MESSAGE))
found = text_[:10].replace('\n', '\\n ')
for search, message in self.err_msgs:
rxs = not isinstance(search, str)
......@@ -1440,6 +1432,7 @@ class Series(NaryOperator):
self.grammar.tree__.add_error(node, mandatory_violation)
text_ = text_[i:]
results += (node,)
# TODO: Add queue-jumping here (XXX_skip = Regex, Regex, Regex...)
break
results += (node,)
# if node.error_flag: # break on first error
......@@ -1590,6 +1583,7 @@ class AllOf(NaryOperator):
parsers = series.parsers
super().__init__(*parsers)
# TODO: Add check for mandatory items here, just like with Series-Operator
def __call__(self, text: StringView) -> Tuple[Optional[Node], StringView]:
results = () # type: Tuple[Node, ...]
text_ = text # type: StringView
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment