Methods
find_data()
Returns all nodes of the tree whose data equals the given data.
find_data()
Returns all nodes of the tree whose data equals the given data.
find_pred()
Returns all nodes of the tree that evaluate pred(node) as true.
find_pred()
Returns all nodes of the tree that evaluate pred(node) as true.
iter_subtrees()
Depth-first iteration.
Iterates over all the subtrees, never returning to the same node twice (Lark's parse-tree is actually a DAG).
iter_subtrees()
Depth-first iteration.
Iterates over all the subtrees, never returning to the same node twice (Lark's parse-tree is actually a DAG).
(generator) iter_subtrees_topdown()
Breadth-first iteration.
Iterates over all the subtrees, return nodes in order like pretty() does.
(generator) iter_subtrees_topdown()
Breadth-first iteration.
Iterates over all the subtrees, return nodes in order like pretty() does.
pretty()
Returns an indented string representation of the tree.
Great for debugging.
pretty()
Returns an indented string representation of the tree.
Great for debugging.
(generator) scan_values()
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))