-
Notifications
You must be signed in to change notification settings - Fork 0
/
lf-optimiser.ometajs
56 lines (49 loc) · 1.2 KB
/
lf-optimiser.ometajs
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
var LFValidator = require('./lf-validator').LFValidator;
export ometa LFOptimiser <: LFValidator {
Helped =
?(this.helped === true)
{this.helped = false},
SetHelped =
{this.helped = true},
Process =
:x
trans(x):x
( Helped('disableMemoisation')
( trans(x):x
| {console.error('Failed to reprocess?!')}
?false
)
)*
-> x,
AtLeastNQuantification
"MinimumCardinality":i ?{i[1][1]==1} "Variable":v trans*:xs
SetHelped
-> ['ExistentialQuantification', v].concat(xs)
| ^AtLeastNQuantification,
NumericalRangeQuantification
"MinimumCardinality":i
"MaximumCardinality":j
?{i[1][1]==j[1][1]}
"Variable":v trans*:xs
SetHelped
-> ['ExactQuantification', ['Cardinality', i[1]], v].concat(xs)
| ^NumericalRangeQuantification,
LogicalNegation =
['LogicalNegation' trans:xs] SetHelped
-> xs
| ^LogicalNegation
,
ExactQuantification =
"Cardinality":i
"Variable":v
trans*:xs
?(i[1][1] === 0)
SetHelped
// Exactly 0 is equivalent to not exists
-> ['LogicalNegation', ['ExistentialQuantification', v].concat(xs)]
| ^ExactQuantification
}
LFOptimiser.initialize = function() {
LFValidator.initialize.call(this);
this._didSomething = false;
};