The reference sections are ordered in four parts: the imperative syntax (1-6), the object-oriented (7-10) and the model-oriented (11-15) features, the advanced concepts (16-21).
Text not verified for kermeta 2 | |
---|---|
Warning | |
---|---|
Comments are a little bit particular in the Kermeta language because they are not all ignored by the interpreter. There are two kinds of comments: the first (syntax : // foo , /* bar * /) is only associated to the text editor view in which the user edits his Kermeta file, and the second one(syntax : /** foo */ or @tag_name "tag value") is translated into a MOF tag linked to structures described in the Kermeta model. The first one, is a text decoration, the second one is part of the Kermeta model. |
Like in many languages, Kermeta provides two ways to add comments in your models:
simple line comments, i.e text line beginning with //
// This is a single line comment
multi-line comments, i.e text between /* */. Be careful with this notation : the opening syntax must not have juxtaposed stars ("/**"), otherwise it will be considered as a linked comment (see Section 2.1.2, “ Linked comments ” ), i.e a comment that is part of the Kermeta program as a model.
/* This a multi line comment all these lines are comments this line too. */
Kermeta provides a way to define named and unnamed annotations,
that have to be defined just
above any model element among
Package
,
ClassDefinition
,
Property
,
Operation
. Such
annotations correspond to MOF tags, and are linked to the
elements
which immediately
follows.
To define a named annotation, you have to use a special symbol "@", whereas an anonymous annotation has to be written between /** and */
Example 1: you can define an annotation to describe the role of a property
@usage "count the number of ..."
reference myCounter : Integer
Example 2 : you can document your classes and operation using /** ... */
/** * This is a documentation tag for the class "myClass" */
class MyClass {
/** This is a documentation tag for myOperation */
operation myOperation() is do
// Unlinked comment
end
@desc "This is a named annotation for thisOperation"
operation thisOperation() is do
/* This is an unlinked comment */
end
}