Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
DHParser
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
badw-it
DHParser
Commits
b5fa4569
Commit
b5fa4569
authored
May 17, 2019
by
di68kap
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/development' into development
parents
0b2955e2
c265ccda
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
DHParser/parse.py
DHParser/parse.py
+4
-1
DHParser/testing.py
DHParser/testing.py
+5
-4
test/test_testing.py
test/test_testing.py
+3
-1
No files found.
DHParser/parse.py
View file @
b5fa4569
...
...
@@ -974,7 +974,9 @@ class Grammar:
result
,
'Parser "%s" did not match empty document.'
%
str
(
parser
),
Error
.
PARSER_DID_NOT_MATCH
)
while
rest
and
len
(
stitches
)
<
self
.
max_parser_dropouts__
:
# copy to local variable, so break condition can be triggered manually
max_parser_dropouts
=
self
.
max_parser_dropouts__
while
rest
and
len
(
stitches
)
<
max_parser_dropouts
:
result
,
rest
=
parser
(
rest
)
if
rest
:
fwd
=
rest
.
find
(
"
\n
"
)
+
1
or
len
(
rest
)
...
...
@@ -1000,6 +1002,7 @@ class Grammar:
# 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
max_parser_dropouts
=
-
1
# no further retries!
else
:
error_msg
=
"Parser stopped before end"
\
+
((
"! trying to recover"
...
...
DHParser/testing.py
View file @
b5fa4569
...
...
@@ -351,14 +351,15 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report=True, ve
operator at the end. See test_testing.TestLookahead.
"""
raw_errors
=
syntax_tree
.
errors_sorted
is_artifact
=
((
2
<=
len
(
raw_errors
)
<
=
3
# case 1: superfluous data for lookahead
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_BEFORE_END,
Error
.
PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD
})
# case 3: mandatory lookahead failure at end of text
or
(
len
(
raw_errors
)
==
1
and
raw_errors
[
-
1
].
code
==
Error
.
MANDATORY_CONTINUATION_AT_EOF
))
and
(
raw_errors
[
-
1
].
code
==
Error
.
PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD
# case 2: mandatory lookahead failure at end of text
or
raw_errors
[
-
1
].
code
==
Error
.
MANDATORY_CONTINUATION_AT_EOF
)))
if
is_artifact
:
# don't remove zombie node with error message at the end
# but change it's tag_name to indicate that it is an artifact!
...
...
test/test_testing.py
View file @
b5fa4569
...
...
@@ -312,7 +312,9 @@ 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
==
Error
.
PARSER_LOOKAHEAD_MATCH_ONLY
for
e
in
result
.
errors
)
assert
any
(
e
.
code
in
(
Error
.
PARSER_LOOKAHEAD_MATCH_ONLY
,
Error
.
PARSER_STOPPED_EXCEPT_FOR_LOOKAHEAD
)
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
)
assert
any
(
e
.
code
==
Error
.
MANDATORY_CONTINUATION_AT_EOF
for
e
in
result
.
errors
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment