parrotcode: NCIGEN abstract syntax tree | |
Contents | Compilers |
NCIGENAST - NCIGEN abstract syntax tree
This file implements the various abstract syntax tree nodes for doing syntax analysis on c99 programs.
NCIGENAST::Node
is the base class for all NCIGENAST nodes,
and is derived from PCT::Node.
A node has an array component to hold its children,
and a hash component for its attributes.
However,
we tend to use accessor methods for accessing the node's attributes instead of accessing the hash directly.
Every NCIGENAST node inherits name
,
source
,
and pos
attributes from PCT::Node
.
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 inherited from PCT::Node
.
Other node attributes are generally defined by subclasses of NCIGENAST::Node
.
NCIGENAST::Val
nodes represent constant values in the abstract syntax tree.
The name
attribute represents the value of the node.
NCIGENAST::Var
nodes represent variables within the abstract syntax tree.
The variable name (if any) is given as the node's name
attribute.
isdecl
attribute (for lexical variables) to flag
.
A true value of isdecl
indicates that the variable given by this node is to be created within the current lexical scope.
Otherwise,
the node refers to a lexical variable from an outer scope.
lvalue
attribute,
which indicates whether this variable is being used in an lvalue context.
namespace
.
Useful only for variables with a scope
of 'package'.
slurpy
attribute (for parameter variables) to flag
.
A true value of slurpy
indicates that the parameter variable given by this node is to be created as a slurpy parameter (consuming all remaining arguments passed in).
type
indicates either the type of the value to create for the node or (future implementation) a NCIGENAST tree to create the value.
type
indicates the type of aggregate to create for the base if the base doesn't specify its own 'viviself' attribute.NCIGENAST::Op
nodes represent the operations in an abstract syntax tree.
The primary function of the node is given by its pasttype
,
secondary functions may be given by the node's name
,
pirop
,
or other attributes.
Copyright (C) 2006-2008, The Perl Foundation.
|