Annotation syntax

A model for annotations.

The syntax of annotations is defined through a meta-meta-model (i.e., a model with potency 2). The following listing shows such model:

metaDepth / code
Model AnnotationSyntax@2 { 
   abstract Node Annotation {
     reqs@1   : Annotation[*];
     forbids@1: Annotation[*];
     target@(2): Node[0..1];
     applicPotency@1 : int = 0;
     
     customHook@1 : String [0..1];
     semanticHooks@1  : SemanticAction[*];
   }
   
   Node ModelAnnotation : Annotation {     
   }
   
   Node ClabjectAnnotation : Annotation {
   }
   
   Node FieldAnnotation : Annotation {
   }
   
   Node PrimFieldAnnotation : FieldAnnotation {
   }
   
   Node ReferenceAnnotation : FieldAnnotation {
   }      
   
   enum When  { post, pre }   
   enum Event { create, delete, write, read, connect, disconnect, verify, createModel, retype }
   
   abstract Node SemanticAction{ // We expect in instances a constraint named main, and another called filter
      execPoint@1 : When[0..1];
      level@1	  : int = 0;   // 0 means at this level, 1 one level down, 2 two levels down, etc
      trigger@1   : Event = verify;   
      target@(2)  : Node[0..1];
      actionCodeFile@1 : String;      
      annotations@1  : Annotation[*];
   }
   		 
   Node ConstraintSpec : SemanticAction{
      messageIfFail@1 : String;
   }
   
   Node InPlaceTrafo : SemanticAction {
   }
   
   Node Model2Model  : SemanticAction {
   }
   
   Node CodeGenerationAction : SemanticAction {
      genFileExtension@1 : String;
      postSystemCommands@1 : String[0..*];
   }    
}
This model is aimed to be instantiated twice: once to define types of annotations, and then another one to use such annotations. Processing annotations produces a full-fledged model that refers to the annotated model. Here you can find more examples of MOPs:
  • Auto-instantiation: This MOP permits selecting some elements (via annotations), which are then automatically instantiated whenever the containing model is instantiated. Example model. Annotation definition. Hook in EOL. Alternative custom hook in EOL
  • Composition semantics: This MOP adds to a reference the semantics of composition (via an annotation). The hook is an EOL method which gets evaluated on the target node and reference when the command "verify" is issued. Example model. Annotation definition. Hook in EOL.
  • Powertype: This MOP allows declaring a powertype relationship. A is a powertype of B if the instances of A inherit from B. Hence, upon instantiating the A's, this MOP clones B (if not done before) into the lower meta-level and makes each A instance to inherit from B. Example model. Annotation definition. Hook in EOL