Package

org.bitbucket.inkytonik.kiama

relation

Permalink

package relation

Visibility
  1. Public
  2. All

Type Members

  1. case class Bridge[T](cross: T) extends Product with Serializable

    Permalink

    A bridge node in a tree structure which connects to another structure.

    A bridge node in a tree structure which connects to another structure. Bridges are not traversed when determining the tree structure.

  2. case class NodeNotInTreeException[T](t: T) extends Exception with Product with Serializable

    Permalink

    Exception thrown if a tree relation operation tries to use a node that is not in the tree to which the relation applies.

    Exception thrown if a tree relation operation tries to use a node that is not in the tree to which the relation applies. t is the node that was found not to be in the tree.

    For the time-being, the exception does not indicate which tree is involved because it's not clear how to identify the tree briefly in a short message. The stack trace that accompanies the exception should be sufficient.

  3. class Relation[T, U] extends AnyRef

    Permalink

    A binary relation between values of type T and values of type U.

    A binary relation between values of type T and values of type U. Constructed from memoised caches that map T values to their image and vice versa.

  4. case class StructureIsNotATreeException(msg: String) extends Exception with Product with Serializable

    Permalink

    Exception thrown if CheckTree is specified as a tree's shape but the provided structure is not a tree.

    Exception thrown if CheckTree is specified as a tree's shape but the provided structure is not a tree. msg describes the reason(s) why the structure is not a tree by listing the nodes that have more than one parent.

  5. class Tree[T <: Product, +R <: T] extends AnyRef

    Permalink

    Relational representations of trees built out of hierarchical Product instances.

    Relational representations of trees built out of hierarchical Product instances. Typically, the nodes are instances of case classes.

    The type T is the common base type of the tree nodes. The type R is a sub-type of T that is the type of the root node.

    The originalRoot value should be the root of a finite, acyclic structure that contains only Product instances of type T (unless they are skipped, see below).

    The shape argument governs how the structure referred to by originalRoot is treated. If shape is LeaveAlone (the default) then the structure is used without change. If shape is CheckTree then a check is run before the structure is used to make sure that it is a tree (i.e., no node sharing nor cycles). A runtime error occurs if this is not the case. If shape is EnsureTree then shared parts of the structure are cloned to ensure that it is a tree before it is used.

    If you are confident that your structure is a tree (e.g., it comes from a parser) then the default shape should be fine. If you prefer a bit more safety, then use CheckTree so that a non-tree structure cannot be missed. Finally, use EnsureTree if you know that your structure may contain sharing (e.g., it is produced by a term rewriting process).

    The child relation of a tree is defined to skip certain nodes. Specifically, if a node of type T is wrapped in a Some of an option, a Left or Right of an Either, a tuple up to size four, or a TraversableOnce, then those wrappers are ignored. E.g., if t1 is Some (t2) where both t1 and t2 are of type T, then t1 will be t2's parent, not the Some value.

    Thanks to Len Hamey for the idea to use lazy cloning to restore the tree structure instead of requiring that the input trees contain no sharing.

  6. class TreeRelation[T <: Product] extends Relation[T, T]

    Permalink

    A tree relation is a binary relation on tree nodes with an extra property that the image operation throws a NodeNotInTreeException exception if it is applied to a node that is not in this tree.

    A tree relation is a binary relation on tree nodes with an extra property that the image operation throws a NodeNotInTreeException exception if it is applied to a node that is not in this tree. T is the type of the tree nodes.

  7. sealed abstract class TreeShape extends AnyRef

    Permalink

    Tree properties

Value Members

  1. object CheckTree extends TreeShape with Product with Serializable

    Permalink

    The incoming structure should be a tree (i.e., no sharing nor cycles) but a runtime check should be performed to make sure.

  2. object EnsureTree extends TreeShape with Product with Serializable

    Permalink

    The incoming structure may not be a tree (e.g., may contain sharing) and shared parts should be cloned to make it a tree before any further processing is performed.

  3. object LeaveAlone extends TreeShape with Product with Serializable

    Permalink

    The incoming structure has an acceptable shape and should be left alone by the tree processing.

  4. object Relation

    Permalink

    Support for binary relations.

  5. object TreeRelation

    Permalink

    Support for tree relations.

Ungrouped