Package edu.cornell.cs.apl.attributes

Attribute grammars based on the Kiama library.

Please read the section on Attribute Grammars in Kiama's user manual to learn how to use this library.

Types

Attribute
Link copied to clipboard
abstract class Attribute<in Node, out T> : Function1<Node, T> , ReadOnlyProperty<Node, T>

An attribute of type T for nodes of type Node.

CycleInAttributeDefinitionException
Link copied to clipboard
class CycleInAttributeDefinitionException : RuntimeException

Thrown when a cycle is (dynamically) detected in an Attribute definition.

Tree
Link copied to clipboard
class Tree<Node : TreeNode<Node>, out RootNode : Node>(root: RootNode)

Computes and stores parent/child/sibling relations in a tree structure.

TreeNode
Link copied to clipboard
interface TreeNode<out Node>

A node in a Tree.

Functions

attribute
Link copied to clipboard
fun <Node, T> attribute(f: Node.() -> T): Attribute<Node, T>

Defines an Attribute of type T for nodes of type Node. The value of the attribute for a given Node is determined by the function f.

circularAttribute
Link copied to clipboard
fun <Node, T> circularAttribute(initial: T, f: Node.() -> T): Attribute<Node, T>

Defines an Attribute of type T for nodes of type Node. Unlike with attribute, attribute definitions are allowed to be circular.

collectedAttribute
Link copied to clipboard
fun <Node : TreeNode<Node>, T> collectedAttribute(tree: Tree<Node, Node>, f: (Node) -> Iterable<Pair<Node, T>>): Attribute<Node, Set<T>>

Defines an Attribute where the value of each Node is determined by the contributions from the other nodes. For every node, f specifies the contribution of that node to the other nodes. All nodes in tree are traversed to collect the attributes for each node.