Commit d1297425 authored by di68kap's avatar di68kap

- Fehler in DHParser/parser.py : yet another testing artifact error case;...

- Fehler in DHParser/parser.py : yet another testing artifact error case; still needs unit-test and support in testing.py
parent 257b0ada
...@@ -86,6 +86,7 @@ class Error: ...@@ -86,6 +86,7 @@ class Error:
PARSER_DID_NOT_MATCH = ErrorCode(1020) PARSER_DID_NOT_MATCH = ErrorCode(1020)
PARSER_LOOKAHEAD_MATCH_ONLY = ErrorCode(1030) PARSER_LOOKAHEAD_MATCH_ONLY = ErrorCode(1030)
PARSER_STOPPED_BEFORE_END = ErrorCode(1040) PARSER_STOPPED_BEFORE_END = ErrorCode(1040)
PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD = ErrorCode(1045)
CAPTURE_STACK_NOT_EMPTY = ErrorCode(1050) CAPTURE_STACK_NOT_EMPTY = ErrorCode(1050)
MALFORMED_ERROR_STRING = ErrorCode(1060) MALFORMED_ERROR_STRING = ErrorCode(1060)
AMBIGUOUS_ERROR_HANDLING = ErrorCode(1070) AMBIGUOUS_ERROR_HANDLING = ErrorCode(1070)
......
...@@ -994,13 +994,19 @@ class Grammar: ...@@ -994,13 +994,19 @@ class Grammar:
error_code = Error.PARSER_DID_NOT_MATCH error_code = Error.PARSER_DID_NOT_MATCH
else: else:
stitches.append(result) stitches.append(result)
error_msg = "Parser stopped before end" \ h = self.history__[-1]
+ (("! trying to recover" if h.status == h.MATCH and (h.node.pos + len(h.node) == len(self.document__)):
+ (" but stopping history recording at this point." # TODO: this case still needs unit-test and support in testing.py
if self.history_tracking__ else "...")) error_msg = "Parser stopped before end, but matched with lookahead."
if len(stitches) < self.max_parser_dropouts__ error_code = Error.PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD
else " too often! Terminating parser.") else:
error_code = Error.PARSER_STOPPED_BEFORE_END error_msg = "Parser stopped before end" \
+ (("! trying to recover"
+ (" but stopping history recording at this point."
if self.history_tracking__ else "..."))
if len(stitches) < self.max_parser_dropouts__
else " too often! Terminating parser.")
error_code = Error.PARSER_STOPPED_BEFORE_END
stitches.append(Node(ZOMBIE_TAG, skip).with_pos(tail_pos(stitches))) stitches.append(Node(ZOMBIE_TAG, skip).with_pos(tail_pos(stitches)))
self.tree__.new_error(stitches[-1], error_msg, error_code) self.tree__.new_error(stitches[-1], error_msg, error_code)
if self.history_tracking__: if self.history_tracking__:
......
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