Commit 3286cce7 authored by di68kap's avatar di68kap

- error.py: renamed some error messages

parent 98af2bfc
......@@ -84,9 +84,9 @@ class Error:
MANDATORY_CONTINUATION = ErrorCode(1010)
MANDATORY_CONTINUATION_AT_EOF = ErrorCode(1015)
PARSER_DID_NOT_MATCH = ErrorCode(1020)
PARSER_LOOKAHEAD_MATCH_ONLY = ErrorCode(1030)
PARSER_LOOKAHEAD_FAILURE_ONLY = ErrorCode(1030)
PARSER_STOPPED_BEFORE_END = ErrorCode(1040)
PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD = ErrorCode(1045)
PARSER_LOOKAHEAD_MATCH_ONLY = ErrorCode(1045)
CAPTURE_STACK_NOT_EMPTY = ErrorCode(1050)
MALFORMED_ERROR_STRING = ErrorCode(1060)
AMBIGUOUS_ERROR_HANDLING = ErrorCode(1070)
......
......@@ -968,7 +968,7 @@ class Grammar:
self.tree__.new_error(
result, 'Parser "%s" only did not match empty document '
'because of lookahead' % str(parser),
Error.PARSER_LOOKAHEAD_MATCH_ONLY)
Error.PARSER_LOOKAHEAD_FAILURE_ONLY)
else:
self.tree__.new_error(
result, 'Parser "%s" did not match empty document.' % str(parser),
......@@ -991,7 +991,7 @@ class Grammar:
if lookahead_failure_only(parser):
error_msg = 'Parser "%s" only did not match because of lookahead! ' \
% str(parser) + err_info
error_code = Error.PARSER_LOOKAHEAD_MATCH_ONLY
error_code = Error.PARSER_LOOKAHEAD_FAILURE_ONLY
else:
error_msg = 'Parser "%s" did not match!' % str(parser) + err_info
error_code = Error.PARSER_DID_NOT_MATCH
......@@ -1002,7 +1002,7 @@ class Grammar:
if h.status == h.MATCH and (h.node.pos + len(h.node) == len(self.document__)):
# TODO: this case still needs unit-tests and support in testing.py
error_msg = "Parser stopped before end, but matched with lookahead."
error_code = Error.PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD
error_code = Error.PARSER_LOOKAHEAD_MATCH_ONLY
max_parser_dropouts = -1 # no further retries!
else:
error_msg = "Parser stopped before end" \
......
......@@ -353,11 +353,11 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report='REPORT'
raw_errors = syntax_tree.errors_sorted
is_artifact = ((2 <= len(raw_errors) == 3 # case 1: superfluous data for lookahead
and {e.code for e in raw_errors} <=
{Error.PARSER_LOOKAHEAD_MATCH_ONLY,
# Error.PARSER_STOPPED_BEFORE_END,
Error.PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD})
{Error.PARSER_LOOKAHEAD_FAILURE_ONLY,
# Error.PARSER_STOPPED_BEFORE_END,
Error.PARSER_LOOKAHEAD_MATCH_ONLY})
or (len(raw_errors) == 1
and (raw_errors[-1].code == Error.PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD
and (raw_errors[-1].code == Error.PARSER_LOOKAHEAD_MATCH_ONLY
# case 2: mandatory lookahead failure at end of text
or raw_errors[-1].code == Error.MANDATORY_CONTINUATION_AT_EOF)))
if is_artifact:
......
......@@ -313,8 +313,8 @@ class TestLookahead:
gr = self.grammar_fac()
# Case 1: Lookahead string is part of the test case; parser fails but for the lookahead
result = gr(self.cases['category']['match'][1], 'category', True)
assert any(e.code in (Error.PARSER_LOOKAHEAD_MATCH_ONLY,
Error.PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD)
assert any(e.code in (Error.PARSER_LOOKAHEAD_FAILURE_ONLY,
Error.PARSER_LOOKAHEAD_MATCH_ONLY)
for e in result.errors)
# Case 2: Lookahead string is not part of the test case; parser matches but for the mandatory continuation
result = gr(self.cases['category']['match'][2], 'category', True)
......
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