Return the value of this attribute for node t
.
Return the value of this attribute for node t
. Essentially Figure 6
from the CRAG paper, plus the READY optimisation (section 3.3).
Duplicate an entry if possible.
Duplicate an entry if possible. If t1
has a memoised value associated
with it, set the value associated with t2
to the same value. If there
is no value associated with t1
, set the value associated with t2
to
u
.
Return the value stored at key t
as an option.
Return the value stored at key t
as an option.
Return the value stored at key t
if there is one, otherwise
return u
.
Return the value stored at key t
if there is one, otherwise
return u
.
Has the value of this attribute at t
already been computed or not?
Has the value of this attribute at t
already been computed or not?
The memo table.
The memo table.
Store the value u
under the key t
.
Store the value u
under the key t
.
Store the value u
under the key t
if t
does not already have an
associated value.
Store the value u
under the key t
if t
does not already have an
associated value.
Report a cycle in the calculation of this attribute discovered when
evaluating the attribute on value t
.
Report a cycle in the calculation of this attribute discovered when
evaluating the attribute on value t
. Throws an IllegalStateException
.
Immediately reset this attribute's memoisation cache.
Immediately reset this attribute's memoisation cache.
Immediately reset the memo table at t
.
Immediately reset the memo table at t
.
Check to see if a reset has been requested via the common memo version, and if so, do it.
Check to see if a reset has been requested via the common memo version, and if so, do it.
Run the semantic function f
in a safe manner.
Run the semantic function f
in a safe manner. We need to guard against
f
throwing an exception which aborts the computation, since we could
then leave the global circular attribute state in a funny state.
The attribute's string representation is its name.
The attribute's string representation is its name.
An attribute of a node type
T
with value of typeU
which has a circular definition. The value of the attribute is computed by the function f which may itself use the value of the attribute. init specifies an initial value for the attribute. The attribute (and any circular attributes on which it depends) are evaluated until no value changes (i.e., a fixed point is reached). The final result is memoised so that subsequent evaluations return the same value.This code implements the basic circular evaluation algorithm from "Circular Reference Attributed Grammars - their Evaluation and Applications", by Magnusson and Hedin from LDTA 2003.