瀏覽代碼

Change expand_kids_by_data to use range

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.12.0
Erez Sh 3 年之前
父節點
當前提交
4fe49c9cdb
共有 1 個檔案被更改,包括 3 行新增3 行删除
  1. +3
    -3
      lark/tree.py

+ 3
- 3
lark/tree.py 查看文件

@@ -110,9 +110,9 @@ class Tree(object):
def expand_kids_by_data(self, *data_values):
"""Expand (inline) children with any of the given data values. Returns True if anything changed"""
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
changed = True
return changed


Loading…
取消
儲存