Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
1439eeed
Commit
1439eeed
authored
Mar 22, 2019
by
di68kap
Browse files
- Fehlerkorrektur
parent
a7a402d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/ebnf.py
View file @
1439eeed
...
...
@@ -93,7 +93,7 @@ from DHParser import logging, is_filename, load_if_file, \\
Node, TransformationFunc, TransformationDict, transformation_factory, traverse,
\\
remove_children_if, move_adjacent, normalize_whitespace, is_anonymous, matches_re,
\\
reduce_single_child, replace_by_single_child, replace_or_reduce, remove_whitespace,
\\
remove_empty, remove_tokens, flatten, is_insignificant_whitespace,
\\
replace_by_children,
remove_empty, remove_tokens, flatten, is_insignificant_whitespace,
\\
collapse, collapse_if, replace_content, WHITESPACE_PTYPE, TOKEN_PTYPE,
\\
remove_nodes, remove_content, remove_brackets, change_tag_name, remove_anonymous_tokens,
\\
keep_children, is_one_of, not_one_of, has_content, apply_if, remove_first, remove_last,
\\
...
...
DHParser/transform.py
View file @
1439eeed
...
...
@@ -631,11 +631,15 @@ def replace_by_single_child(context: List[Node]):
def
replace_by_children
(
context
:
List
[
Node
]):
"""
Eliminates the last node in the context by replacing it with its children.
The attributes of this node will be dropped.
The attributes of this node will be dropped. In case the last node is
the root-note (i.e. len(context) == 1), it will not be eliminated.
"""
try
:
parent
=
context
[
-
2
]
except
IndexError
:
return
node
=
context
[
-
1
]
assert
node
.
children
parent
=
context
[
-
2
]
result
=
parent
.
result
i
=
result
.
index
(
node
)
parent
.
result
=
result
[:
i
]
+
node
.
children
+
result
[
i
+
1
:]
...
...
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