Matt S Trout > Rakudo-Star-2012.08_001 > TGE::Tree


Annotate this POD



TGE::Tree - The top-level node of every tree.


A TGE::Tree is the core object at the center of every tree transformation. You can think of it as something like a PGE::Match object. The first step of applying every tree grammar is to create a TGE::Tree object and wrap it around the tree being transformed. The TGE::Tree object handles result caching for particular transform rules on particular nodes, maintains connections between particular nodes and the transforms that can apply to those nodes, and will eventually handle indexing for faster tree searches.


Returns a simple initialized TGE::Tree object. Doesn't accept any constructor parameters.


  value = Tree.get('attrname')

Fetches the value of a particular attribute from the root node of the grammar.

  value = Tree.get('attrname', node)
  value = Tree.get('attrname', node, 'type')

Fetches the value of a particular attribute from the node passed in. When working with a tree where the nodes don't know their type (PGE match objects, for example), you must also tell get the type of the node.

syntax highlighting: