kiama.attribution

trait AttributionBase

[source: kiama/attribution/AttributionBase.scala]

trait AttributionBase
extends AnyRef
Base support for attribution of syntax trees in a functional style. Includes circular attributes but needs to be augmented with basic attributes and parameterised attributes.
Direct Known Subclasses:
Attribution, UncachedAttribution, DynamicAttribution

Type Summary
type ==>
Convenient type constructor for partial functions.
Method Summary
def circular [T <: AnyRef, U](init : U)(f : scala.PartialFunction[T, U]) : scala.PartialFunction[T, U]
Define a 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.
def constant [T <: AnyRef, U](u : => U) : scala.PartialFunction[T, U]
Define an attribute of T nodes of type U given by the constant value u. u is evaluated at most once.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Class Summary
class CircularAttribute [T <: AnyRef, U](init : U, f : scala.PartialFunction[T, U]) extends scala.PartialFunction[T, U]
An attribute of a node type T with value of type U 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.
protected class ParamAttributeKey (val arg : Any, val node : AnyRef) extends AnyRef
Support for parameterised attributes: argument, node pair comparison.
Type Details
type ==>
Convenient type constructor for partial functions.

Method Details
def circular[T <: AnyRef, U](init : U)(f : scala.PartialFunction[T, U]) : scala.PartialFunction[T, U]
Define a 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.

def constant[T <: AnyRef, U](u : => U) : scala.PartialFunction[T, U]
Define an attribute of T nodes of type U given by the constant value u. u is evaluated at most once.