Browse Source

Change expand_kids_by_data to use range

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.12.0
Erez Sh 3 years ago
parent
commit
4fe49c9cdb
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      lark/tree.py

+ 3
- 3
lark/tree.py View File

@@ -110,9 +110,9 @@ class Tree(object):
def expand_kids_by_data(self, *data_values): def expand_kids_by_data(self, *data_values):
"""Expand (inline) children with any of the given data values. Returns True if anything changed""" """Expand (inline) children with any of the given data values. Returns True if anything changed"""
changed = False changed = False
for i, c in reversed(list(enumerate(self.children))):
if isinstance(c, Tree) and c.data in data_values:
child = self.children[i]
for i in range(len(self.children)-1, -1, -1):
child = self.children[i]
if isinstance(child, Tree) and child.data in data_values:
self.children[i:i+1] = child.children self.children[i:i+1] = child.children
changed = True changed = True
return changed return changed


Loading…
Cancel
Save