Annotations
Annotation = @( "@" QualifiedIdent ) [ "(" AnnotationArgs ")" ] AnnotationArgs = {lexpr} { "," {lexpr} } [ "," ]
TODO: document this |
Declaration
TODO: document this |
@annotation shape MyAnnotation def MyAnnotation(int i) // ... end end @MyAnnotation(12) shape MyShape end
Since annotations are just shapes, that are stored in the type data, you can instantiate them just like normal shapes. To disable this behaviour, you can use multiple approaches:
|
Builtin annotations
Some annotations are buildin into the compiler:
@annotation
to declare a annotation@not_instantiable
to make a annotation (or constructor of them) not instantiable from normal code vianew
.@no_mangle
to not apply any name mangeling to a function
TODO: document this |
Accessing
TODO: document this |
Placement
TODO: document this |
AnnotatedTopLevelDecl = { Annotation } TopLevelDecl ; AnnotatedStmnt = { Annotation } Statement ; AnnotatedType = { Annotation } Type ;
Declaration Examples
@namespace_annotation namespace Test @shape_annotation shape MyTempl @field_annotation var int field; @method_annotation def method() end end @variable_annotation var int variable; @method_annotation def myFunction( @param_annotation int param1 ) # ... end end @function_annotation def someFunction() @variable_annotation var int i; end
Type examples
var Car car = new @type_annotation Car(); var @type_annotation int i; var array[@type_annotation int] a; shape MyContainer of [ @type_annotation T , @type_annotation int i, @type_annotation const j ] use [ @type_annotation Parent ] var @type_annotation int field; def (@type_annotation int, @type_annotation int) myFunction() end end // type annoation for typeless var @type_annotation c; c = new MyContainer[ @type_annotation int, 12, 1 ](); f = cast d to @type_annotation F;