![]() |
|
Navigation |
Synopsis Declare an annotation type for nodes.
Syntax
anno AnnoType OnType @ Name
Description An annotation may be associated with any node value, be it a pure node or some AlgebraicDataType derived from it.
Annotations are intended to attach application data to values, like adding position information or control flow information to source code or adding visualization information to a graph. An annotation declaration defines:
The following constructs are provided for handling annotations:
Examples Here is a declaration of an annotation that attaches location information to certain syntactic constructs of
programs (e.g.,
EXPRESSION ) with name posinfo :
anno loc EXPRESSION @ posinfo;One can also add such location information to all syntax trees: anno loc Tree @ posinfo;Given a graph datatype, one can define an annotation with name LayoutStrategy that defines which
graph layout algorithm to apply to a particular graph, e.g.,
rascal>data Graph = vertex(str name, int x, int y) | edge(str from, str to); ok rascal>data LayoutStrategy = dot() | tree() | force() | hierarchy() | fisheye(); ok rascal>anno LayoutStrategy Graph @ strategy; ok rascal>G = vertex("root", 0, 0); Graph: vertex("root",0,0) rascal>G @ strategy = fisheye(); Graph: vertex("root",0,0)[ @strategy=fisheye() ] ![]() |