parrotcode: base class for PAST and POST nodes | |
Contents | Compilers |
PCT::Node - base class for PAST and POST nodes
This file implements the base class for abstract syntax tree (PAST) and opcode syntax tree (POST) nodes in the Parrot Compiler Toolkit.
PCT::Node
is the base class for all PAST and POST nodes.
It's derived from class Capture
,
so that it has both array and hash components.
The array component is used to maintain a node's children,
while the hash component contains the attributes of the node.
In general we provide and use accessor methods for a node's attributes,
instead of accessing the hash component directly.
Every PAST/POST node has name
,
source
,
and pos
attributes.
The name
attribute is the node's name,
if any,
while source
and pos
are used to identify the location in the original source code for the node.
The source
and pos
values are generally set by the node
method below.
Other node attributes are generally defined by subclasses of PCT::Node
.
push
method,
below) and calls the appropriate accessor method for each attribute.
And returns the node.child
to the beginning of the invocant's list of children.child
to the end of the invocant's list of children.class
,
initializes it with the given children and attributes,
and adds it to the end of the invocant's array of children.
Returns the newly created node.source
and pos
attributes to those of val
.
If val
is another PAST node,
then source
and pos
are simply copied from that node,
otherwise val
is assumed to be a Match
object and obtains source/position information from that.name
attribute of the invocant.has_value
is true then set the invocant's value of attrname
to value
.
Returns the (resulting) value of attrname
in the invocant.fmt
is provided,
then it will be used as a prefix to the unique number.Patrick Michaud <pmichaud@pobox.com> is the author and maintainer. Please send patches and suggestions to the Parrot porters or Perl 6 compilers mailing lists.
2006-11-20 Patrick Michaud added first draft of POD documentation. 2007-11-21 Re-implementation with pdd26 compliance, compiler toolkit 2007-12-07 Refactor PAST::Node into separate PCT::Node component.
Copyright (C) 2006-2007, The Perl Foundation.
|