occam-furtle 2.0.78 → 2.0.82
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/constants.js +9 -1
- package/lib/dom/assignment/array.js +6 -2
- package/lib/dom/assignment/object.js +6 -2
- package/lib/dom/assignment/variable.js +6 -2
- package/lib/dom/assignments/variable.js +10 -2
- package/lib/dom/block/return.js +8 -4
- package/lib/dom/block.js +6 -2
- package/lib/dom/comparison.js +7 -3
- package/lib/dom/conditionalBlocks.js +8 -8
- package/lib/dom/declaration/procedure.js +6 -2
- package/lib/dom/every.js +175 -0
- package/lib/dom/parameter/named.js +10 -2
- package/lib/dom/parameters/named.js +10 -2
- package/lib/dom/procedure/anonymous.js +16 -2
- package/lib/dom/procedureCall/anonymous.js +6 -2
- package/lib/dom/reduce.js +177 -0
- package/lib/dom/statement/return.js +6 -2
- package/lib/dom/ternary.js +5 -7
- package/lib/dom/value/bitwise.js +7 -3
- package/lib/dom/value/bracketed.js +6 -2
- package/lib/dom/value/negated.js +6 -2
- package/lib/dom/value.js +58 -25
- package/lib/dom/values.js +7 -1
- package/lib/dom/variable.js +18 -4
- package/lib/index.js +3 -1
- package/lib/nodeProperty.js +2 -2
- package/package.json +5 -5
- package/src/constants.js +2 -0
- package/src/dom/assignment/array.js +10 -3
- package/src/dom/assignment/object.js +10 -3
- package/src/dom/assignment/variable.js +9 -2
- package/src/dom/assignments/variable.js +18 -4
- package/src/dom/block/return.js +12 -6
- package/src/dom/block.js +9 -4
- package/src/dom/comparison.js +15 -5
- package/src/dom/conditionalBlocks.js +10 -10
- package/src/dom/declaration/procedure.js +8 -2
- package/src/dom/every.js +117 -0
- package/src/dom/parameter/named.js +14 -2
- package/src/dom/parameters/named.js +16 -2
- package/src/dom/procedure/anonymous.js +18 -0
- package/src/dom/procedureCall/anonymous.js +10 -3
- package/src/dom/reduce.js +117 -0
- package/src/dom/statement/return.js +8 -2
- package/src/dom/ternary.js +8 -15
- package/src/dom/value/bitwise.js +14 -4
- package/src/dom/value/bracketed.js +9 -3
- package/src/dom/value/negated.js +9 -3
- package/src/dom/value.js +66 -25
- package/src/dom/values.js +4 -0
- package/src/dom/variable.js +20 -2
- package/src/index.js +2 -0
- package/src/nodeProperty.js +1 -1
|
@@ -80,14 +80,26 @@ export default domAssigned(class NamedParameter {
|
|
|
80
80
|
const type = typeFromNamedParameterNode(namedParameterNode, context),
|
|
81
81
|
name = nameFromNamedParameterNode(namedParameterNode, context),
|
|
82
82
|
asName = asNameFromNamedParameterNode(namedParameterNode, context),
|
|
83
|
-
|
|
84
|
-
string = context.nodeAsString(node),
|
|
83
|
+
string = stringFromTypeNameAndAsName(type, name, asName, context),
|
|
85
84
|
namedParameter = new NamedParameter(string, type, name, asName);
|
|
86
85
|
|
|
87
86
|
return namedParameter;
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
89
|
|
|
90
|
+
function stringFromTypeNameAndAsName(type, name, asName, context) {
|
|
91
|
+
let string;
|
|
92
|
+
|
|
93
|
+
string = `${type} ${name}`;
|
|
94
|
+
|
|
95
|
+
if (asName !== null) {
|
|
96
|
+
string = `${string} As ${asName}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
91
103
|
function typeFromNamedParameterNode(namedParameterNode, context) {
|
|
92
104
|
const typeTerminalNode = typeTerminalNodeQuery(namedParameterNode),
|
|
93
105
|
typeTerminalNodeContent = typeTerminalNode.getContent(),
|
|
@@ -107,16 +107,30 @@ export default domAssigned(class NamedParameters {
|
|
|
107
107
|
static fromObjectAssignmentNode(objectAssignmentNode, context) {
|
|
108
108
|
const objectAssignmentNamedParametersNode = objectAssignmentNamedParametersNodeQuery(objectAssignmentNode),
|
|
109
109
|
parametersNode = objectAssignmentNamedParametersNode, ///
|
|
110
|
-
node = parametersNode, ///
|
|
111
|
-
string = context.nodeAsString(node),
|
|
112
110
|
namedParameterNodes = namedParameterNodesQuery(parametersNode),
|
|
113
111
|
array = arrayFromNamedParameterNodes(namedParameterNodes, context),
|
|
112
|
+
string = stringFromArray(array, context),
|
|
114
113
|
namedParameters = new NamedParameters(string, array);
|
|
115
114
|
|
|
116
115
|
return namedParameters;
|
|
117
116
|
}
|
|
118
117
|
});
|
|
119
118
|
|
|
119
|
+
function stringFromArray(array, context) {
|
|
120
|
+
const namedParametersSString = array.reduce((namedParametersSString, namedParameter) => {
|
|
121
|
+
const namedParameterString = namedParameter.getString();
|
|
122
|
+
|
|
123
|
+
namedParametersSString = (namedParametersSString === null) ?
|
|
124
|
+
namedParameterString :
|
|
125
|
+
`${namedParametersSString}, ${namedParameterString}`;
|
|
126
|
+
|
|
127
|
+
return namedParametersSString;
|
|
128
|
+
}, null),
|
|
129
|
+
string = namedParametersSString; ///
|
|
130
|
+
|
|
131
|
+
return string;
|
|
132
|
+
}
|
|
133
|
+
|
|
120
134
|
function arrayFromNamedParameterNodes(namedParameterNodes, context) {
|
|
121
135
|
const { NamedParameter } = dom,
|
|
122
136
|
array = namedParameterNodes.map((namedParameterNode) => { ///
|
|
@@ -10,6 +10,8 @@ import { variablesFromValuesAndParameters } from "../procedure";
|
|
|
10
10
|
const parametersNodeQuery = nodeQuery("/anonymousProcedure/parameters"),
|
|
11
11
|
typeTerminalNodeQuery = nodeQuery("/anonymousProcedure/@type"),
|
|
12
12
|
someAnonymousProcedureNodeQuery = nodeQuery("/some/anonymousProcedure"),
|
|
13
|
+
everyAnonymousProcedureNodeQuery = nodeQuery("/every/anonymousProcedure"),
|
|
14
|
+
reduceAnonymousProcedureNodeQuery = nodeQuery("/reduce/anonymousProcedure"),
|
|
13
15
|
anonymousProcedureCallAnonymousProcedureNodeQuery = nodeQuery("/anonymousProcedureCall/anonymousProcedure");
|
|
14
16
|
|
|
15
17
|
export default domAssigned(class AnonymousProcedure {
|
|
@@ -71,6 +73,22 @@ export default domAssigned(class AnonymousProcedure {
|
|
|
71
73
|
return anonymousProcedure;
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
static fromEveryNode(everyNode, context) {
|
|
77
|
+
const everyAnonymousProcedureNode = everyAnonymousProcedureNodeQuery(everyNode),
|
|
78
|
+
anonymousProcedureNode = everyAnonymousProcedureNode, ///
|
|
79
|
+
anonymousProcedure = anonymousProcedureFromAnonymousProcedureNode(anonymousProcedureNode, context);
|
|
80
|
+
|
|
81
|
+
return anonymousProcedure;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static fromReduceNode(reduceNode, context) {
|
|
85
|
+
const reduceAnonymousProcedureNode = reduceAnonymousProcedureNodeQuery(reduceNode),
|
|
86
|
+
anonymousProcedureNode = reduceAnonymousProcedureNode, ///
|
|
87
|
+
anonymousProcedure = anonymousProcedureFromAnonymousProcedureNode(anonymousProcedureNode, context);
|
|
88
|
+
|
|
89
|
+
return anonymousProcedure;
|
|
90
|
+
}
|
|
91
|
+
|
|
74
92
|
static fromAnonymousProcedureCallNode(anonymousProcedureCallNode, context) {
|
|
75
93
|
const anonymousProcedureCallAnonymousProcedureNode = anonymousProcedureCallAnonymousProcedureNodeQuery(anonymousProcedureCallNode),
|
|
76
94
|
anonymousProcedureNode = anonymousProcedureCallAnonymousProcedureNode, ///
|
|
@@ -48,10 +48,9 @@ export default domAssigned(class AnonymousProcedureCall {
|
|
|
48
48
|
|
|
49
49
|
if (anonymousProcedureCallNode !== null) {
|
|
50
50
|
const { Values, AnonymousProcedure } = dom,
|
|
51
|
-
node = anonymousProcedureCallNode, ///
|
|
52
|
-
string = context.nodeAsString(node),
|
|
53
51
|
anonymousProcedure = AnonymousProcedure.fromAnonymousProcedureCallNode(anonymousProcedureCallNode, context),
|
|
54
|
-
values = Values.fromAnonymousProcedureCallNode(anonymousProcedureCallNode, context)
|
|
52
|
+
values = Values.fromAnonymousProcedureCallNode(anonymousProcedureCallNode, context),
|
|
53
|
+
string = stringFromAnonymousProcedureAndValues(anonymousProcedure, values, context);
|
|
55
54
|
|
|
56
55
|
anonymousProcedureCall = new AnonymousProcedureCall(string, anonymousProcedure, values);
|
|
57
56
|
}
|
|
@@ -59,3 +58,11 @@ export default domAssigned(class AnonymousProcedureCall {
|
|
|
59
58
|
return anonymousProcedureCall;
|
|
60
59
|
}
|
|
61
60
|
});
|
|
61
|
+
|
|
62
|
+
function stringFromAnonymousProcedureAndValues(anonymousProcedure, values, context) {
|
|
63
|
+
const anonymousProcedureString = anonymousProcedure.getString(),
|
|
64
|
+
valuesString = values.getString(),
|
|
65
|
+
string = `(${anonymousProcedureString})(${valuesString})`;
|
|
66
|
+
|
|
67
|
+
return string;
|
|
68
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
import Exception from "../exception";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
import { domAssigned } from "../dom";
|
|
8
|
+
import { NODES_TYPE, BOOLEAN_TYPE } from "../types";
|
|
9
|
+
|
|
10
|
+
const variableNodeQuery = nodeQuery("/reduce/variable"),
|
|
11
|
+
parametersNodeQuery = nodeQuery("/reduce/anonymousProcedure/parameters"),
|
|
12
|
+
valueReduceNodeQuery = nodeQuery("/value/reduce"),
|
|
13
|
+
initialValueNodeQuery = nodeQuery("/reduce/value"); ///
|
|
14
|
+
|
|
15
|
+
export default domAssigned(class Reduce {
|
|
16
|
+
constructor(string, variable, initialValue, anonymousProcedure) {
|
|
17
|
+
this.string = string;
|
|
18
|
+
this.variable = variable;
|
|
19
|
+
this.initialValue = initialValue;
|
|
20
|
+
this.anonymousProcedure = anonymousProcedure;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getString() {
|
|
24
|
+
return this.string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getVariable() {
|
|
28
|
+
return this.variable;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getInitialValue() {
|
|
32
|
+
return this.initialValue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getAnonymousProcedure() {
|
|
36
|
+
return this.anonymousProcedure;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
evaluate(context) {
|
|
40
|
+
let value;
|
|
41
|
+
|
|
42
|
+
const reduceString = this.getString();
|
|
43
|
+
|
|
44
|
+
context.trace(`Evaluating the '${reduceString}' reduce...`);
|
|
45
|
+
|
|
46
|
+
value = this.variable.evaluate(context);
|
|
47
|
+
|
|
48
|
+
const valueType = value.getType();
|
|
49
|
+
|
|
50
|
+
if (valueType !== NODES_TYPE) {
|
|
51
|
+
const valueString = value.asString(context),
|
|
52
|
+
message = `The ${valueString} value's '${valueType}' type should be '${NODES_TYPE}'.`,
|
|
53
|
+
exception = Exception.fromMessage(message);
|
|
54
|
+
|
|
55
|
+
throw exception;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const nodes = value.getNodes(),
|
|
59
|
+
initialValue = this.initialValue.evaluate(context);
|
|
60
|
+
|
|
61
|
+
value = nodes.reduce((currentValue, node) => {
|
|
62
|
+
let value;
|
|
63
|
+
|
|
64
|
+
const { Value, Values } = dom;
|
|
65
|
+
|
|
66
|
+
value = currentValue; ///
|
|
67
|
+
|
|
68
|
+
const values = Values.fromValue(value, context);
|
|
69
|
+
|
|
70
|
+
value = Value.fromNode(node, context);
|
|
71
|
+
|
|
72
|
+
values.addValue(value);
|
|
73
|
+
|
|
74
|
+
value = this.anonymousProcedure.call(values, context);
|
|
75
|
+
|
|
76
|
+
return value;
|
|
77
|
+
}, initialValue);
|
|
78
|
+
|
|
79
|
+
context.trace(`...evaluated the '${reduceString}' reduce.`);
|
|
80
|
+
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static name = "Reduce";
|
|
85
|
+
|
|
86
|
+
static fromValueNode(valueNode, context) {
|
|
87
|
+
let reduce = null;
|
|
88
|
+
|
|
89
|
+
const valueReduceNode = valueReduceNodeQuery(valueNode);
|
|
90
|
+
|
|
91
|
+
if (valueReduceNode !== null) {
|
|
92
|
+
const { Value, Variable, AnonymousProcedure } = dom,
|
|
93
|
+
reduceNode = valueReduceNode, ///
|
|
94
|
+
string = stringFromReduceNode(reduceNode, context),
|
|
95
|
+
value = Value.fromReduceNode(reduceNode, context),
|
|
96
|
+
variable = Variable.fromReduceNode(reduceNode, context),
|
|
97
|
+
initialValue = value, ///
|
|
98
|
+
anonymousProcedure = AnonymousProcedure.fromReduceNode(reduceNode, context);
|
|
99
|
+
|
|
100
|
+
reduce = new Reduce(string, variable, initialValue, anonymousProcedure);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return reduce;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
function stringFromReduceNode(reduceNode, context) {
|
|
108
|
+
const variableNode = variableNodeQuery(reduceNode),
|
|
109
|
+
parametersNode = parametersNodeQuery(reduceNode),
|
|
110
|
+
initialValueNode = initialValueNodeQuery(reduceNode),
|
|
111
|
+
variableString = context.nodeAsString(variableNode),
|
|
112
|
+
parametersString = context.nodeAsString(parametersNode),
|
|
113
|
+
initialValueString = context.nodeAsString(initialValueNode),
|
|
114
|
+
string = `Reduce(${variableString}, (${parametersString}) { ... }, ${initialValueString})`;
|
|
115
|
+
|
|
116
|
+
return string;
|
|
117
|
+
}
|
|
@@ -40,11 +40,17 @@ export default domAssigned(class ReturnStatement {
|
|
|
40
40
|
static fromReturnBlockNode(returnBlockNode, context) {
|
|
41
41
|
const { Value } = dom,
|
|
42
42
|
returnStatementNode = returnStatementNodeQuery(returnBlockNode),
|
|
43
|
-
node = returnStatementNode, ///
|
|
44
|
-
string = context.nodeAsString(node),
|
|
45
43
|
value = Value.fromReturnStatementNode(returnStatementNode, context),
|
|
44
|
+
string = stringFromValue(value, context),
|
|
46
45
|
returnStatement = new ReturnStatement(string, value);
|
|
47
46
|
|
|
48
47
|
return returnStatement;
|
|
49
48
|
}
|
|
50
49
|
});
|
|
50
|
+
|
|
51
|
+
function stringFromValue(value, context) {
|
|
52
|
+
const valueString = value.asString(context),
|
|
53
|
+
string = `Return ${valueString};`;
|
|
54
|
+
|
|
55
|
+
return string;
|
|
56
|
+
}
|
package/src/dom/ternary.js
CHANGED
|
@@ -7,8 +7,7 @@ import { nodeQuery } from "../utilities/query";
|
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
import { BOOLEAN_TYPE } from "../types";
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
ifValueNodeQuery = nodeQuery("/ternary/value[1]"),
|
|
10
|
+
const ifValueNodeQuery = nodeQuery("/ternary/value[1]"),
|
|
12
11
|
ternaryNodeQuery = nodeQuery("/value/ternary"),
|
|
13
12
|
elseValueNodeQuery = nodeQuery("/ternary/value[2]");
|
|
14
13
|
|
|
@@ -75,12 +74,12 @@ export default domAssigned(class Ternary {
|
|
|
75
74
|
|
|
76
75
|
if (ternaryNode !== null) {
|
|
77
76
|
const { Value } = dom,
|
|
78
|
-
string = stringFromTernaryNode(ternaryNode, context),
|
|
79
77
|
ifValueNode = ifValueNodeQuery(ternaryNode),
|
|
80
78
|
elseValueNode = elseValueNodeQuery(ternaryNode),
|
|
81
79
|
value = Value.fromTernaryNode(ternaryNode, context),
|
|
82
80
|
ifValue = Value.fromValueNode(ifValueNode, context),
|
|
83
|
-
elseValue = Value.fromValueNode(elseValueNode, context)
|
|
81
|
+
elseValue = Value.fromValueNode(elseValueNode, context),
|
|
82
|
+
string = stringFromValueIfValueAndElseValue(value, ifValue, elseValue, context);
|
|
84
83
|
|
|
85
84
|
ternary = new Ternary(string, value, ifValue, elseValue);
|
|
86
85
|
}
|
|
@@ -89,17 +88,11 @@ export default domAssigned(class Ternary {
|
|
|
89
88
|
}
|
|
90
89
|
});
|
|
91
90
|
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
elseValueNode = elseValueNodeQuery(ternaryNode),
|
|
98
|
-
ifValueString = context.nodeAsString(ifValueNode),
|
|
99
|
-
elseValueString = context.nodeAsString(elseValueNode),
|
|
100
|
-
valueString = context.nodeAsString(valueNode);
|
|
101
|
-
|
|
102
|
-
string = `If (${valueString}) ${ifValueString} ${elseValueString}`;
|
|
91
|
+
function stringFromValueIfValueAndElseValue(value, ifValue, elseValue, context) {
|
|
92
|
+
const valueString = value.getString(),
|
|
93
|
+
ifValueString = ifValue.getString(),
|
|
94
|
+
elseValueString = elseValue.getString(),
|
|
95
|
+
string = `If (${valueString}) ${ifValueString} ${elseValueString}`;
|
|
103
96
|
|
|
104
97
|
return string;
|
|
105
98
|
}
|
package/src/dom/value/bitwise.js
CHANGED
|
@@ -5,8 +5,8 @@ import Exception from "../../exception";
|
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../../utilities/query";
|
|
7
7
|
import { domAssigned } from "../../dom";
|
|
8
|
-
import { DISJUNCTION } from "../../constants";
|
|
9
8
|
import { BOOLEAN_TYPE } from "../../types";
|
|
9
|
+
import { CONJUNCTION, DISJUNCTION } from "../../constants";
|
|
10
10
|
|
|
11
11
|
const terminalNodeQuery = nodeQuery("/bitwiseValue/@*"),
|
|
12
12
|
leftValueNodeQuery = nodeQuery("/bitwiseValue/value[0]"),
|
|
@@ -93,14 +93,13 @@ export default domAssigned(class BitwiseValue {
|
|
|
93
93
|
|
|
94
94
|
if (bitwiseValueNode !== null) {
|
|
95
95
|
const { Value } = dom,
|
|
96
|
-
node = bitwiseValueNode, //
|
|
97
|
-
string = context.nodeAsString(node),
|
|
98
96
|
type = BOOLEAN_TYPE,
|
|
99
97
|
leftValueNode = leftValueNodeQuery(bitwiseValueNode),
|
|
100
98
|
rightValueNode = rightValueNodeQuery(bitwiseValueNode),
|
|
101
99
|
disjoint = disjointFromBitwiseValueNode(bitwiseValueNode, context),
|
|
102
100
|
leftValue = Value.fromValueNode(leftValueNode, context),
|
|
103
|
-
rightValue = Value.fromValueNode(rightValueNode, context)
|
|
101
|
+
rightValue = Value.fromValueNode(rightValueNode, context),
|
|
102
|
+
string = stringFromTypeDisjointLeftValueAndRightValue(disjoint, leftValue, rightValue, context);
|
|
104
103
|
|
|
105
104
|
bitwiseValue = new BitwiseValue(string, type, disjoint, leftValue, rightValue);
|
|
106
105
|
}
|
|
@@ -116,3 +115,14 @@ function disjointFromBitwiseValueNode(bitwiseValueNode, context) {
|
|
|
116
115
|
|
|
117
116
|
return disjoint;
|
|
118
117
|
}
|
|
118
|
+
|
|
119
|
+
function stringFromTypeDisjointLeftValueAndRightValue(disjoint, leftValue, rightValue, context) {
|
|
120
|
+
const operatorString = disjoint ?
|
|
121
|
+
DISJUNCTION :
|
|
122
|
+
CONJUNCTION,
|
|
123
|
+
leftValueString = leftValue.asString(context),
|
|
124
|
+
rightValueString = rightValue.asString(context),
|
|
125
|
+
string = `${leftValueString} ${operatorString} ${rightValueString}`;
|
|
126
|
+
|
|
127
|
+
return string;
|
|
128
|
+
}
|
|
@@ -48,10 +48,9 @@ export default domAssigned(class BracketedValue {
|
|
|
48
48
|
if (valueBracketedValueNode !== null) {
|
|
49
49
|
const { Value } = dom,
|
|
50
50
|
bracketedValueNode = valueBracketedValueNode, ///
|
|
51
|
-
node = bracketedValueNode, ///
|
|
52
|
-
string = context.nodeAsString(node),
|
|
53
51
|
valueNode = valueNodeQuery(bracketedValueNode),
|
|
54
|
-
value = Value.fromValueNode(valueNode, context)
|
|
52
|
+
value = Value.fromValueNode(valueNode, context),
|
|
53
|
+
string = stringFromValue(value, context);
|
|
55
54
|
|
|
56
55
|
bracketedValue = new BracketedValue(string, value);
|
|
57
56
|
}
|
|
@@ -59,3 +58,10 @@ export default domAssigned(class BracketedValue {
|
|
|
59
58
|
return bracketedValue;
|
|
60
59
|
}
|
|
61
60
|
});
|
|
61
|
+
|
|
62
|
+
function stringFromValue(value, context) {
|
|
63
|
+
const valueString = value.asString(context),
|
|
64
|
+
string = `(${valueString})`;
|
|
65
|
+
|
|
66
|
+
return string;
|
|
67
|
+
}
|
package/src/dom/value/negated.js
CHANGED
|
@@ -70,11 +70,10 @@ export default domAssigned(class NegatedValue {
|
|
|
70
70
|
|
|
71
71
|
if (negatedValueNode !== null) {
|
|
72
72
|
const { Value } = dom,
|
|
73
|
-
node = negatedValueNode, //
|
|
74
|
-
string = context.nodeAsString(node),
|
|
75
73
|
type = BOOLEAN_TYPE,
|
|
76
74
|
valueNode = valueNodeQuery(negatedValueNode),
|
|
77
|
-
value = Value.fromValueNode(valueNode, context)
|
|
75
|
+
value = Value.fromValueNode(valueNode, context),
|
|
76
|
+
string = stringFromValue(value, context);
|
|
78
77
|
|
|
79
78
|
negatedValue = new NegatedValue(string, type, value);
|
|
80
79
|
}
|
|
@@ -82,3 +81,10 @@ export default domAssigned(class NegatedValue {
|
|
|
82
81
|
return negatedValue;
|
|
83
82
|
}
|
|
84
83
|
});
|
|
84
|
+
|
|
85
|
+
function stringFromValue(value, context) {
|
|
86
|
+
const valueString = value.asString(context),
|
|
87
|
+
string = `!${valueString}`;
|
|
88
|
+
|
|
89
|
+
return string;
|
|
90
|
+
}
|
package/src/dom/value.js
CHANGED
|
@@ -12,7 +12,8 @@ import { NODE_TYPE, NODES_TYPE, NUMBER_TYPE, STRING_TYPE, BOOLEAN_TYPE } from ".
|
|
|
12
12
|
|
|
13
13
|
const { match } = arrayUtilities;
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const reduceValueNodeQuery = nodeQuery("/reduce/value"),
|
|
16
|
+
ternaryValueNodeQuery = nodeQuery("/ternary/value"),
|
|
16
17
|
numberTerminalNodeQuery = nodeQuery("/value/@number"),
|
|
17
18
|
conditionValueNodeQuery = nodeQuery("/condition/value"),
|
|
18
19
|
primitiveTerminalNodeQuery = nodeQuery("/value/@primitive"),
|
|
@@ -22,13 +23,15 @@ const ternaryValueNodeQuery = nodeQuery("/ternary/value"),
|
|
|
22
23
|
variableAssignmentValueNodeQuery = nodeQuery("/variableAssignment/value");
|
|
23
24
|
|
|
24
25
|
export default domAssigned(class Value {
|
|
25
|
-
constructor(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall) {
|
|
26
|
+
constructor(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall) {
|
|
26
27
|
this.node = node;
|
|
27
28
|
this.nodes = nodes;
|
|
28
29
|
this.number = number;
|
|
29
30
|
this.string = string;
|
|
30
31
|
this.boolean = boolean;
|
|
31
32
|
this.some = some;
|
|
33
|
+
this.every = every;
|
|
34
|
+
this.reduce = reduce;
|
|
32
35
|
this.ternary = ternary;
|
|
33
36
|
this.variable = variable;
|
|
34
37
|
this.nodeQuery = nodeQuery;
|
|
@@ -65,6 +68,14 @@ export default domAssigned(class Value {
|
|
|
65
68
|
return this.some;
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
getEvery() {
|
|
72
|
+
return this.every;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getReduce() {
|
|
76
|
+
return this.reduce;
|
|
77
|
+
}
|
|
78
|
+
|
|
68
79
|
getTernary() {
|
|
69
80
|
return this.ternay;
|
|
70
81
|
}
|
|
@@ -122,6 +133,10 @@ export default domAssigned(class Value {
|
|
|
122
133
|
type = BOOLEAN_TYPE;
|
|
123
134
|
} else if (this.some !== null) {
|
|
124
135
|
type = this.some.getType();
|
|
136
|
+
} else if (this.every !== null) {
|
|
137
|
+
type = this.every.getType();
|
|
138
|
+
} else if (this.reduce !== null) {
|
|
139
|
+
type = this.reduce.getType();
|
|
125
140
|
} else if (this.ternary !== null) {
|
|
126
141
|
type = this.ternary.getType();
|
|
127
142
|
} else if (this.variable !== null) {
|
|
@@ -157,33 +172,37 @@ export default domAssigned(class Value {
|
|
|
157
172
|
} else if (this.nodes !== null) {
|
|
158
173
|
string = nodesAsString(this.nodes, context);
|
|
159
174
|
} else if (this.number !== null) {
|
|
160
|
-
string = numberAsString(this.number
|
|
175
|
+
string = numberAsString(this.number);
|
|
161
176
|
} else if (this.string !== null) {
|
|
162
|
-
string = stringAsString(this.string
|
|
177
|
+
string = stringAsString(this.string)
|
|
163
178
|
} else if (this.boolean !== null) {
|
|
164
|
-
string = booleanAsString(this.boolean
|
|
179
|
+
string = booleanAsString(this.boolean)
|
|
165
180
|
} else if (this.some !== null) {
|
|
166
|
-
string = this.some.
|
|
181
|
+
string = this.some.getString();
|
|
182
|
+
} else if (this.every !== null) {
|
|
183
|
+
string = this.every.getString();
|
|
184
|
+
} else if (this.reduce !== null) {
|
|
185
|
+
string = this.reduce.getString();
|
|
167
186
|
} else if (this.ternary !== null) {
|
|
168
|
-
string = this.ternary.
|
|
187
|
+
string = this.ternary.getString();
|
|
169
188
|
} else if (this.variable !== null) {
|
|
170
|
-
string = this.variable.
|
|
189
|
+
string = this.variable.getString();
|
|
171
190
|
} else if (this.nodeQuery !== null) {
|
|
172
|
-
string = this.nodeQuery.
|
|
191
|
+
string = this.nodeQuery.getString();
|
|
173
192
|
} else if (this.nodesQuery !== null) {
|
|
174
|
-
string = this.nodesQuery.
|
|
193
|
+
string = this.nodesQuery.getString();
|
|
175
194
|
} else if (this.comparison !== null) {
|
|
176
|
-
string = this.comparison.
|
|
195
|
+
string = this.comparison.getString();
|
|
177
196
|
} else if (this.negatedValue !== null) {
|
|
178
|
-
string = this.negatedValue.
|
|
197
|
+
string = this.negatedValue.getString();
|
|
179
198
|
} else if (this.bitwiseValue !== null) {
|
|
180
|
-
string = this.bitwiseValue.
|
|
199
|
+
string = this.bitwiseValue.getString();
|
|
181
200
|
} else if (this.bracketedValue !== null) {
|
|
182
|
-
string = this.bracketedValue.
|
|
201
|
+
string = this.bracketedValue.getString();
|
|
183
202
|
} else if (this.procedureCall !== null) {
|
|
184
|
-
string = this.procedureCall.
|
|
203
|
+
string = this.procedureCall.getString();
|
|
185
204
|
} else if (this.anonymousProcedureCall !== null) {
|
|
186
|
-
string = this.anonymousProcedureCall.
|
|
205
|
+
string = this.anonymousProcedureCall.getString();
|
|
187
206
|
}
|
|
188
207
|
|
|
189
208
|
return string;
|
|
@@ -202,6 +221,10 @@ export default domAssigned(class Value {
|
|
|
202
221
|
value = this;
|
|
203
222
|
} else if (this.some !== null) {
|
|
204
223
|
value = this.some.evaluate(context);
|
|
224
|
+
} else if (this.every !== null) {
|
|
225
|
+
value = this.every.evaluate(context);
|
|
226
|
+
} else if (this.reduce !== null) {
|
|
227
|
+
value = this.reduce.evaluate(context);
|
|
205
228
|
} else if (this.ternary !== null) {
|
|
206
229
|
value = this.ternary.evaluate(context);
|
|
207
230
|
} else if (this.variable !== null) {
|
|
@@ -287,6 +310,8 @@ export default domAssigned(class Value {
|
|
|
287
310
|
string = null,
|
|
288
311
|
boolean = null,
|
|
289
312
|
some = null,
|
|
313
|
+
every = null,
|
|
314
|
+
reduce = null,
|
|
290
315
|
ternary = null,
|
|
291
316
|
variable = null,
|
|
292
317
|
nodeQuery = null,
|
|
@@ -297,7 +322,7 @@ export default domAssigned(class Value {
|
|
|
297
322
|
bracketedValue = null,
|
|
298
323
|
procedureCall = null,
|
|
299
324
|
anonymousProcedureCall = null,
|
|
300
|
-
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
325
|
+
value = new Value(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
301
326
|
|
|
302
327
|
return value;
|
|
303
328
|
}
|
|
@@ -309,6 +334,8 @@ export default domAssigned(class Value {
|
|
|
309
334
|
boolean = null,
|
|
310
335
|
ternary = null,
|
|
311
336
|
some = null,
|
|
337
|
+
every = null,
|
|
338
|
+
reduce = null,
|
|
312
339
|
variable = null,
|
|
313
340
|
nodeQuery = null,
|
|
314
341
|
nodesQuery = null,
|
|
@@ -318,7 +345,7 @@ export default domAssigned(class Value {
|
|
|
318
345
|
bracketedValue = null,
|
|
319
346
|
procedureCall = null,
|
|
320
347
|
anonymousProcedureCall = null,
|
|
321
|
-
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
348
|
+
value = new Value(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
322
349
|
|
|
323
350
|
return value;
|
|
324
351
|
}
|
|
@@ -329,6 +356,8 @@ export default domAssigned(class Value {
|
|
|
329
356
|
number = null,
|
|
330
357
|
boolean = null,
|
|
331
358
|
some = null,
|
|
359
|
+
every = null,
|
|
360
|
+
reduce = null,
|
|
332
361
|
ternary = null,
|
|
333
362
|
variable = null,
|
|
334
363
|
nodeQuery = null,
|
|
@@ -339,7 +368,7 @@ export default domAssigned(class Value {
|
|
|
339
368
|
bracketedValue = null,
|
|
340
369
|
procedureCall = null,
|
|
341
370
|
anonymousProcedureCall = null,
|
|
342
|
-
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
371
|
+
value = new Value(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
343
372
|
|
|
344
373
|
return value;
|
|
345
374
|
}
|
|
@@ -350,6 +379,8 @@ export default domAssigned(class Value {
|
|
|
350
379
|
number = null,
|
|
351
380
|
string = null,
|
|
352
381
|
some = null,
|
|
382
|
+
every = null,
|
|
383
|
+
reduce = null,
|
|
353
384
|
ternary = null,
|
|
354
385
|
variable = null,
|
|
355
386
|
nodeQuery = null,
|
|
@@ -360,7 +391,7 @@ export default domAssigned(class Value {
|
|
|
360
391
|
bracketedValue = null,
|
|
361
392
|
procedureCall = null,
|
|
362
393
|
anonymousProcedureCall = null,
|
|
363
|
-
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
394
|
+
value = new Value(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
364
395
|
|
|
365
396
|
return value;
|
|
366
397
|
}
|
|
@@ -371,6 +402,14 @@ export default domAssigned(class Value {
|
|
|
371
402
|
return value;
|
|
372
403
|
}
|
|
373
404
|
|
|
405
|
+
static fromReduceNode(reduceNode, context) {
|
|
406
|
+
const reduceValueNode = reduceValueNodeQuery(reduceNode),
|
|
407
|
+
valueNode = reduceValueNode, ///
|
|
408
|
+
value = valueFromValueNode(valueNode, context);
|
|
409
|
+
|
|
410
|
+
return value;
|
|
411
|
+
}
|
|
412
|
+
|
|
374
413
|
static fromTernaryNode(ternaryNode, context) {
|
|
375
414
|
const ternaryValueNode = ternaryValueNodeQuery(ternaryNode),
|
|
376
415
|
valueNode = ternaryValueNode, ///
|
|
@@ -474,7 +513,7 @@ function nodesAsString(nodes, context) {
|
|
|
474
513
|
return string;
|
|
475
514
|
}
|
|
476
515
|
|
|
477
|
-
function numberAsString(number
|
|
516
|
+
function numberAsString(number) {
|
|
478
517
|
let string;
|
|
479
518
|
|
|
480
519
|
string = `${number}`;
|
|
@@ -482,13 +521,13 @@ function numberAsString(number, context) {
|
|
|
482
521
|
return string;
|
|
483
522
|
}
|
|
484
523
|
|
|
485
|
-
function stringAsString(string
|
|
524
|
+
function stringAsString(string) {
|
|
486
525
|
string = `"${string}"`; ///
|
|
487
526
|
|
|
488
527
|
return string;
|
|
489
528
|
}
|
|
490
529
|
|
|
491
|
-
function booleanAsString(boolean
|
|
530
|
+
function booleanAsString(boolean) {
|
|
492
531
|
let string;
|
|
493
532
|
|
|
494
533
|
string = `'${boolean}'`;
|
|
@@ -497,13 +536,15 @@ function booleanAsString(boolean, context) {
|
|
|
497
536
|
}
|
|
498
537
|
|
|
499
538
|
function valueFromValueNode(valueNode, context) {
|
|
500
|
-
const { Some, Value, Ternary, Variable, NodeQuery, NodesQuery, Comparison, NegatedValue, BitwiseValue, BracketedValue, ProcedureCall, AnonymousProcedureCall } = dom,
|
|
539
|
+
const { Some, Every, Reduce, Value, Ternary, Variable, NodeQuery, NodesQuery, Comparison, NegatedValue, BitwiseValue, BracketedValue, ProcedureCall, AnonymousProcedureCall } = dom,
|
|
501
540
|
node = nodeFromValueNode(valueNode, context),
|
|
502
541
|
nodes = nodesFromValueNode(valueNode, context),
|
|
503
542
|
number = numberFromValueNode(valueNode, context),
|
|
504
543
|
string = stringFromValueNode(valueNode, context),
|
|
505
544
|
boolean = booleanFromValueNode(valueNode, context),
|
|
506
545
|
some = Some.fromValueNode(valueNode, context),
|
|
546
|
+
every = Every.fromValueNode(valueNode, context),
|
|
547
|
+
reduce = Reduce.fromValueNode(valueNode, context),
|
|
507
548
|
ternary = Ternary.fromValueNode(valueNode, context),
|
|
508
549
|
variable = Variable.fromValueNode(valueNode, context),
|
|
509
550
|
nodeQuery = NodeQuery.fromValueNode(valueNode, context),
|
|
@@ -514,7 +555,7 @@ function valueFromValueNode(valueNode, context) {
|
|
|
514
555
|
bracketedValue = BracketedValue.fromValueNode(valueNode, context),
|
|
515
556
|
procedureCall = ProcedureCall.fromValueNode(valueNode, context),
|
|
516
557
|
anonymousProcedureCall = AnonymousProcedureCall.fromValueNode(valueNode, context),
|
|
517
|
-
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
558
|
+
value = new Value(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, negatedValue, bitwiseValue, bracketedValue, procedureCall, anonymousProcedureCall);
|
|
518
559
|
|
|
519
560
|
return value;
|
|
520
561
|
}
|
package/src/dom/values.js
CHANGED