-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathparser_features_demo_declarations.kerml
More file actions
104 lines (78 loc) · 2.66 KB
/
Copy pathparser_features_demo_declarations.kerml
File metadata and controls
104 lines (78 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Parser Features Demo: Declarations
*
* Demonstrates advanced declaration patterns:
* - Multiplicity declarations (Task 73)
* - Subclassifier keyword (Task 74)
* - Classifier keyword (Task 66)
* - Multiple typing with comma (Task 78)
* - Subset/disjoint statements (Task 65)
*
* Based on real stdlib patterns from Base.kerml, Occurrences.kerml
*/
package Declarations {
// The library is not implicitly visible: a bare name needs an import
// (KerML 8.2.3.5 — only the top-level elements of a root namespace are).
private import ScalarValues::*;
private import Occurrences::Occurrence;
// ===== Multiplicity Declarations (Task 73) =====
multiplicity exactlyOne [1..1] {
doc
/* Exactly one element required */
}
multiplicity zeroOrOne [0..1] {
doc
/* Optional element */
}
multiplicity oneToMany [1..*];
// ===== Classifier Keyword (Task 66) =====
// 'classifier' is canonical KerML term
abstract classifier Anything {
doc
/* Base classifier */
feature self: Anything[1] redefines self;
}
classifier Thing specializes Anything {
feature id: String;
}
// ===== Subclassifier Keyword (Task 74) =====
abstract classifier Base {
feature name: String;
}
classifier Derived {
feature derivedField: Integer;
}
subclassifier Derived specializes Base;
// ===== Multiple Typing with Comma (Task 78) =====
abstract classifier Type1 { }
abstract classifier Type2 { }
abstract classifier Type3 { }
feature MultiTypedFeature {
// Multiple typing
feature : Type1, Type2;
// Named with multiple types
feature multiTyped: Type1, Type2, Type3;
}
// ===== Subset/Disjoint Statements (Task 65) =====
feature OccurrenceStructure {
feature occurrences: Occurrence[*];
feature laterOccurrence: Occurrence[0..1];
feature earlierOccurrence: Occurrence[0..1];
// Subset statement
subset laterOccurrence.successors subsets earlierOccurrence.successors;
}
feature SetOperations {
feature setA: Anything[*];
feature setB: Anything[*];
// Disjoint statement
disjoint setA from setB;
}
// ===== Redefines Statements =====
classifier RedefinitionBase {
feature innerSpaceDimension: Integer default 3;
}
classifier Redefinition specializes RedefinitionBase {
// Redefines statement with value
redefines innerSpaceDimension = 0;
}
}