buildTree(tree,
context,
pathFunctions={ } ,
nameFunctions={ } ,
typeFunctions={ } )
| source code
|
traverses tree, calling functions on nodes.
pathFunctions is a dictionary mapping complete paths (i.e., tuples of
node labels) to handler functions, nameFunctions name a single label and
are called for nodes that don't match a pathFunction if the last item of
their paths is the label. Both of these currently are not used.
Instead, everything hinges on the fallback, which is a node's type value
(generated from the key words), matched against typeFunctions.
The handler functions must be iterators. If they yield anything, it
must be key-value pairs.
All key-value pairs are collected in a dictionary that is then
returned. If value is a tuple, it is appended to the current value for
the key.
Context is an arbitrary object containing ancillary information for
building nodes. What's in there and what's not is up to the functions
and their callers.
|