Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
The container registry cleanup task is now completed and the registry can be used normally.
Open sidebar
badw-it
DHParser
Commits
e0f50929
Commit
e0f50929
authored
Dec 02, 2019
by
eckhart
Browse files
minor changes...
parent
97c6aed7
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/parse.py
View file @
e0f50929
...
...
@@ -47,6 +47,9 @@ from DHParser.toolkit import sane_parser_name, escape_control_characters, re, cy
__all__
=
(
'ParserError'
,
'ApplyFunc'
,
'FlagFunc'
,
'ParseFunc'
,
'Parser'
,
'UnknownParserError'
,
'GrammarErrorType'
,
...
...
DHParser/trace.py
View file @
e0f50929
...
...
@@ -35,7 +35,7 @@ from DHParser.stringview import StringView
from
DHParser.syntaxtree
import
Node
,
REGEXP_PTYPE
,
TOKEN_PTYPE
,
WHITESPACE_PTYPE
,
\
EMPTY_PTYPE
,
EMPTY_NODE
from
DHParser.log
import
HistoryRecord
from
DHParser.parse
import
Parser
,
ParserError
,
ParseFunc
from
DHParser.parse
import
Grammar
,
Parser
,
ParserError
,
ParseFunc
__all__
=
(
'trace_history'
,
'with_all_descendants'
,
'with_unnamed_descendants'
,
'set_tracer'
)
...
...
@@ -78,6 +78,7 @@ def trace_history(self, text: StringView) -> Tuple[Optional[Node], StringView]:
def
with_all_descendants
(
root
:
Parser
)
->
List
[
Parser
]:
"""Returns a list with the parser `root` and all of its descendants."""
descendants
=
[]
def
visit
(
parser
:
Parser
):
descendants
.
append
(
parser
)
root
.
apply
(
visit
)
...
...
@@ -93,10 +94,18 @@ def with_unnamed_descendants(root: Parser) -> List[Parser]:
return
descendants
def
set_tracer
(
parsers
:
Union
[
Parser
,
Collection
[
Parser
]],
tracer
:
Optional
[
ParseFunc
]):
if
isinstance
(
parsers
,
Parser
):
def
set_tracer
(
parsers
:
Union
[
Grammar
,
Parser
,
Collection
[
Parser
]],
tracer
:
Optional
[
ParseFunc
]):
if
isinstance
(
parsers
,
Grammar
):
parsers
=
parsers
.
all_parsers__
elif
isinstance
(
parsers
,
Parser
):
parsers
=
[
parsers
]
for
parser
in
parsers
:
if
parser
.
ptype
!=
':Forward'
:
parser
.
set_proxy
(
tracer
)
if
parsers
:
assert
all
(
parsers
[
0
].
grammar
==
parser
.
grammar
for
parser
in
parsers
)
parsers
[
0
].
grammar
.
history_tracking__
=
True
for
parser
in
parsers
:
if
parser
.
ptype
!=
':Forward'
:
parser
.
set_proxy
(
tracer
)
def
resume_notices
(
grammar
:
Grammar
):
pass
Write
Preview
Supports
Markdown
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