Common functionality for all attributes.
An attribute of a node type T
with value of type U
, supported by a memo
table and circularity test.
A cached dynamic attribute of a node type T
with value of type U
, supported
by a memo table and circularity test.
A variation of the CachedAttribute
class for parameterised attributes.
An attribute of a node type T
with value of type U
which has a circular
definition.
A constant attribute of a node type T
with value of type U
.
Support for parameterised attributes: argument, node pair comparison.
Define a named cached attribute of T
nodes of type U
by the function
f
, which should not depend on the value of this attribute.
Define a named cached attribute of T
nodes of type U
by the function
f
, which should not depend on the value of this attribute. The computed
attribute value is cached so it will be computed at most once. name
is used in debugging output to identify this attribute.
Define an anonymous cached attribute of T
nodes of type U
by the
function f
, which should not depend on the value of this attribute.
Define an anonymous cached attribute of T
nodes of type U
by the
function f
, which should not depend on the value of this attribute.
The computed attribute value is cached so it will be computed at most
once.
Define a cached attribute of T
nodes of type U
by the function f
,
which should not depend on the value of this attribute.
Define a cached attribute of T
nodes of type U
by the function f
,
which should not depend on the value of this attribute. The computed
attribute value is cached so it will be computed at most once. If
optNameDef
is not None
, then optNameDef.get
is used in debugging
output to identify this attribute.
Define a named attribute of T
nodes of type U
by the function f
,
which takes the current node and its parent as its arguments.
Define a named attribute of T
nodes of type U
by the function f
,
which takes the current node and its parent as its arguments. T
must be
a sub-type of Attributable
so that parents can be accessed generically.
name
is used in debugging output to identify this attribute and its parameter.
Define an anonymous attribute of T
nodes of type U
by the function
f
, which takes the current node and its parent as its arguments.
Define an anonymous attribute of T
nodes of type U
by the function
f
, which takes the current node and its parent as its arguments. T
must be a sub-type of Attributable
so that parents can be accessed
generically.
Define an attribute of T
nodes of type U
by the function f
, which
takes the current node and its parent as its arguments.
Define an attribute of T
nodes of type U
by the function f
, which
takes the current node and its parent as its arguments. T
must be
a sub-type of Attributable
so that parents can be accessed generically.
If optNameDef
is not None
, then optNameDef.get
is used in debugging
output to identify this attribute.
Define a named circular attribute of T
nodes of type U
by the function
f
.
Define a named circular attribute of T
nodes of type U
by the function
f
. f
is allowed to depend on the value of this attribute, which will
be given by init
initially and will be evaluated iteratively until a
fixed point is reached (in conjunction with other circular attributes
on which it depends). The final value is cached. name
is used in
debugging output to identify this attribute.
Define an anonymous circular attribute of T
nodes of type U
by the
function f
.
Define an anonymous circular attribute of T
nodes of type U
by the
function f
. f
is allowed to depend on the value of this attribute,
which will be given by init
initially and will be evaluated iteratively
until a fixed point is reached (in conjunction with other circular
attributes on which it depends). The final value is cached.
Define an optionally named circular attribute of T
nodes of type U
by the function f
.
Define an optionally named circular attribute of T
nodes of type U
by the function f
. f
is allowed to depend on the value of this
attribute, which will be given by init
initially and will be evaluated
iteratively until a fixed point is reached (in conjunction with other
circular attributes on which it depends). The final value is cached.
If optNameDef
is not None
, then optNameDef.get
is used in
debugging output to identify this attribute.
Define an optionally named constanat attribute of T
nodes of type U
given by the value u
.
Define an optionally named constanat attribute of T
nodes of type U
given by the value u
. u
is evaluated at most once. name
is used
in debugging output to identify this attribute.
Define an anonymous constanat attribute of T
nodes of type U
given by the value u
.
Define an anonymous constanat attribute of T
nodes of type U
given by the value u
. u
is evaluated at most once.
Define an optionally named constanat attribute of T
nodes of type U
given by the value u
.
Define an optionally named constanat attribute of T
nodes of type U
given by the value u
. u
is evaluated at most once. If optNameDef
is not None
, then optNameDef.get
is used in debugging output to
identify this attribute.
Define a named cached dynamic attribute of T
nodes of type U
by the
partial functionf
, which should not depend on the value of this attribute.
Define a named cached dynamic attribute of T
nodes of type U
by the
partial functionf
, which should not depend on the value of this attribute.
The computed attribute value is cached so it will be computed at most once.
name
is used in debugging output to identify this attribute.
Define an anonymous cached dynamic attribute of T
nodes of type U
by
the partial function f
, which should not depend on the value of this
attribute.
Define an anonymous cached dynamic attribute of T
nodes of type U
by
the partial function f
, which should not depend on the value of this
attribute. The computed attribute value is cached so it will be computed
at most once.
Define a cached dynamic attribute of T
nodes of type U
by the partial
function f
, which should not depend on the value of this attribute.
Define a cached dynamic attribute of T
nodes of type U
by the partial
function f
, which should not depend on the value of this attribute.
The computed attribute value is cached so it will be computed at most once.
If optNameDef
is not None
, then optNameDef.get
is used in debugging
output to identify this attribute.
Initialise the Attributable
tree rooted at t
so that it is ready for
attribution.
Initialise the Attributable
tree rooted at t
so that it is ready for
attribution. At present, the only initialisation performed is to set node
attributes such as parent and children so that nodes can generically refer
to their neighbours. If you wish to use any of these properties, you must
call this method before doing so. Otherwise, the node properties should
not be used and there is no need to call this method.
Implicitly converts functions to dynamic attributes.
Implicitly converts functions to dynamic attributes. This conversion allows us to use simpler types for dynamic attributes, but still extend them later.
Define a named parameterised attribute of T
nodes of type U
by the
function f
, which takes an argument of type A
.
Define a named parameterised attribute of T
nodes of type U
by the
function f
, which takes an argument of type A
. The computed attribute
value for a given T
and A
pair is cached so it will be computed at most
once. name
and the A
value are used in debugging output to identify
this attribute and its parameter.
Define an anonymous parameterised attribute of T
nodes of type U
by the
function f
, which takes an argument of type A
.
Define an anonymous parameterised attribute of T
nodes of type U
by the
function f
, which takes an argument of type A
. The computed attribute
value for a given T
and A
pair is cached so it will be computed at most
once.
Define a parameterised attribute of T
nodes of type U
by the function
f
, which takes an argument of type A
.
Define a parameterised attribute of T
nodes of type U
by the function
f
, which takes an argument of type A
. The computed attribute value
for a given T
and A
pair is cached so it will be computed at most
once. If optNameDef
is not None
, then optNameDef.get
and the A
value are used in debugging output to identify this attribute.
Lazily reset all memoisation tables.
Define a named attribute as per attr
, except that the attribute
must have a tree value and will be spliced into the tree to have the
same parent as the node on which it is defined.
Define a named attribute as per attr
, except that the attribute
must have a tree value and will be spliced into the tree to have the
same parent as the node on which it is defined. This kind of attribute
is used to generate new trees that must share context with the node on
which they are defined. name
is used in debugging output to identify
this attribute and its parameter.
Define an anonymous attribute as per attr
, except that the attribute
must have a tree value and will be spliced into the tree to have the
same parent as the node on which it is defined.
Define an anonymous attribute as per attr
, except that the attribute
must have a tree value and will be spliced into the tree to have the
same parent as the node on which it is defined. This kind of attribute
is used to generate new trees that must share context with the node on
which they are defined.
Define an optionally named attribute as per attr
, except that the
attribute must have a tree value and will be spliced into the tree to
have the same parent as the node on which it is defined.
Define an optionally named attribute as per attr
, except that the
attribute must have a tree value and will be spliced into the tree to
have the same parent as the node on which it is defined. This kind of
attribute is used to generate new trees that must share context
with the node on which they are defined. If optNameDef
is not None
,
then optNameDef.get
is used in debugging output to identify this
attribute.
Reusable implementation of attribution of syntax trees in a functional style with attribute values cached so that each value is computed at most once.