-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathExpressions.kerml
More file actions
75 lines (62 loc) · 1.77 KB
/
Expressions.kerml
File metadata and controls
75 lines (62 loc) · 1.77 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
package Expressions {
private import ScalarFunctions::*;
private import BaseFunctions::ToString;
private import ControlFunctions::*;
a: Integer;
aa : Boolean;
x = ToString(a * a + 3 == 4);
y = NumericalFunctions::'+'(1,2);
z : Boolean = aa & true xor zz | false implies z;
zz : Boolean = aa and true xor aa or false implies z;
grp = -x + x * y * y + a ** 3 ^ 4;
b = if x > y? x-y else y-x;
c = x->collect {in xx; xx + 1};
c1 = x.{in xx; xx + 1};
d = x->select {in xx; xx != null};
d1 = x.?{in xx; xx != null};
e = x->reduce {in s; in t; s + t}->reduce '+';
behavior w { inout v : Integer;
step : ControlPerformances::LoopPerformance {
in expr whileTest {v > 3}
in step body {
step decrement {
out v_decr : Integer = v - 1;
}
succession decrement then update;
step update : FeatureReferencingPerformances::FeatureWritePerformance {
in onOccurrence = w::self {
feature redefines startingAt : w {
inout feature redefines accessedFeature redefines v;
}
}
inout replacementValues = decrement.v_decr;
}
}
}
}
xx = if x == 1 and y == 2? a
else if x == 2? b
else if x == 3? c
else 0;
function TotalMass { in partMass; in subparts;
partMass + (subparts->collect {in p; totalMass(partMass, subparts)}->reduce '+' ?? 0.0)
}
expr totalMass: TotalMass { in mass; in sub; }
feature f {
expr s { in x; return : Boolean; }
}
bb : Boolean = f.s(1);
class C {
var count : ScalarValues::Integer := 0;
}
feature obj1 : C;
feature obj2 : C;
test1 = obj1 === obj2;
test2 = x !== obj2;
class L {
feature c : C[*];
feature count : ScalarValues::Integer = c#(1).count;
}
feature l = new L();
feature w1 = w(xx);
}