occam-furtle 3.0.461 → 3.0.464
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/context/block.js +2 -2
- package/lib/element/anonymousProcedure.js +12 -11
- package/lib/element/assignment/list.js +5 -5
- package/lib/element/assignment/object.js +35 -31
- package/lib/element/binding/named.js +6 -5
- package/lib/element/binding.js +5 -4
- package/lib/element/bindings/named.js +34 -28
- package/lib/element/bindings.js +14 -10
- package/lib/element/contains.js +4 -4
- package/lib/element/endsWith.js +4 -4
- package/lib/element/every.js +4 -4
- package/lib/element/expression.js +17 -27
- package/lib/element/lengthOf.js +4 -4
- package/lib/element/nodeQuery.js +7 -7
- package/lib/element/nodesQuery.js +6 -6
- package/lib/element/parameter.js +4 -3
- package/lib/element/parameters.js +14 -11
- package/lib/element/primitive.js +3 -3
- package/lib/element/procedure.js +13 -12
- package/lib/element/procedureCall.js +12 -10
- package/lib/element/reduce.js +3 -3
- package/lib/element/returnBlock.js +2 -2
- package/lib/element/returnStatement.js +3 -3
- package/lib/element/some.js +3 -3
- package/lib/element/startsWith.js +4 -4
- package/lib/element/term/bracketed.js +3 -3
- package/lib/element/term/comparison.js +4 -4
- package/lib/element/term/logical.js +5 -5
- package/lib/element/term/negated.js +4 -4
- package/lib/element/term.js +8 -10
- package/lib/element/terms.js +13 -14
- package/lib/element/ternary.js +2 -2
- package/lib/element/toInteger.js +5 -5
- package/lib/element/tryInteger.js +4 -4
- package/lib/element/value.js +4 -6
- package/lib/element/values.js +13 -11
- package/lib/element/variable.js +4 -4
- package/lib/nominalValueProperties.js +18 -17
- package/lib/nominalValueProperty.js +3 -3
- package/package.json +2 -2
- package/src/context/block.js +1 -1
- package/src/element/anonymousProcedure.js +15 -15
- package/src/element/assignment/list.js +4 -4
- package/src/element/assignment/object.js +36 -34
- package/src/element/binding/named.js +6 -4
- package/src/element/binding.js +5 -3
- package/src/element/bindings/named.js +46 -34
- package/src/element/bindings.js +19 -11
- package/src/element/contains.js +3 -3
- package/src/element/endsWith.js +3 -3
- package/src/element/every.js +3 -3
- package/src/element/expression.js +17 -35
- package/src/element/lengthOf.js +3 -3
- package/src/element/nodeQuery.js +6 -6
- package/src/element/nodesQuery.js +5 -5
- package/src/element/parameter.js +4 -2
- package/src/element/parameters.js +19 -12
- package/src/element/primitive.js +2 -2
- package/src/element/procedure.js +16 -16
- package/src/element/procedureCall.js +11 -10
- package/src/element/reduce.js +2 -2
- package/src/element/returnBlock.js +1 -1
- package/src/element/returnStatement.js +2 -2
- package/src/element/some.js +2 -2
- package/src/element/startsWith.js +3 -3
- package/src/element/term/bracketed.js +2 -2
- package/src/element/term/comparison.js +3 -3
- package/src/element/term/logical.js +4 -4
- package/src/element/term/negated.js +3 -3
- package/src/element/term.js +7 -11
- package/src/element/terms.js +20 -19
- package/src/element/ternary.js +1 -1
- package/src/element/toInteger.js +4 -4
- package/src/element/tryInteger.js +3 -3
- package/src/element/value.js +3 -7
- package/src/element/values.js +22 -17
- package/src/element/variable.js +3 -3
- package/src/nominalValueProperties.js +22 -18
- package/src/nominalValueProperty.js +2 -2
package/src/element/binding.js
CHANGED
|
@@ -27,9 +27,9 @@ export default define(class Binding extends Element {
|
|
|
27
27
|
return this.elided;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
compareTerm(term, context) {
|
|
30
|
+
compareTerm(term, context, back, forward) {
|
|
31
31
|
if (this.elided) {
|
|
32
|
-
return;
|
|
32
|
+
return forward();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const termString = term.getString(),
|
|
@@ -45,10 +45,12 @@ export default define(class Binding extends Element {
|
|
|
45
45
|
message = `The '${termString}' term's '${termType}' type is not equal to the '${bindingString}' binding's '${typeString}' type.`,
|
|
46
46
|
exception = Exception.fromMessage(message);
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
return back(exception);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
context.debug(`...comparing the '${termString}' term against the '${bindingString}' binding.`);
|
|
52
|
+
|
|
53
|
+
return forward();
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
static name = "Binding";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Element } from "occam-languages";
|
|
3
|
+
import { Element, continuationUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import Exception from "../../exception";
|
|
6
6
|
|
|
7
7
|
import { define } from "../../elements";
|
|
8
8
|
|
|
9
|
+
const { some, forEach } = continuationUtilities;
|
|
10
|
+
|
|
9
11
|
export default define(class NamedBindings extends Element {
|
|
10
12
|
constructor(context, string, node, breakPoint, array) {
|
|
11
13
|
super(context, string, node, breakPoint);
|
|
@@ -29,11 +31,15 @@ export default define(class NamedBindings extends Element {
|
|
|
29
31
|
return namedBinding;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
someNamedBinding(callback
|
|
34
|
+
someNamedBinding(callback, back, forward) {
|
|
35
|
+
return some(this.array, callback, back, forward);
|
|
36
|
+
}
|
|
33
37
|
|
|
34
|
-
forEachNamedBinding(callback
|
|
38
|
+
forEachNamedBinding(callback, back, forward) {
|
|
39
|
+
return forEach(this.array, callback, back, forward);
|
|
40
|
+
}
|
|
35
41
|
|
|
36
|
-
compareTerms(terms, context) {
|
|
42
|
+
compareTerms(terms, context, back, forward) {
|
|
37
43
|
const termsString = terms.getString(),
|
|
38
44
|
namedBindingsString = this.getString(); ///
|
|
39
45
|
|
|
@@ -46,54 +52,60 @@ export default define(class NamedBindings extends Element {
|
|
|
46
52
|
const message = `The '${termsString}' terms and '${namedBindingsString}' named bindings are not of the same length.`,
|
|
47
53
|
exception = Exception.fromMessage(message);
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
return back(exception);
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
this.forEachNamedBinding((namedBinding, index) => {
|
|
53
|
-
if (namedBinding
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
namedBinding.compareTerm(term, context);
|
|
58
|
+
return this.forEachNamedBinding((namedBinding, back, forward, index) => {
|
|
59
|
+
if (namedBinding === null) {
|
|
60
|
+
return forward();
|
|
57
61
|
}
|
|
58
|
-
});
|
|
59
62
|
|
|
60
|
-
|
|
63
|
+
const term = terms.getTerm(index);
|
|
64
|
+
|
|
65
|
+
return namedBinding.compareTerm(term, context, back, forward);
|
|
66
|
+
}, back, () => {
|
|
67
|
+
context.debug(`...compared the '${termsString}' terms with the '${namedBindingsString}' named bindings.`);
|
|
68
|
+
|
|
69
|
+
return forward();
|
|
70
|
+
});
|
|
61
71
|
}
|
|
62
72
|
|
|
63
|
-
compareNamedBinding(namedBinding, context) {
|
|
73
|
+
compareNamedBinding(namedBinding, context, back, forward) {
|
|
64
74
|
const namedBindingString = namedBinding.getString(),
|
|
65
75
|
namedBindingsString = this.getString(); ///
|
|
66
76
|
|
|
67
77
|
context.trace(`Comparing the '${namedBindingString}' namedBinding with the '${namedBindingsString}' named bindings...`);
|
|
68
78
|
|
|
69
|
-
const namedBindingA = namedBinding
|
|
70
|
-
namedBindingCompares = this.someNamedBinding((namedBinding) => {
|
|
71
|
-
if (namedBinding !== null) {
|
|
72
|
-
const namedBindingB = namedBinding, ///
|
|
73
|
-
namedBindingBComparesToNamedBindingA = namedBindingA.compareNamedBinding(namedBindingB, context);
|
|
79
|
+
const namedBindingA = namedBinding; ///
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
});
|
|
81
|
+
return this.someNamedBinding((namedBinding) => {
|
|
82
|
+
if (namedBinding !== null) {
|
|
83
|
+
const namedBindingB = namedBinding; ///
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
return namedBindingA.compareNamedBinding(namedBindingB, context, back, forward);
|
|
86
|
+
}
|
|
87
|
+
}, back, (namedBindingCompares) => {
|
|
88
|
+
if (!namedBindingCompares) {
|
|
89
|
+
const message = `The '${namedBindingString}' namedBinding does not compare to any of the '${namedBindingsString}' named bindings.`,
|
|
90
|
+
exception = Exception.fromMessage(message);
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
return back(exception);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
context.debug(`...compared the '${namedBindingString}' namedBinding with the '${namedBindingsString}' named bindings.`);
|
|
87
96
|
|
|
88
|
-
|
|
97
|
+
return forward();
|
|
98
|
+
});
|
|
89
99
|
}
|
|
90
100
|
|
|
91
|
-
compareNamedBindings(namedBindings, context) {
|
|
92
|
-
namedBindings.forEachNamedBinding((namedBinding) => {
|
|
93
|
-
if (namedBinding
|
|
94
|
-
|
|
101
|
+
compareNamedBindings(namedBindings, context, back, forward) {
|
|
102
|
+
return namedBindings.forEachNamedBinding((namedBinding, back, forward) => {
|
|
103
|
+
if (namedBinding === null) {
|
|
104
|
+
return forward();
|
|
95
105
|
}
|
|
96
|
-
|
|
106
|
+
|
|
107
|
+
return this.compareNamedBinding(namedBinding, context, back, forward);
|
|
108
|
+
}, back, forward);
|
|
97
109
|
}
|
|
98
110
|
|
|
99
111
|
static name = "NamedBindings";
|
package/src/element/bindings.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Element } from "occam-languages";
|
|
3
|
+
import { Element, continuationUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import Exception from "../exception";
|
|
6
6
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
8
|
|
|
9
|
+
const { forEach } = continuationUtilities;
|
|
10
|
+
|
|
9
11
|
export default define(class Bindings extends Element {
|
|
10
12
|
constructor(context, string, node, breakPoint, array) {
|
|
11
13
|
super(context, string, node, breakPoint);
|
|
@@ -29,9 +31,11 @@ export default define(class Bindings extends Element {
|
|
|
29
31
|
return binding;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
forEachBinding(callback
|
|
34
|
+
forEachBinding(callback, back, forward) {
|
|
35
|
+
return forEach(this.array, callback, back, forward);
|
|
36
|
+
}
|
|
33
37
|
|
|
34
|
-
compareTerms(terms, context) {
|
|
38
|
+
compareTerms(terms, context, back, forward) {
|
|
35
39
|
const termsString = terms.getString(),
|
|
36
40
|
bindingsString = this.getString(); ///
|
|
37
41
|
|
|
@@ -44,18 +48,22 @@ export default define(class Bindings extends Element {
|
|
|
44
48
|
const message = `The '${termsString}' expressions and '${bindingsString}' bindings are not of the same length.`,
|
|
45
49
|
exception = Exception.fromMessage(message);
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
return back(exception);
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
this.forEachBinding((binding, index) => {
|
|
51
|
-
if (binding
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
binding.compareTerm(term, context);
|
|
54
|
+
return this.forEachBinding((binding, back, forward, index) => {
|
|
55
|
+
if (binding === null) {
|
|
56
|
+
return forward();
|
|
55
57
|
}
|
|
56
|
-
});
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
const term = terms.getTerm(index);
|
|
60
|
+
|
|
61
|
+
return binding.compareTerm(term, context, back, forward);
|
|
62
|
+
}, back, () => {
|
|
63
|
+
context.debug(`...compared the '${termsString}' terms against the '${bindingsString}' bindings.`);
|
|
64
|
+
|
|
65
|
+
forward();
|
|
66
|
+
});
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
static name = "Bindings";
|
package/src/element/contains.js
CHANGED
|
@@ -24,7 +24,7 @@ export default define(class Contains extends Element {
|
|
|
24
24
|
return this.substring;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
evaluate(context) {
|
|
27
|
+
evaluate(context, back, forward) {
|
|
28
28
|
let value;
|
|
29
29
|
|
|
30
30
|
const containsString = this.getString(); ///
|
|
@@ -41,7 +41,7 @@ export default define(class Contains extends Element {
|
|
|
41
41
|
message = `The '${valueString}' value's '${valueType}' type should be '${STRING_TYPE_NAME}'.`,
|
|
42
42
|
exception = Exception.fromMessage(message);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
return back(exception);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const string = value.getString(),
|
|
@@ -53,7 +53,7 @@ export default define(class Contains extends Element {
|
|
|
53
53
|
|
|
54
54
|
context.debug(`...evaluated the '${containsString}' function as '${valueString}'.`);
|
|
55
55
|
|
|
56
|
-
return value;
|
|
56
|
+
return forward(value);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
static name = "Contains";
|
package/src/element/endsWith.js
CHANGED
|
@@ -24,7 +24,7 @@ export default define(class EndsWith extends Element {
|
|
|
24
24
|
return this.substring;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
evaluate(context) {
|
|
27
|
+
evaluate(context, back, forward) {
|
|
28
28
|
let value;
|
|
29
29
|
|
|
30
30
|
const endsWithString = this.getString(); ///
|
|
@@ -41,7 +41,7 @@ export default define(class EndsWith extends Element {
|
|
|
41
41
|
message = `The '${valueString}' value's '${valueType}' type should be '${STRING_TYPE_NAME}'.`,
|
|
42
42
|
exception = Exception.fromMessage(message);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
return back(exception);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const string = value.getString(),
|
|
@@ -53,7 +53,7 @@ export default define(class EndsWith extends Element {
|
|
|
53
53
|
|
|
54
54
|
context.debug(`...evaluated the '${endsWithString}' function as '${valueString}'.`);
|
|
55
55
|
|
|
56
|
-
return value;
|
|
56
|
+
return forward(value);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
static name = "EndsWith";
|
package/src/element/every.js
CHANGED
|
@@ -43,7 +43,7 @@ export default define(class Every extends Element {
|
|
|
43
43
|
message = `The '${valueString}' value's '${valueType}' type should be '${LIST_TYPE_NAME}'.`,
|
|
44
44
|
exception = Exception.fromMessage(message);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
return back(exception);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const nodes = value.getNodes();
|
|
@@ -62,14 +62,14 @@ export default define(class Every extends Element {
|
|
|
62
62
|
message = `The '${valueString}' value's type is '${valueType}' when it should be of type '${BOOLEAN_TYPE_NAME}'.`,
|
|
63
63
|
exception = Exception.fromMessage(message);
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
return back(exception);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const boolean = value.getBoolean();
|
|
69
69
|
|
|
70
70
|
return forward(boolean);
|
|
71
71
|
});
|
|
72
|
-
}, (boolean) => {
|
|
72
|
+
}, back, (boolean) => {
|
|
73
73
|
const value = valueFromBoolean(boolean, context),
|
|
74
74
|
valueString = value.getString();
|
|
75
75
|
|
|
@@ -126,59 +126,41 @@ export default define(class Expression extends Element {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
evaluate(context, back, forward) {
|
|
129
|
-
let value = null;
|
|
130
|
-
|
|
131
129
|
if (false) {
|
|
132
130
|
///
|
|
133
131
|
} else if (this.term !== null) {
|
|
134
|
-
|
|
132
|
+
return this.term.evaluate(context, back, forward);
|
|
135
133
|
} else if (this.nodeQuery !== null) {
|
|
136
|
-
|
|
134
|
+
return this.nodeQuery.evaluate(context, back, forward);
|
|
137
135
|
} else if (this.nodesQuery !== null) {
|
|
138
|
-
|
|
136
|
+
return this.nodesQuery.evaluate(context, back, forward);
|
|
139
137
|
} else if (this.lengthOf !== null) {
|
|
140
|
-
|
|
138
|
+
return this.lengthOf.evaluate(context, back, forward);
|
|
141
139
|
} else if (this.toInteger !== null) {
|
|
142
|
-
|
|
140
|
+
return this.toInteger.evaluate(context, back, forward);
|
|
143
141
|
} else if (this.tryInteger !== null) {
|
|
144
|
-
|
|
142
|
+
return this.tryInteger.evaluate(context, back, forward);
|
|
145
143
|
} else if (this.contains !== null) {
|
|
146
|
-
|
|
144
|
+
return this.contains.evaluate(context, back, forward);
|
|
147
145
|
} else if (this.endsWith !== null) {
|
|
148
|
-
|
|
146
|
+
return this.endsWith.evaluate(context, back, forward);
|
|
149
147
|
} else if (this.startsWith !== null) {
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (value !== null) {
|
|
154
|
-
return forward(value);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (this.some !== null) {
|
|
148
|
+
return this.startsWith.evaluate(context, back, forward);
|
|
149
|
+
} else if (this.some !== null) {
|
|
158
150
|
return this.some.evaluate(context, back, forward);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (this.
|
|
162
|
-
return this.every.evaluate(context, back, forward);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (this.reduce !== null) {
|
|
151
|
+
} else if (this.every !== null) {
|
|
152
|
+
return this.every.evaluate(context, back, forward);
|
|
153
|
+
} else if (this.reduce !== null) {
|
|
166
154
|
return this.reduce.evaluate(context, back, forward);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (this.ternary !== null) {
|
|
155
|
+
} else if (this.ternary !== null) {
|
|
170
156
|
return this.ternary.evaluate(context, back, forward);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (this.returnBlock !== null) {
|
|
157
|
+
} else if (this.procedureCall !== null) {
|
|
158
|
+
return this.procedureCall.evaluate(context, back, forward);
|
|
159
|
+
} else if (this.returnBlock !== null) {
|
|
174
160
|
const variables = [];
|
|
175
161
|
|
|
176
162
|
return this.returnBlock.evaluate(variables, context, back, forward);
|
|
177
163
|
}
|
|
178
|
-
|
|
179
|
-
if (this.procedureCall !== null) {
|
|
180
|
-
return this.procedureCall.evaluate(context, back, forward);
|
|
181
|
-
}
|
|
182
164
|
}
|
|
183
165
|
|
|
184
166
|
static name = "Expression";
|
package/src/element/lengthOf.js
CHANGED
|
@@ -19,7 +19,7 @@ export default define(class LengthOf extends Element {
|
|
|
19
19
|
return this.variable;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
evaluate(context) {
|
|
22
|
+
evaluate(context, back, forward) {
|
|
23
23
|
let value;
|
|
24
24
|
|
|
25
25
|
const lengthOfString = this.getString(); ///
|
|
@@ -36,7 +36,7 @@ export default define(class LengthOf extends Element {
|
|
|
36
36
|
message = `The '${valueString}' value's '${valueType}' type should be '${LIST_TYPE_NAME}'.`,
|
|
37
37
|
exception = Exception.fromMessage(message);
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
return back(exception);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const primitiveValue = value.getPrimitiveValue(),
|
|
@@ -49,7 +49,7 @@ export default define(class LengthOf extends Element {
|
|
|
49
49
|
|
|
50
50
|
context.debug(`...evaluated the '${lengthOfString}' function as '${valueString}'.`);
|
|
51
51
|
|
|
52
|
-
return value;
|
|
52
|
+
return forward(value);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
static name = "LengthOf";
|
package/src/element/nodeQuery.js
CHANGED
|
@@ -28,7 +28,7 @@ export default define(class NodeQuery extends Element {
|
|
|
28
28
|
return this.query;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
evaluate(context) {
|
|
31
|
+
evaluate(context, back, forward) {
|
|
32
32
|
let value;
|
|
33
33
|
|
|
34
34
|
const nodeQueryString = this.getString(); ///
|
|
@@ -39,7 +39,7 @@ export default define(class NodeQuery extends Element {
|
|
|
39
39
|
const message = `Cannot evaluate the '${nodeQueryString}' function because its expression is malformed.`,
|
|
40
40
|
exception = Exception.fromMessage(message);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
return back(exception);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
value = this.variable.evaluate(context);
|
|
@@ -52,7 +52,7 @@ export default define(class NodeQuery extends Element {
|
|
|
52
52
|
message = `The '${valueString}' value's '${valueType}' type should be '${NOMINAL_VALUE_TYPE_NAME}'.`,
|
|
53
53
|
exception = Exception.fromMessage(message);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
return back(exception);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
let node;
|
|
@@ -67,7 +67,7 @@ export default define(class NodeQuery extends Element {
|
|
|
67
67
|
message = `The '${valueString}' value's node is null.`,
|
|
68
68
|
exception = Exception.fromMessage(message);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
return back(exception);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const nodes = this.query.execute(node),
|
|
@@ -89,14 +89,14 @@ export default define(class NodeQuery extends Element {
|
|
|
89
89
|
const message = `The length of the returned nodes is ${nodesLength} when it should be 0 or 1.`,
|
|
90
90
|
exception = Exception.fromMessage(message);
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
return back(exception);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const valueString = value.getString();
|
|
96
96
|
|
|
97
97
|
context.debug(`...evaluated the '${nodeQueryString}' function as '${valueString}'.`);
|
|
98
98
|
|
|
99
|
-
return value;
|
|
99
|
+
return forward(value);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
static name = "NodeQuery";
|
|
@@ -24,7 +24,7 @@ export default define(class NodesQuery extends Element {
|
|
|
24
24
|
return this.query;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
evaluate(context) {
|
|
27
|
+
evaluate(context, back, forward) {
|
|
28
28
|
let value;
|
|
29
29
|
|
|
30
30
|
const nodesQueryString = this.getString(); ///
|
|
@@ -35,7 +35,7 @@ export default define(class NodesQuery extends Element {
|
|
|
35
35
|
const message = `Cannot evaluate the '${nodesQueryString}' function because its expression is malformed.`,
|
|
36
36
|
exception = Exception.fromMessage(message);
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
return back(exception);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
value = this.variable.evaluate(context);
|
|
@@ -48,7 +48,7 @@ export default define(class NodesQuery extends Element {
|
|
|
48
48
|
message = `The '${valueString}' value's '${valueType}' type should be '${NOMINAL_VALUE_TYPE_NAME}'.`,
|
|
49
49
|
exception = Exception.fromMessage(message);
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
return back(exception);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
let node;
|
|
@@ -63,7 +63,7 @@ export default define(class NodesQuery extends Element {
|
|
|
63
63
|
message = `The '${valueString}' value's node is null.`,
|
|
64
64
|
exception = Exception.fromMessage(message);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
return back(exception);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const nodes = this.query.execute(node);
|
|
@@ -74,7 +74,7 @@ export default define(class NodesQuery extends Element {
|
|
|
74
74
|
|
|
75
75
|
context.debug(`...evaluated the '${nodesQueryString}' function as '${valueString}'.`);
|
|
76
76
|
|
|
77
|
-
return value;
|
|
77
|
+
return forward(value);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
static name = "NodesQuery";
|
package/src/element/parameter.js
CHANGED
|
@@ -22,7 +22,7 @@ export default define(class Parameter extends Element {
|
|
|
22
22
|
return this.name;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
compareValue(value, context) {
|
|
25
|
+
compareValue(value, context, back, forward) {
|
|
26
26
|
const valueString = value.getString(),
|
|
27
27
|
parameterString = this.getString(); ///
|
|
28
28
|
|
|
@@ -36,10 +36,12 @@ export default define(class Parameter extends Element {
|
|
|
36
36
|
message = `The '${valueString}' value's '${valueType}' type is not equal to the '${parameterString}' parameter's '${typeString}' type.`,
|
|
37
37
|
exception = Exception.fromMessage(message);
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
return back(exception);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
context.debug(`...comparing the '${valueString}' value against the '${parameterString}' parameter.`);
|
|
43
|
+
|
|
44
|
+
return forward();
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
static name = "Parameter";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Element, breakPointUtilities } from "occam-languages";
|
|
3
|
+
import { Element, breakPointUtilities, continuationUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import Exception from "../exception";
|
|
6
6
|
|
|
@@ -9,7 +9,8 @@ import { instantiate } from "../utilities/context";
|
|
|
9
9
|
import { instantiateParameters } from "../process/instantiate";
|
|
10
10
|
import { parametersArrayFromParametersNode } from "../utilities/element";
|
|
11
11
|
|
|
12
|
-
const {
|
|
12
|
+
const { forEach } = continuationUtilities,
|
|
13
|
+
{ breakPointToBreakPointJSON } = breakPointUtilities;
|
|
13
14
|
|
|
14
15
|
export default define(class Parameters extends Element {
|
|
15
16
|
constructor(context, string, node, breakPoint, array) {
|
|
@@ -34,9 +35,11 @@ export default define(class Parameters extends Element {
|
|
|
34
35
|
return parameter;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
forEachParameter(callback
|
|
38
|
+
forEachParameter(callback, back, forward) {
|
|
39
|
+
return forEach(this.array, callback, back, forward);
|
|
40
|
+
}
|
|
38
41
|
|
|
39
|
-
compareValues(values, context) {
|
|
42
|
+
compareValues(values, context, back, forward) {
|
|
40
43
|
const valuesString = values.getString(),
|
|
41
44
|
parametersString = this.getString(); ///
|
|
42
45
|
|
|
@@ -49,18 +52,22 @@ export default define(class Parameters extends Element {
|
|
|
49
52
|
const message = `The '${valuesString}' expressions and '${parametersString}' parameters are not of the same length.`,
|
|
50
53
|
exception = Exception.fromMessage(message);
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
return back(exception);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
this.forEachParameter((parameter, index) => {
|
|
56
|
-
if (parameter
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
parameter.compareValue(value, context);
|
|
58
|
+
return this.forEachParameter((parameter, back, forward, index) => {
|
|
59
|
+
if (parameter === null) {
|
|
60
|
+
return forward();
|
|
60
61
|
}
|
|
61
|
-
});
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const value = values.getValue(index);
|
|
64
|
+
|
|
65
|
+
return parameter.compareValue(value, context, back, forward);
|
|
66
|
+
}, back, () => {
|
|
67
|
+
context.debug(`...compared the '${valuesString}' values against the '${parametersString}' parameters.`);
|
|
68
|
+
|
|
69
|
+
return forward();
|
|
70
|
+
});
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
toJSON() {
|
package/src/element/primitive.js
CHANGED
|
@@ -26,12 +26,12 @@ export default define(class Primitive extends Element {
|
|
|
26
26
|
return this.value;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
evaluate(context) {
|
|
29
|
+
evaluate(context, back, forward) {
|
|
30
30
|
const { Term } = elements,
|
|
31
31
|
primitive = this,
|
|
32
32
|
term = Term.fromPrimitive(primitive, context);
|
|
33
33
|
|
|
34
|
-
return term;
|
|
34
|
+
return forward(term);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
isEqualTo(primitive) {
|
package/src/element/procedure.js
CHANGED
|
@@ -83,28 +83,28 @@ export default define(class Procedure extends Element {
|
|
|
83
83
|
|
|
84
84
|
context.trace(`Calling the '${procedureString}' function...`);
|
|
85
85
|
|
|
86
|
-
this.parameters.compareValues(values, context)
|
|
86
|
+
return this.parameters.compareValues(values, context, back, () => {
|
|
87
|
+
this.guaranteeReturnBlock();
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
const variables = variablesFromValuesAndParameters(values, this.parameters, context);
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
return this.returnBlock.evaluate(variables, context, back, (value) => {
|
|
92
|
+
const valueType = value.getType(),
|
|
93
|
+
typeEqualToValueType = this.type.isEqualTo(valueType);
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
if (!typeEqualToValueType) {
|
|
96
|
+
const valueString = value.getString(),
|
|
97
|
+
typeString = this.type.getString(),
|
|
98
|
+
message = `The '${valueString}' value's '${typeString}' type is not equal to the '${procedureString}' function's '${typeString}' type.`,
|
|
99
|
+
exception = Exception.fromMessage(message);
|
|
95
100
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
typeString = this.type.getString(),
|
|
99
|
-
message = `The '${valueString}' value's '${typeString}' type is not equal to the '${procedureString}' function's '${typeString}' type.`,
|
|
100
|
-
exception = Exception.fromMessage(message);
|
|
101
|
+
return back(exception);
|
|
102
|
+
}
|
|
101
103
|
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
+
context.debug(`...called the '${procedureString}' function.`);
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return forward(value);
|
|
106
|
+
return forward(value);
|
|
107
|
+
});
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
|