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
|
@@ -39,21 +39,22 @@ export default define(class ProcedureCall extends Element {
|
|
|
39
39
|
const message = `The '${procedureCallString}' function is not present.'`,
|
|
40
40
|
exception = Exception.fromMessage(message);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
return back(exception);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const procedure = context.findProcedureByProcedureName(procedureName)
|
|
46
|
-
values = this.values.evaluate(context);
|
|
45
|
+
const procedure = context.findProcedureByProcedureName(procedureName);
|
|
47
46
|
|
|
48
|
-
return
|
|
49
|
-
return
|
|
50
|
-
|
|
47
|
+
return this.values.evaluate(context, back, (values) => {
|
|
48
|
+
return free((context) => {
|
|
49
|
+
return procedure.call(values, context, back, (value) => {
|
|
50
|
+
const valueString = value.getString();
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
context.debug(`...evaluated the '${procedureCallString}' function call as '${valueString}'.`);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
return forward(value);
|
|
55
|
+
});
|
|
56
|
+
}, context);
|
|
57
|
+
});
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
static name = "ProcedureCall";
|
package/src/element/reduce.js
CHANGED
|
@@ -47,7 +47,7 @@ export default define(class Reduce extends Element {
|
|
|
47
47
|
message = `The '${valueString}' value's '${valueType}' type should be '${LIST_TYPE_NAME}'.`,
|
|
48
48
|
exception = Exception.fromMessage(message);
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
return back(exception);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const primitiveValue = value.getPrimitiveValue(),
|
|
@@ -68,7 +68,7 @@ export default define(class Reduce extends Element {
|
|
|
68
68
|
values.addValue(value);
|
|
69
69
|
|
|
70
70
|
return this.anonymousProcedure.call(values, context, back, forward);
|
|
71
|
-
}, inivialValue, (value) => {
|
|
71
|
+
}, inivialValue, back, (value) => {
|
|
72
72
|
const valueString = value.getString();
|
|
73
73
|
|
|
74
74
|
context.trace(`...evaluated the '${reduceString}' reduce as '${valueString}'.`);
|
|
@@ -15,7 +15,7 @@ export default define(class ReturnStatement extends Element {
|
|
|
15
15
|
return this.value;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
evaluate(context) {
|
|
18
|
+
evaluate(context, back, forward) {
|
|
19
19
|
let value;
|
|
20
20
|
|
|
21
21
|
const returnStatementString = this.getString(); ///
|
|
@@ -28,7 +28,7 @@ export default define(class ReturnStatement extends Element {
|
|
|
28
28
|
|
|
29
29
|
context.debug(`...evaluated the '${returnStatementString}' return statement as '${valueString}'.`);
|
|
30
30
|
|
|
31
|
-
return value;
|
|
31
|
+
return forward(value);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
static name = "ReturnStatement";
|
package/src/element/some.js
CHANGED
|
@@ -42,7 +42,7 @@ export default define(class Some extends Element {
|
|
|
42
42
|
message = `The '${valueString}' value's '${valueType}' type should be '${LIST_TYPE_NAME}'.`,
|
|
43
43
|
exception = Exception.fromMessage(message);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
return back(exception);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const primitiveValue = value.getPrimitiveValue(),
|
|
@@ -62,7 +62,7 @@ export default define(class Some 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 primitiveValue = value.getPrimitiveValue(),
|
|
@@ -24,7 +24,7 @@ export default define(class StartsWith 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 startsWithString = this.getString(); ///
|
|
@@ -41,7 +41,7 @@ export default define(class StartsWith 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 StartsWith extends Element {
|
|
|
53
53
|
|
|
54
54
|
context.debug(`...evaluated the '${startsWithString}' function as '${valueString}'.`);
|
|
55
55
|
|
|
56
|
-
return value;
|
|
56
|
+
return forward(value);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
static name = "StartsWith";
|
|
@@ -17,7 +17,7 @@ export default define(class BracketedTerm extends Element {
|
|
|
17
17
|
|
|
18
18
|
getType() { return this.term.getType(); }
|
|
19
19
|
|
|
20
|
-
evaluate(context) {
|
|
20
|
+
evaluate(context, back, forward) {
|
|
21
21
|
let value;
|
|
22
22
|
|
|
23
23
|
const bracketedTermString = this.getString(); ///
|
|
@@ -30,7 +30,7 @@ export default define(class BracketedTerm extends Element {
|
|
|
30
30
|
|
|
31
31
|
context.debug(`...evaluated the '${bracketedTermString}' bracketed term as '${valueString}'.`);
|
|
32
32
|
|
|
33
|
-
return value;
|
|
33
|
+
return forward(value);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static name = "BracketedTerm";
|
|
@@ -28,7 +28,7 @@ export default define(class ComparisonTerm extends Element {
|
|
|
28
28
|
return this.rightTerm;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
evaluate(context) {
|
|
31
|
+
evaluate(context, back, forward) {
|
|
32
32
|
let value;
|
|
33
33
|
|
|
34
34
|
const comparisonTermString = this.getString(); ///
|
|
@@ -49,7 +49,7 @@ export default define(class ComparisonTerm extends Element {
|
|
|
49
49
|
message = `The '${leftValueString}' left term's type is '${leftValueTypeString}' whereas the '${rightValueString}' right term's type is '${rightValueTypeString}'.`,
|
|
50
50
|
exception = Exception.fromMessage(message);
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
return back(exception);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const leftValueEqualToRightValue = leftValue.isEqualTo(rightValue);
|
|
@@ -66,7 +66,7 @@ export default define(class ComparisonTerm extends Element {
|
|
|
66
66
|
|
|
67
67
|
context.debug(`...evaluated the '${comparisonTermString}' comparison value as '${valueString}'.`);
|
|
68
68
|
|
|
69
|
-
return value;
|
|
69
|
+
return forward(value);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
static name = "ComparisonTerm";
|
|
@@ -34,7 +34,7 @@ export default define(class LogicalTerm extends Element {
|
|
|
34
34
|
return this.rightTerm;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
evaluate(context) {
|
|
37
|
+
evaluate(context, back, forward) {
|
|
38
38
|
let value;
|
|
39
39
|
|
|
40
40
|
const logicalTermString = this.getString(); ///
|
|
@@ -53,7 +53,7 @@ export default define(class LogicalTerm extends Element {
|
|
|
53
53
|
message = `The '${leftValueString}' left term's type is '${leftValueType}' when it should be of type '${BOOLEAN_TYPE_NAME}'.`,
|
|
54
54
|
exception = Exception.fromMessage(message);
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
return back(exception);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (!rightValueTypeBooleanType) {
|
|
@@ -61,7 +61,7 @@ export default define(class LogicalTerm extends Element {
|
|
|
61
61
|
message = `The '${rightValueString}' right term's type is '${rightValueType}' when it should be of type '${BOOLEAN_TYPE_NAME}'.`,
|
|
62
62
|
exception = Exception.fromMessage(message);
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
return back(exception);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const leftValuePrimitiveValue = leftValue.getPrimitiveValue(),
|
|
@@ -78,7 +78,7 @@ export default define(class LogicalTerm extends Element {
|
|
|
78
78
|
|
|
79
79
|
context.debug(`...evaluated the '${logicalTermString}' logical value as '${valueString}'.`);
|
|
80
80
|
|
|
81
|
-
return value;
|
|
81
|
+
return forward(value);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
static name = "LogicalTerm";
|
|
@@ -24,7 +24,7 @@ export default define(class NegatedTerm extends Element {
|
|
|
24
24
|
return this.term;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
evaluate(context) {
|
|
27
|
+
evaluate(context, back, forward) {
|
|
28
28
|
let value;
|
|
29
29
|
|
|
30
30
|
const negatedTermString = this.getString(); ///
|
|
@@ -41,7 +41,7 @@ export default define(class NegatedTerm extends Element {
|
|
|
41
41
|
message = `The '${valueString}' left value's type is '${valueType}' when it should be of type '${BOOLEAN_TYPE_NAME}'.`,
|
|
42
42
|
exception = Exception.fromMessage(message);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
return back(exception);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
let boolean;
|
|
@@ -58,7 +58,7 @@ export default define(class NegatedTerm extends Element {
|
|
|
58
58
|
|
|
59
59
|
context.debug(`...evaluated the '${negatedTermString}' negated value as '${valueString}'.`);
|
|
60
60
|
|
|
61
|
-
return value;
|
|
61
|
+
return forward(value);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
static name = "NegatedTerm";
|
package/src/element/term.js
CHANGED
|
@@ -76,26 +76,22 @@ export default define(class Term extends Element {
|
|
|
76
76
|
return boolean;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
evaluate(context) {
|
|
80
|
-
let value;
|
|
81
|
-
|
|
79
|
+
evaluate(context, back, forward) {
|
|
82
80
|
if (false) {
|
|
83
81
|
///
|
|
84
82
|
} else if (this.variable !== null) {
|
|
85
|
-
|
|
83
|
+
return this.variable.evaluate(context, back, forward);
|
|
86
84
|
} else if (this.primitive !== null) {
|
|
87
|
-
|
|
85
|
+
return this.primitive.evaluate(context, back, forward);
|
|
88
86
|
} else if (this.negatedTerm !== null) {
|
|
89
|
-
|
|
87
|
+
return this.negatedTerm.evaluate(context, back, forward);
|
|
90
88
|
} else if (this.logicalTerm !== null) {
|
|
91
|
-
|
|
89
|
+
return this.logicalTerm.evaluate(context, back, forward);
|
|
92
90
|
} else if (this.bracketedTerm !== null) {
|
|
93
|
-
|
|
91
|
+
return this.bracketedTerm.evaluate(context, back, forward);
|
|
94
92
|
} else if (this.comparisonTerm !== null) {
|
|
95
|
-
|
|
93
|
+
return this.comparisonTerm.evaluate(context, back, forward);
|
|
96
94
|
}
|
|
97
|
-
|
|
98
|
-
return value;
|
|
99
95
|
}
|
|
100
96
|
|
|
101
97
|
isEqualTo(term) {
|
package/src/element/terms.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Element } from "occam-languages";
|
|
3
|
+
import { Element, continuationUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import elements from "../elements";
|
|
6
6
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
8
|
import { termsStringFromTermsArray, valuesStringFromValuesArray } from "../utilities/string";
|
|
9
9
|
|
|
10
|
+
const { map } = continuationUtilities;
|
|
11
|
+
|
|
10
12
|
export default define(class Terms extends Element {
|
|
11
13
|
constructor(context, string, node, breakPoint, array) {
|
|
12
14
|
super(context, string, node, breakPoint);
|
|
@@ -34,28 +36,27 @@ export default define(class Terms extends Element {
|
|
|
34
36
|
this.array.push(term);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
mapTerm(callback
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
mapTerm(callback, back, forward) {
|
|
40
|
+
return map(this.array, callback, back, forward);
|
|
41
|
+
}
|
|
40
42
|
|
|
41
|
-
evaluate(context) {
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
evaluate(context, back, forwarsd) {
|
|
44
|
+
return this.mapTerm((term, back, forward) => {
|
|
45
|
+
return term.evaluate(context, back, forward);
|
|
46
|
+
}, back, (valuesArray) => {
|
|
47
|
+
const valuesString = valuesStringFromValuesArray(valuesArray, context),
|
|
48
|
+
string = valuesString, ///
|
|
49
|
+
array = valuesArray, ///
|
|
50
|
+
node = null,
|
|
51
|
+
breakPoint = null;
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
}),
|
|
47
|
-
valuesString = valuesStringFromValuesArray(valuesArray, context),
|
|
48
|
-
string = valuesString, ///
|
|
49
|
-
array = valuesArray, ///
|
|
50
|
-
node = null,
|
|
51
|
-
breakPoint = null;
|
|
52
|
-
|
|
53
|
-
context = null;
|
|
53
|
+
context = null;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const { Values } = elements,
|
|
56
|
+
values = new Values(context, string, node, breakPoint, array);
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
return forwarsd(values);
|
|
59
|
+
});
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
static name = "Terms";
|
package/src/element/ternary.js
CHANGED
|
@@ -42,7 +42,7 @@ export default define(class Ternary extends Element {
|
|
|
42
42
|
message = `The '${valueString}' value's type is '${valueType}' when it should be of type '${BOOLEAN_TYPE_NAME}'.`,
|
|
43
43
|
exception = Exception.fromMessage(message);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
return back(exception);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const primitiveValue = value.getPrimitiveValue(),
|
package/src/element/toInteger.js
CHANGED
|
@@ -20,7 +20,7 @@ export default define(class ToInteger extends Element {
|
|
|
20
20
|
return this.variable;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
evaluate(context) {
|
|
23
|
+
evaluate(context, back, forward) {
|
|
24
24
|
let value;
|
|
25
25
|
|
|
26
26
|
const toIntegerString = this.getString(); ///
|
|
@@ -41,7 +41,7 @@ export default define(class ToInteger extends Element {
|
|
|
41
41
|
const message = `Cannot evaluate the '${toIntegerString}' function because the '${valueTypeName}' type of its argument is not supported.`,
|
|
42
42
|
exception = Exception.fromMessage(message);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
return back(exception);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
case STRING_TYPE_NAME:
|
|
@@ -53,7 +53,7 @@ export default define(class ToInteger extends Element {
|
|
|
53
53
|
const message = `Cannot evaluate the '${toIntegerString}' function because the '${valueTypeName}' value is not an integer.`,
|
|
54
54
|
exception = Exception.fromMessage(message);
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
return back(exception);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
integer = Number(valueString);
|
|
@@ -68,7 +68,7 @@ export default define(class ToInteger extends Element {
|
|
|
68
68
|
|
|
69
69
|
context.debug(`...evaluated the '${toIntegerString}' function as '${valueString}'.`);
|
|
70
70
|
|
|
71
|
-
return value;
|
|
71
|
+
return forward(value);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
static name = "ToInteger";
|
|
@@ -21,7 +21,7 @@ export default define(class TryInteger extends Element {
|
|
|
21
21
|
return this.variable;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
evaluate(context) {
|
|
24
|
+
evaluate(context, back, forward) {
|
|
25
25
|
let value;
|
|
26
26
|
|
|
27
27
|
const tryIntegerString = this.getString(); ///
|
|
@@ -42,7 +42,7 @@ export default define(class TryInteger extends Element {
|
|
|
42
42
|
const message = `Cannot evaluate the '${tryIntegerString}' function because the '${valueTypeName}' type of its argument is not supported.`,
|
|
43
43
|
exception = Exception.fromMessage(message);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
return back(exception);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
case STRING_TYPE_NAME:
|
|
@@ -61,7 +61,7 @@ export default define(class TryInteger extends Element {
|
|
|
61
61
|
|
|
62
62
|
context.debug(`...evaluated the '${tryIntegerString}' function as '${valueString}'.`);
|
|
63
63
|
|
|
64
|
-
return value;
|
|
64
|
+
return forward(value);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
static name = "TryInteger";
|
package/src/element/value.js
CHANGED
|
@@ -50,18 +50,14 @@ export default define(class Value extends Element {
|
|
|
50
50
|
return boolean;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
evaluate(context) {
|
|
54
|
-
let value;
|
|
55
|
-
|
|
53
|
+
evaluate(context, back, forward) {
|
|
56
54
|
if (false) {
|
|
57
55
|
///
|
|
58
56
|
} else if (this.variable !== null) {
|
|
59
|
-
|
|
57
|
+
return this.variable.evaluate(context, back, forward);
|
|
60
58
|
} else if (this.primitive !== null) {
|
|
61
|
-
|
|
59
|
+
return this.primitive.evaluate(context, back, forward);
|
|
62
60
|
}
|
|
63
|
-
|
|
64
|
-
return value;
|
|
65
61
|
}
|
|
66
62
|
|
|
67
63
|
isEqualTo(value) {
|
package/src/element/values.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Element } from "occam-languages";
|
|
3
|
+
import { Element, continuationUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { valuesStringFromValuesArray } from "../utilities/string";
|
|
7
7
|
|
|
8
|
+
const { map, forEach } = continuationUtilities;
|
|
9
|
+
|
|
8
10
|
export default define(class Values extends Element {
|
|
9
11
|
constructor(context, string, node, breakPoint, array) {
|
|
10
12
|
super(context, string, node, breakPoint);
|
|
@@ -32,27 +34,30 @@ export default define(class Values extends Element {
|
|
|
32
34
|
this.array.push(value);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
mapValue(callback
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
mapValue(callback, back, forward) {
|
|
38
|
+
return map(this.array, callback, back, forward);
|
|
39
|
+
}
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
forEachValue(callback) {
|
|
42
|
+
this.array.forEach(callback);
|
|
43
|
+
}
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
evaluate(context, back, forward) {
|
|
46
|
+
return this.mapValue((value, back, forward) => {
|
|
47
|
+
return value.evaluate(context, back, forward);
|
|
48
|
+
}, back, (valuesArray) => {
|
|
49
|
+
const valuesString = valuesStringFromValuesArray(valuesArray, context),
|
|
50
|
+
string = valuesString, ///
|
|
51
|
+
array = valuesArray, ///
|
|
52
|
+
node = null,
|
|
53
|
+
breakPoint = null;
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
context = null;
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
const values = new Values(context, string, node, breakPoint, array);
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
return forward(values);
|
|
60
|
+
});
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
static name = "Values";
|
package/src/element/variable.js
CHANGED
|
@@ -34,7 +34,7 @@ export default define(class Variable extends Element {
|
|
|
34
34
|
return comparesToVariableName;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
evaluate(context) {
|
|
37
|
+
evaluate(context, back, forward) {
|
|
38
38
|
const variableString = this.getString(); ///
|
|
39
39
|
|
|
40
40
|
context.trace(`Evaluating the '${variableString}' variable...`);
|
|
@@ -47,7 +47,7 @@ export default define(class Variable extends Element {
|
|
|
47
47
|
const message = `The '${variableString}' variable is not present.'`,
|
|
48
48
|
exception = Exception.fromMessage(message);
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
return back(exception);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const variable = context.findVariableByVariableName(variableName),
|
|
@@ -56,7 +56,7 @@ export default define(class Variable extends Element {
|
|
|
56
56
|
|
|
57
57
|
context.debug(`...evaluated the '${variableString}' variable as the '${valueString}' value.`);
|
|
58
58
|
|
|
59
|
-
return value;
|
|
59
|
+
return forward(value);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
assign(value, context, back, forward) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { continuationUtilities } from "occam-languages";
|
|
4
|
+
|
|
3
5
|
import elements from "./elements";
|
|
4
6
|
import Exception from "./exception";
|
|
5
7
|
import NominalValueProperty from "./nominalValueProperty";
|
|
@@ -8,6 +10,8 @@ import { nominalValuePropertiesStringFromNominalValuePropertiesArray } from "./u
|
|
|
8
10
|
import { LIST_TYPE_NAME, STRING_TYPE_NAME, BOOLEAN_TYPE_NAME, NOMINAL_VALUE_TYPE_NAME } from "./typeNames";
|
|
9
11
|
import { CONTENT_PARAMETER_NAME, TERMINAL_PARAMETER_NAME, CHILD_NODES_PARAMETER_NAME, NO_WHITESPACE_PARAMETER_NAME } from "./parameterNames";
|
|
10
12
|
|
|
13
|
+
const { some } = continuationUtilities;
|
|
14
|
+
|
|
11
15
|
class NominalValueProperties {
|
|
12
16
|
constructor(string, array) {
|
|
13
17
|
this.string = string;
|
|
@@ -22,36 +26,36 @@ class NominalValueProperties {
|
|
|
22
26
|
return this.array;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
someNominalValueProperty(callback
|
|
29
|
+
someNominalValueProperty(callback, back, forward) {
|
|
30
|
+
return some(this.array, callback, back, forward);
|
|
31
|
+
}
|
|
26
32
|
|
|
27
|
-
compareNamedBinding(namedBinding, context) {
|
|
33
|
+
compareNamedBinding(namedBinding, context, back, forward) {
|
|
28
34
|
const namedBindingString = namedBinding.getString(),
|
|
29
35
|
nominalValuePropertiesString = this.string; ///
|
|
30
36
|
|
|
31
37
|
context.trace(`Comparing the '${namedBindingString}' named binding with the '${nominalValuePropertiesString}' node properties...`);
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
return this.someNominalValueProperty((nominalValueProperty, back, forward) => {
|
|
40
|
+
return nominalValueProperty.compareNamedBinding(namedBinding, context, back, forward);
|
|
41
|
+
}, back, (namedBindingsCompare) => {
|
|
42
|
+
if (!namedBindingsCompare) {
|
|
43
|
+
const message = `The '${namedBindingString}' named binding does not compmare to any of the '${nominalValuePropertiesString}' node properties.`,
|
|
44
|
+
exception = Exception.fromMessage(message);
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
return true;
|
|
46
|
+
return back(exception);
|
|
38
47
|
}
|
|
39
|
-
});
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
const message = `The '${namedBindingString}' named binding does not compmare to any of the '${nominalValuePropertiesString}' node properties.`,
|
|
43
|
-
exception = Exception.fromMessage(message);
|
|
49
|
+
context.debug(`...compared the '${namedBindingString}' named binding with the '${nominalValuePropertiesString}' node properties.`);
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
context.debug(`...compared the '${namedBindingString}' named binding with the '${nominalValuePropertiesString}' node properties.`);
|
|
51
|
+
return forward();
|
|
52
|
+
});
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
compareNamedBindings(namedBindings, context) {
|
|
52
|
-
namedBindings.forEachNamedBinding((namedBinding) => {
|
|
53
|
-
this.compareNamedBinding(namedBinding, context);
|
|
54
|
-
});
|
|
55
|
+
compareNamedBindings(namedBindings, context, back, forward) {
|
|
56
|
+
return namedBindings.forEachNamedBinding((namedBinding, back, forward) => {
|
|
57
|
+
return this.compareNamedBinding(namedBinding, context, back, forward);
|
|
58
|
+
}, back, forward);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
static fromNothing() {
|
|
@@ -21,7 +21,7 @@ export default class NominalValueProperty {
|
|
|
21
21
|
return this.name;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
compareNamedBinding(namedBinding, context) {
|
|
24
|
+
compareNamedBinding(namedBinding, context, back, forward) {
|
|
25
25
|
let namedBindingCompares = false;
|
|
26
26
|
|
|
27
27
|
const nominalValuePropertyString = this.string, ///
|
|
@@ -42,7 +42,7 @@ export default class NominalValueProperty {
|
|
|
42
42
|
context.debug(`...compared the '${nominalValuePropertyString}' node property with the '${namedBindingString}' named binding.`);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
return namedBindingCompares;
|
|
45
|
+
return forward(namedBindingCompares);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
static name = "Parameter";
|