|parrotcode: a base class for syntax tree nodes|
|Contents | Compilers|
Node - a base class for syntax tree nodes
All PAST and POST nodes subclass from this base type.
These methods define the external interface of node objects.
Sets or gets the source code string that a particular node was parsed from. (Useful for debugging output.)
node.'source'($S1) $S2 = node.'source'()
Sets or gets the position offset in the original source code file that a particular node was parsed from. (Useful for debugging output.)
node.'pos'($I1) $S2 = node.'pos'()
Returns a simple array of the children of a particular node.
$P1 = node.'children'()
Returns an iterator for the children of a node.
iter = node.'child_iter'()
Adds one child to the node's list of children. If the list doesn't exist yet, it creates it.
Check how many elements a node has by calling the
elements opcode on it:
$I1 = elements node
The children of a node can be directly accessed using array indexes on the node object.
$P2 = node node = $P1
This method captures a few key elements from an existing node to populate a new node.
Recursively prints a formatted display of the contents of a node.
These methods provide functionality for the Node class and its subclasses, but aren't part of the external interface for the class.
This method returns a list of attributes that should be displayed in a 'dump' operation. Subclasses can override it to return a different list.
Provides a generic accessor method that can be used by any subclass. It takes three arguments: the name of the attribute to access, a value for the attribute, and a binary flag that says whether to set the attribute.
self.'accessor'('attrname', value, setflag)