Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
07cf20fd
Commit
07cf20fd
authored
Jul 04, 2021
by
Eckhart Arnold
Browse files
parse.py: reentry_point() refactored
parent
ea695bb6
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/ebnf.py
View file @
07cf20fd
...
...
@@ -3143,7 +3143,7 @@ class EBNFCompiler(Compiler):
refined = self.gen_search_rule(nd)
except IndexError:
nd = self.tree # TODO: Allow arbitrary parsers, here
refined =
""
refined =
'' # refined = rule
except KeyError:
# rule represents a procedure name
nd = self.tree
...
...
tests/test_ebnf.py
View file @
07cf20fd
...
...
@@ -888,6 +888,51 @@ class TestCustomizedResumeParsing:
st
=
grammar
(
doc3
)
assert
st
.
children
and
st
.
children
[
-
1
].
tag_name
==
'word'
class
TestCustomizedResumeParsing_with_Parsers
:
lang
=
r
"""@ literalws = right
@ alpha_resume = ALPHA_RESUME
@ beta_resume = GAMMA_RE
@ bac_resume = /(?=GA\w+)/
document = alpha [beta] gamma "."
alpha = "ALPHA" abc
abc = §"a" "b" "c"
beta = "BETA" (bac | bca)
bac = "b" "a" §"c"
bca = "b" "c" §"a"
gamma = "GAMMA" §(cab | cba)
cab = "c" "a" §"b"
cba = "c" "b" §"a"
GAMMA_RE = /(?=GA\w+)/
ALPHA_RESUME = { !`BETA` !`GAMMA` /./ }
"""
gr
=
grammar_provider
(
lang
)()
def
test_several_resume_rules_innermost_rule_matching
(
self
):
gr
=
self
.
gr
content
=
'ALPHA abc BETA bad GAMMA cab .'
cst
=
gr
(
content
)
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
# because of resuming, there should be only on error message
assert
len
(
cst
.
errors_sorted
)
==
1
content
=
'ALPHA acb BETA bad GAMMA cab .'
cst
=
gr
(
content
)
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
# because of resuming, there should be only on error message
assert
len
(
cst
.
errors_sorted
)
==
2
content
=
'ALPHA acb GAMMA cab .'
cst
=
gr
(
content
)
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
# because of resuming, there should be only on error message
assert
len
(
cst
.
errors_sorted
)
==
1
class
TestInSeriesResume
:
def
setup
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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