trait AttributionCore extends AttributionCommon with Memoiser
Reusable implementation of attribution of syntax trees in a functional style with attribute values cached so that each value is computed at most once.
- Source
- AttributionCore.scala
- Alphabetic
- By Inheritance
- AttributionCore
- Memoiser
- AttributionCommon
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
ConstantAttribute
[T, U] extends Attribute[T, U]
A constant attribute of a node type
Twith value of typeU.A constant attribute of a node type
Twith value of typeU. The value is given by the computationuwhich is evaluated at most once.- Definition Classes
- AttributionCommon
-
class
CachedAttribute
[T, U] extends Attribute[T, U] with IdMemoised[T, Option[U]]
An attribute of a node type
Twith value of typeU, supported by a memo table and circularity test.An attribute of a node type
Twith value of typeU, supported by a memo table and circularity test. The value of the attribute is computed by the functionf. The result is memoised so that it is only evaluated once.fshould not itself require the value of this attribute. If it does, a circularity error is reported by throwing anIllegalStateException. -
class
CachedDynamicAttribute
[T, U] extends CachedAttribute[T, U]
A cached dynamic attribute of a node type
Twith value of typeU, supported by a memo table and circularity test.A cached dynamic attribute of a node type
Twith value of typeU, supported by a memo table and circularity test. The value of the attribute is initially computed by the functionf, but the definition can be augmented dynamically. The result is memoised so that it is only evaluated once for a given definition. The attribute definition should not itself require the value of this attribute. If it does, a circularity error is reported by throwing anIllegalStateException. This kind of attribute encapsulates state to keep track of the current definition, so an instance should only be used from one thread at a time. -
class
CachedParamAttribute
[A, T, U] extends (A) ⇒ Attribute[T, U] with Memoised[ParamAttributeKey, Option[U]]
A variation of the
CachedAttributeclass for parameterised attributes. -
class
CircularAttribute
[T, U] extends Attribute[T, U] with IdMemoised[T, U]
An attribute of a node type
Twith value of typeUwhich has a circular definition.An attribute of a node type
Twith value of typeUwhich 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.
-
trait
IdMemoised
[T, U] extends MemoisedBase[T, U]
A memoised entity that weakly holds onto its keys and uses identity to compare them.
A memoised entity that weakly holds onto its keys and uses identity to compare them.
- Definition Classes
- Memoiser
-
trait
Memoised
[T, U] extends MemoisedBase[T, U]
A memoised entity that uses equality to compare keys.
A memoised entity that uses equality to compare keys.
- Definition Classes
- Memoiser
-
trait
MemoisedBase
[T, U] extends AnyRef
Common interface for encapsulation of memoisation for a single memoised entity backed by a configurable cache.
Common interface for encapsulation of memoisation for a single memoised entity backed by a configurable cache.
- Definition Classes
- Memoiser
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
attr[T, U](name: String, f: (T) ⇒ U): CachedAttribute[T, U]
As for the other
attrwith the first argument specifying a name for the constructed attribute. -
macro
def
attr[T, U](f: (T) ⇒ U): CachedAttribute[T, U]
Define a cached attribute of
Tnodes of typeUby the functionf, which should not depend on the value of this attribute.Define a cached attribute of
Tnodes of typeUby the 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. -
def
childAttr[T <: Attributable, U](name: String, f: (T) ⇒ (Attributable) ⇒ U): CachedAttribute[T, U]
As for the other
childAttrwith the first argument specifying a name for the constructed attribute. -
macro
def
childAttr[T <: Attributable, U](f: (T) ⇒ (Attributable) ⇒ U): CachedAttribute[T, U]
Define an attribute of
Tnodes of typeUby the functionf, which takes the current node and its parent as its arguments.Define an attribute of
Tnodes of typeUby the functionf, which takes the current node and its parent as its arguments.Tmust be a sub-type ofAttributableso that parents can be accessed generically. -
def
circular[T, U](name: String, init: U)(f: (T) ⇒ U): CircularAttribute[T, U]
As for the other
circularwith the first argument specifying a name for the constructed attribute. -
macro
def
circular[T, U](init: U)(f: (T) ⇒ U): CircularAttribute[T, U]
Define an optionally named circular attribute of
Tnodes of typeUby the functionf.Define an optionally named circular attribute of
Tnodes of typeUby the functionf.fis allowed to depend on the value of this attribute, which will be given byinitinitially 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
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
constant[T, U](name: String, u: ⇒ U): Attribute[T, U]
As for the other
constantwith the first argument specifying a name for the constructed attribute.As for the other
constantwith the first argument specifying a name for the constructed attribute.- Definition Classes
- AttributionCommon
-
macro
def
constant[T, U](u: ⇒ U): Attribute[T, U]
Define a constant attribute of
Tnodes of typeUgiven by the valueu.Define a constant attribute of
Tnodes of typeUgiven by the valueu.uis evaluated at most once.- Definition Classes
- AttributionCommon
-
def
dynAttr[T, U](name: String, f: (T) ⇒ U): CachedDynamicAttribute[T, U]
As for the other
dynAttrwith the first argument specifying a name for the constructed attribute. -
macro
def
dynAttr[T, U](f: (T) ⇒ U): CachedDynamicAttribute[T, U]
Define a cached dynamic attribute of
Tnodes of typeUby the partial functionf, which should not depend on the value of this attribute.Define a cached dynamic attribute of
Tnodes of typeUby 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. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
initTree[T <: Attributable](t: T): Unit
Initialise the
Attributabletree rooted attso that it is ready for attribution.Initialise the
Attributabletree rooted attso 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.- Definition Classes
- AttributionCommon
-
implicit
def
internalToDynamicAttribute[T, U](f: (T) ⇒ U): CachedDynamicAttribute[T, U]
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.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
paramAttr[V, T, U](name: String, f: (V) ⇒ (T) ⇒ U): CachedParamAttribute[V, T, U]
As for the other
paramAttrwith the first argument specifying a name for the constructed attribute. -
macro
def
paramAttr[V, T, U](f: (V) ⇒ (T) ⇒ U): CachedParamAttribute[V, T, U]
Define a parameterised attribute of
Tnodes of typeUby the functionf, which takes an argument of typeV.Define a parameterised attribute of
Tnodes of typeUby the functionf, which takes an argument of typeV. The computed attribute value for a givenVandTpair is cached so it will be computed at most once. -
def
resetMemo(): Unit
Lazily reset all memoisation tables.
Lazily reset all memoisation tables. The actual resets will only happen the next time the value of each attribute is accessed.
- Definition Classes
- Memoiser
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tree[T <: Attributable, U <: Attributable](name: String, f: (T) ⇒ U): CachedAttribute[T, U]
As for the other
treewith the first argument specifying a name for the constructed attribute. -
macro
def
tree[T <: Attributable, U <: Attributable](f: (T) ⇒ U): CachedAttribute[T, U]
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. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )