Commit 49f47560 authored by di68kap's avatar di68kap
Browse files

- ineptus weiterbearbeitet

parent 1a4774ff
......@@ -729,6 +729,27 @@ def normalize_whitespace(context):
node.result = re.sub(r'\s+', ' ', node.result)
def merge_whitespace(context):
"""
Merges adjacent whitespace. UNTESTED!
"""
node = context[-1]
children = node.children
new_result = []
i = 0
L = len(children)
while i < L:
if children[i].parser.pytpe == WHITESPACE_PTYPE:
k = i
while i < L and children[k].parser.ptype == WHITESPACE_PTYPE:
i += 1
if i > k:
children[k].result = sum(children[n].result for n in range(k, i + 1))
new_result.append(children[k])
i += 1
node.result = tuple(new_result)
def move_whitespace(context):
"""
Moves adjacent whitespace nodes to the parent node.
......
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