Преглед на файлове

Docs: Added docstring to Tree.scan_values()

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.3
Erez Sh преди 3 години
родител
ревизия
206030ecf7
променени са 1 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. +7
    -0
      lark/tree.py

+ 7
- 0
lark/tree.py Целия файл

@@ -108,6 +108,13 @@ class Tree(object):
self.children[i:i+1] = kid.children

def scan_values(self, pred):
"""Return all values in the tree that evaluate pred(value) as true.

This can be used to find all the tokens in the tree.

Example:
>>> all_tokens = tree.scan_values(lambda v: isinstance(v, Token))
"""
for c in self.children:
if isinstance(c, Tree):
for t in c.scan_values(pred):


Зареждане…
Отказ
Запис