occam-furtle 2.0.86 → 2.0.89
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/README.md +43 -12
- package/lib/constants.js +5 -1
- package/lib/context/block.js +8 -8
- package/lib/dom/assignment/array.js +10 -6
- package/lib/dom/assignment/object.js +10 -6
- package/lib/dom/assignment/variable.js +3 -2
- package/lib/dom/assignments/variable.js +10 -6
- package/lib/dom/block/return.js +21 -5
- package/lib/dom/comparison.js +2 -14
- package/lib/dom/declaration/procedure.js +6 -2
- package/lib/dom/error.js +48 -3
- package/lib/dom/every.js +7 -3
- package/lib/dom/label.js +52 -7
- package/lib/dom/parameter/named.js +48 -3
- package/lib/dom/parameter.js +48 -4
- package/lib/dom/parameters/named.js +13 -9
- package/lib/dom/parameters.js +17 -27
- package/lib/dom/procedure.js +10 -6
- package/lib/dom/procedureCall.js +10 -6
- package/lib/dom/query/node.js +10 -6
- package/lib/dom/query/nodes.js +10 -6
- package/lib/dom/reduce.js +8 -4
- package/lib/dom/reference.js +55 -10
- package/lib/dom/some.js +7 -3
- package/lib/dom/statement/return.js +7 -3
- package/lib/dom/step.js +6 -2
- package/lib/dom/ternary.js +10 -6
- package/lib/dom/value/bitwise.js +10 -6
- package/lib/dom/value/bracketed.js +7 -3
- package/lib/dom/value/negated.js +10 -6
- package/lib/dom/value.js +35 -39
- package/lib/dom/values.js +5 -19
- package/lib/dom/variable.js +3 -3
- package/package.json +1 -1
- package/src/constants.js +1 -0
- package/src/context/block.js +8 -8
- package/src/dom/assignment/array.js +15 -8
- package/src/dom/assignment/object.js +15 -8
- package/src/dom/assignment/variable.js +2 -1
- package/src/dom/assignments/variable.js +16 -8
- package/src/dom/block/return.js +25 -4
- package/src/dom/comparison.js +1 -16
- package/src/dom/declaration/procedure.js +10 -4
- package/src/dom/error.js +12 -3
- package/src/dom/every.js +12 -6
- package/src/dom/label.js +20 -10
- package/src/dom/parameter/named.js +14 -6
- package/src/dom/parameter.js +12 -5
- package/src/dom/parameters/named.js +23 -16
- package/src/dom/parameters.js +32 -47
- package/src/dom/procedure.js +19 -15
- package/src/dom/procedureCall.js +15 -9
- package/src/dom/query/node.js +19 -12
- package/src/dom/query/nodes.js +19 -12
- package/src/dom/reduce.js +17 -14
- package/src/dom/reference.js +21 -15
- package/src/dom/some.js +12 -6
- package/src/dom/statement/return.js +13 -6
- package/src/dom/step.js +12 -6
- package/src/dom/ternary.js +21 -14
- package/src/dom/value/bitwise.js +19 -12
- package/src/dom/value/bracketed.js +12 -6
- package/src/dom/value/negated.js +16 -9
- package/src/dom/value.js +42 -47
- package/src/dom/values.js +5 -19
- package/src/dom/variable.js +6 -4
package/src/dom/parameters.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import dom from "../dom";
|
|
4
4
|
import Exception from "../exception";
|
|
5
5
|
|
|
6
|
+
import { UNDERSCORE } from "../constants";
|
|
6
7
|
import { domAssigned } from "../dom";
|
|
7
8
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
8
9
|
|
|
@@ -68,62 +69,57 @@ export default domAssigned(class Parameters {
|
|
|
68
69
|
|
|
69
70
|
static name = "Parameters";
|
|
70
71
|
|
|
71
|
-
static fromStringAndArray(string, array) {
|
|
72
|
-
const parameters = new Parameters(string, array);
|
|
73
|
-
|
|
74
|
-
return parameters;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
72
|
static fromArrayAssignmentNode(arrayAssignmentNode, context) {
|
|
78
73
|
const arrayAssignmentParametersNode = arrayAssignmentParametersNodeQuery(arrayAssignmentNode),
|
|
79
74
|
parametersNode = arrayAssignmentParametersNode, ///
|
|
80
|
-
|
|
81
|
-
string = context.nodeAsString(node),
|
|
82
|
-
parameterNodes = parameterNodesQuery(parametersNode),
|
|
83
|
-
array = arrayFromParameterNodes(parameterNodes, context),
|
|
84
|
-
parameters = new Parameters(string, array);
|
|
75
|
+
parameters = parametersFromParametersNode(parametersNode, context);
|
|
85
76
|
|
|
86
77
|
return parameters;
|
|
87
78
|
}
|
|
88
79
|
|
|
89
80
|
static fromAnonymousProcedureNode(anonymousProcedureNode, context) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
parameterNodes = parameterNodesQuery(parameterNode),
|
|
94
|
-
array = parameterNodes.map((parameterNode) => {
|
|
95
|
-
const parameter = Parameter.fromParameterNode(parameterNode, context);
|
|
96
|
-
|
|
97
|
-
return parameter;
|
|
98
|
-
}),
|
|
99
|
-
string = stringFromArray(array, context),
|
|
100
|
-
parameters = new Parameters(string, array);
|
|
81
|
+
const anonymousProcedureParametersNode = anonymousProcedureParametersNodeQuery(anonymousProcedureNode),
|
|
82
|
+
parametersNode = anonymousProcedureParametersNode, ///
|
|
83
|
+
parameters = parametersFromParametersNode(parametersNode, context);
|
|
101
84
|
|
|
102
85
|
return parameters;
|
|
103
86
|
}
|
|
104
87
|
|
|
105
88
|
static fromProcedureDeclarationNode(procedureDeclarationNode, context) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (procedureDeclarationParametersNode !== null) {
|
|
111
|
-
const parametersNode = procedureDeclarationParametersNode, ///
|
|
112
|
-
node = parametersNode, ///
|
|
113
|
-
string = context.nodeAsString(node),
|
|
114
|
-
parameterNodes = parameterNodesQuery(parametersNode),
|
|
115
|
-
array = arrayFromParameterNodes(parameterNodes, context);
|
|
116
|
-
|
|
117
|
-
parameters = new Parameters(string, array);
|
|
118
|
-
}
|
|
89
|
+
const procedureDeclarationParametersNode = procedureDeclarationParametersNodeQuery(procedureDeclarationNode),
|
|
90
|
+
parametersNode = procedureDeclarationParametersNode, ///
|
|
91
|
+
parameters = parametersFromParametersNode(parametersNode, context);
|
|
119
92
|
|
|
120
93
|
return parameters;
|
|
121
94
|
}
|
|
122
95
|
});
|
|
123
96
|
|
|
97
|
+
function parametersFromParametersNode(parametersNode, context) {
|
|
98
|
+
const { Parameters } = dom,
|
|
99
|
+
array = arrayFromParametersNode(parametersNode, context),
|
|
100
|
+
string = stringFromArray(array, context),
|
|
101
|
+
parameters = new Parameters(string, array);
|
|
102
|
+
|
|
103
|
+
return parameters;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function arrayFromParametersNode(parametersNode, context) {
|
|
107
|
+
const parameterNodes = parameterNodesQuery(parametersNode),
|
|
108
|
+
array = parameterNodes.map((parameterNode) => { ///
|
|
109
|
+
const { Parameter } = dom,
|
|
110
|
+
parameter = Parameter.fromParameterNode(parameterNode, context);
|
|
111
|
+
|
|
112
|
+
return parameter;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return array;
|
|
116
|
+
}
|
|
117
|
+
|
|
124
118
|
function stringFromArray(array, context) {
|
|
125
119
|
const parametersString = array.reduce((parametersString, parameter) => {
|
|
126
|
-
const parameterString = parameter
|
|
120
|
+
const parameterString = (parameter !== null)?
|
|
121
|
+
parameter.getString() :
|
|
122
|
+
UNDERSCORE;
|
|
127
123
|
|
|
128
124
|
parametersString = (parametersString === null) ?
|
|
129
125
|
parameterString :
|
|
@@ -135,14 +131,3 @@ function stringFromArray(array, context) {
|
|
|
135
131
|
|
|
136
132
|
return string;
|
|
137
133
|
}
|
|
138
|
-
|
|
139
|
-
function arrayFromParameterNodes(parameterNodes, context) {
|
|
140
|
-
const { Parameter } = dom,
|
|
141
|
-
array = parameterNodes.map((parameterNode) => { ///
|
|
142
|
-
const parameter = Parameter.fromParameterNode(parameterNode, context);
|
|
143
|
-
|
|
144
|
-
return parameter;
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
return array;
|
|
148
|
-
}
|
package/src/dom/procedure.js
CHANGED
|
@@ -7,9 +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
|
-
parametersNodeQuery = nodeQuery("/procedureDeclaration/parameters"),
|
|
12
|
-
typeTerminalNodeQuery = nodeQuery("/procedureDeclaration/@type");
|
|
10
|
+
const typeTerminalNodeQuery = nodeQuery("/procedureDeclaration/@type");
|
|
13
11
|
|
|
14
12
|
export default domAssigned(class Procedure {
|
|
15
13
|
constructor(string, type, label, parameters, returnBlock) {
|
|
@@ -82,13 +80,7 @@ export default domAssigned(class Procedure {
|
|
|
82
80
|
static name = "Procedure";
|
|
83
81
|
|
|
84
82
|
static fromProcedureDeclarationNode(procedureDeclarationNode, context) {
|
|
85
|
-
const
|
|
86
|
-
type = typeFromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
87
|
-
label = Label.fromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
88
|
-
parameters = Parameters.fromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
89
|
-
returnBlock = ReturnBlock.fromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
90
|
-
string = stringFromTypeLabelParametersAndReturnBlock(type, label, parameters, returnBlock),
|
|
91
|
-
procedureDeclaration = new Procedure(string, type, label, parameters, returnBlock);
|
|
83
|
+
const procedureDeclaration = procedureDeclarationFromProcedureDeclarationNode(procedureDeclarationNode, context);
|
|
92
84
|
|
|
93
85
|
return procedureDeclaration;
|
|
94
86
|
}
|
|
@@ -111,12 +103,16 @@ export function variablesFromValuesAndParameters(values, parameters, context) {
|
|
|
111
103
|
return variables;
|
|
112
104
|
}
|
|
113
105
|
|
|
114
|
-
function
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
function procedureDeclarationFromProcedureDeclarationNode(procedureDeclarationNode, context) {
|
|
107
|
+
const { Label, ReturnBlock, Parameters, Procedure } = dom,
|
|
108
|
+
returnBlock = ReturnBlock.fromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
109
|
+
parameters = Parameters.fromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
110
|
+
label = Label.fromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
111
|
+
type = typeFromProcedureDeclarationNode(procedureDeclarationNode, context),
|
|
112
|
+
string = stringFromTypeLabelParametersAndReturnBlock(type, label, parameters, returnBlock),
|
|
113
|
+
procedureDeclaration = new Procedure(string, type, label, parameters, returnBlock);
|
|
118
114
|
|
|
119
|
-
return
|
|
115
|
+
return procedureDeclaration;
|
|
120
116
|
}
|
|
121
117
|
|
|
122
118
|
function stringFromTypeLabelParametersAndReturnBlock(type, label, parameters, returnBlock) {
|
|
@@ -128,3 +124,11 @@ function stringFromTypeLabelParametersAndReturnBlock(type, label, parameters, re
|
|
|
128
124
|
|
|
129
125
|
return string;
|
|
130
126
|
}
|
|
127
|
+
|
|
128
|
+
function typeFromProcedureDeclarationNode(procedureDeclarationNode, context) {
|
|
129
|
+
const typeTerminalNode = typeTerminalNodeQuery(procedureDeclarationNode),
|
|
130
|
+
typeTerminalNodeContent = typeTerminalNode.getContent(),
|
|
131
|
+
type = typeTerminalNodeContent; ///
|
|
132
|
+
|
|
133
|
+
return type;
|
|
134
|
+
}
|
package/src/dom/procedureCall.js
CHANGED
|
@@ -6,7 +6,7 @@ import Exception from "../exception";
|
|
|
6
6
|
import { domAssigned } from "../dom";
|
|
7
7
|
import { nodeQuery } from "../utilities/query";
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const valueProcedureCallNodeQuery = nodeQuery("/value/procedureCall");
|
|
10
10
|
|
|
11
11
|
export default domAssigned(class ProcedureCall {
|
|
12
12
|
constructor(string, reference, values) {
|
|
@@ -56,22 +56,28 @@ export default domAssigned(class ProcedureCall {
|
|
|
56
56
|
static fromValueNode(valueNode, context) {
|
|
57
57
|
let procedureCall = null;
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const valueProcedureCallNode = valueProcedureCallNodeQuery(valueNode);
|
|
60
60
|
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
node = procedureCallNode, ///
|
|
64
|
-
reference = Reference.fromValueNode(valueNode, context),
|
|
65
|
-
values = Values.fromValueNode(valueNode, context),
|
|
66
|
-
string = stringFromValuesAndReference(values, reference, context);
|
|
61
|
+
if (valueProcedureCallNode !== null) {
|
|
62
|
+
const procedureCallNode = valueProcedureCallNode; ///
|
|
67
63
|
|
|
68
|
-
procedureCall =
|
|
64
|
+
procedureCall = procedureCallFromProcedureCallNode(procedureCallNode, context);
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
return procedureCall;
|
|
72
68
|
}
|
|
73
69
|
});
|
|
74
70
|
|
|
71
|
+
function procedureCallFromProcedureCallNode(procedureCallNode, context) {
|
|
72
|
+
const { Values, Reference, ProcedureCall } = dom,
|
|
73
|
+
reference = Reference.fromProcedureCallNode(procedureCallNode, context),
|
|
74
|
+
values = Values.fromProcedureCallNode(procedureCallNode, context),
|
|
75
|
+
string = stringFromValuesAndReference(values, reference, context),
|
|
76
|
+
procedureCall = new ProcedureCall(string, reference, values);
|
|
77
|
+
|
|
78
|
+
return procedureCall;
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
function stringFromValuesAndReference(values, reference, context) {
|
|
76
82
|
const valuesString = values.getString(),
|
|
77
83
|
referenceString = reference.getString(),
|
package/src/dom/query/node.js
CHANGED
|
@@ -12,8 +12,8 @@ import { domAssigned } from "../../dom";
|
|
|
12
12
|
|
|
13
13
|
const { first } = arrayUtilities;
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const expressionNodeQuery = nodeQuery("/nodeQuery/expression"),
|
|
16
|
+
valueNodeQueryNodeQuery = nodeQuery("/value/nodeQuery");
|
|
17
17
|
|
|
18
18
|
export default domAssigned(class NodeQuery {
|
|
19
19
|
constructor(string, variable, query) {
|
|
@@ -95,20 +95,27 @@ export default domAssigned(class NodeQuery {
|
|
|
95
95
|
static fromValueNode(valueNode, context) {
|
|
96
96
|
let nodeQuery = null;
|
|
97
97
|
|
|
98
|
-
const
|
|
98
|
+
const valueNodeQueryNode = valueNodeQueryNodeQuery(valueNode);
|
|
99
99
|
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
node = nodeQueryNode, ///
|
|
103
|
-
string = context.nodeAsString(node),
|
|
104
|
-
expressionNode = expressionNodeQuery(nodeQueryNode),
|
|
105
|
-
expression = Expression.fromExpressionNode(expressionNode),
|
|
106
|
-
variable = Variable.fromNodeQueryNode(nodeQueryNode, context),
|
|
107
|
-
query = Query.fromExpression(expression);
|
|
100
|
+
if (valueNodeQueryNode !== null) {
|
|
101
|
+
const nodeQueryNode = valueNodeQueryNode; ///
|
|
108
102
|
|
|
109
|
-
nodeQuery =
|
|
103
|
+
nodeQuery = nodeQueryFromNodeQueryNode(nodeQueryNode, context);
|
|
110
104
|
}
|
|
111
105
|
|
|
112
106
|
return nodeQuery;
|
|
113
107
|
}
|
|
114
108
|
});
|
|
109
|
+
|
|
110
|
+
function nodeQueryFromNodeQueryNode(nodeQueryNode, context) {
|
|
111
|
+
const { Variable, NodeQuery } = dom,
|
|
112
|
+
node = nodeQueryNode, ///
|
|
113
|
+
string = context.nodeAsString(node),
|
|
114
|
+
expressionNode = expressionNodeQuery(nodeQueryNode),
|
|
115
|
+
expression = Expression.fromExpressionNode(expressionNode),
|
|
116
|
+
variable = Variable.fromNodeQueryNode(nodeQueryNode, context),
|
|
117
|
+
query = Query.fromExpression(expression),
|
|
118
|
+
nodeQuery = new NodeQuery(string, variable, query);
|
|
119
|
+
|
|
120
|
+
return nodeQuery;
|
|
121
|
+
}
|
package/src/dom/query/nodes.js
CHANGED
|
@@ -9,8 +9,8 @@ import { nodeQuery } from "../../utilities/query";
|
|
|
9
9
|
import { NODE_TYPE } from "../../types";
|
|
10
10
|
import { domAssigned } from "../../dom";
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const expressionNodeQuery = nodeQuery("/nodesQuery/expression"),
|
|
13
|
+
valueNodesQueryNodeQuery = nodeQuery("/value/nodesQuery");
|
|
14
14
|
|
|
15
15
|
export default domAssigned(class NodesQuery {
|
|
16
16
|
constructor(string, variable, query) {
|
|
@@ -80,20 +80,27 @@ export default domAssigned(class NodesQuery {
|
|
|
80
80
|
static fromValueNode(valueNode, context) {
|
|
81
81
|
let nodesQuery = null;
|
|
82
82
|
|
|
83
|
-
const
|
|
83
|
+
const valueNodesQueryNode = valueNodesQueryNodeQuery(valueNode);
|
|
84
84
|
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
node = nodesQueryNode, ///
|
|
88
|
-
string = context.nodeAsString(node),
|
|
89
|
-
expressionNode = expressionNodeQuery(nodesQueryNode),
|
|
90
|
-
expression = Expression.fromExpressionNode(expressionNode),
|
|
91
|
-
variable = Variable.fromNodesQueryNode(nodesQueryNode, context),
|
|
92
|
-
query = Query.fromExpression(expression);
|
|
85
|
+
if (valueNodesQueryNode !== null) {
|
|
86
|
+
const nodesQueryNode = valueNodesQueryNode; ///
|
|
93
87
|
|
|
94
|
-
nodesQuery =
|
|
88
|
+
nodesQuery = nodesQueryFromNodesQueryNode(nodesQueryNode, context);
|
|
95
89
|
}
|
|
96
90
|
|
|
97
91
|
return nodesQuery;
|
|
98
92
|
}
|
|
99
93
|
});
|
|
94
|
+
|
|
95
|
+
function nodesQueryFromNodesQueryNode(nodesQueryNode, context) {
|
|
96
|
+
const { Variable, NodesQuery } = dom,
|
|
97
|
+
node = nodesQueryNode, ///
|
|
98
|
+
string = context.nodeAsString(node),
|
|
99
|
+
expressionNode = expressionNodeQuery(nodesQueryNode),
|
|
100
|
+
expression = Expression.fromExpressionNode(expressionNode),
|
|
101
|
+
variable = Variable.fromNodesQueryNode(nodesQueryNode, context),
|
|
102
|
+
query = Query.fromExpression(expression),
|
|
103
|
+
nodesQuery = new NodesQuery(string, variable, query);
|
|
104
|
+
|
|
105
|
+
return nodesQuery;
|
|
106
|
+
}
|
package/src/dom/reduce.js
CHANGED
|
@@ -4,13 +4,10 @@ import dom from "../dom";
|
|
|
4
4
|
import Exception from "../exception";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
import { NODES_TYPE } from "../types";
|
|
7
8
|
import { domAssigned } from "../dom";
|
|
8
|
-
import { NODES_TYPE, BOOLEAN_TYPE } from "../types";
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
parametersNodeQuery = nodeQuery("/reduce/anonymousProcedure/parameters"),
|
|
12
|
-
valueReduceNodeQuery = nodeQuery("/value/reduce"),
|
|
13
|
-
initialValueNodeQuery = nodeQuery("/reduce/value"); ///
|
|
10
|
+
const valueReduceNodeQuery = nodeQuery("/value/reduce"); ///
|
|
14
11
|
|
|
15
12
|
export default domAssigned(class Reduce {
|
|
16
13
|
constructor(string, variable, initialValue, anonymousProcedure) {
|
|
@@ -89,21 +86,27 @@ export default domAssigned(class Reduce {
|
|
|
89
86
|
const valueReduceNode = valueReduceNodeQuery(valueNode);
|
|
90
87
|
|
|
91
88
|
if (valueReduceNode !== null) {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
variable = Variable.fromReduceNode(reduceNode, context),
|
|
96
|
-
initialValue = value, ///
|
|
97
|
-
anonymousProcedure = AnonymousProcedure.fromReduceNode(reduceNode, context),
|
|
98
|
-
string = stringFromVariableInitialValueAndAnonymousProcedure(variable, initialValue, anonymousProcedure);
|
|
99
|
-
|
|
100
|
-
reduce = new Reduce(string, variable, initialValue, anonymousProcedure);
|
|
89
|
+
const reduceNode = valueReduceNode; ///
|
|
90
|
+
|
|
91
|
+
reduce = reduceFromReduceNode(reduceNode, context);
|
|
101
92
|
}
|
|
102
93
|
|
|
103
94
|
return reduce;
|
|
104
95
|
}
|
|
105
96
|
});
|
|
106
97
|
|
|
98
|
+
function reduceFromReduceNode(reduceNode, context) {
|
|
99
|
+
const { Value, Reduce, Variable, AnonymousProcedure } = dom,
|
|
100
|
+
value = Value.fromReduceNode(reduceNode, context),
|
|
101
|
+
variable = Variable.fromReduceNode(reduceNode, context),
|
|
102
|
+
initialValue = value, ///
|
|
103
|
+
anonymousProcedure = AnonymousProcedure.fromReduceNode(reduceNode, context),
|
|
104
|
+
string = stringFromVariableInitialValueAndAnonymousProcedure(variable, initialValue, anonymousProcedure),
|
|
105
|
+
reduce = new Reduce(string, variable, initialValue, anonymousProcedure);
|
|
106
|
+
|
|
107
|
+
return reduce;
|
|
108
|
+
}
|
|
109
|
+
|
|
107
110
|
function stringFromVariableInitialValueAndAnonymousProcedure(variable, initialValue, anonymousProcedure) {
|
|
108
111
|
const variableString = variable.getString(),
|
|
109
112
|
initialValueString = initialValue.getString(),
|
package/src/dom/reference.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
|
|
3
5
|
import { nodeQuery } from "../utilities/query";
|
|
4
6
|
import { domAssigned } from "../dom";
|
|
5
7
|
|
|
6
8
|
const referenceNameTerminalNodeQuery = nodeQuery("/reference/@name"),
|
|
7
|
-
|
|
9
|
+
procedureCallReferenceNodeQuery = nodeQuery("/procedureCall/reference");
|
|
8
10
|
|
|
9
11
|
export default domAssigned(class Reference {
|
|
10
12
|
constructor(string, name) {
|
|
@@ -23,30 +25,27 @@ export default domAssigned(class Reference {
|
|
|
23
25
|
static name = "Reference";
|
|
24
26
|
|
|
25
27
|
static fromReferenceNode(referenceNode, context) {
|
|
26
|
-
const
|
|
27
|
-
string = context.nodeAsString(node),
|
|
28
|
-
name = nameFromReferenceNode(referenceNode, context),
|
|
29
|
-
reference = new Reference(string, name);
|
|
28
|
+
const reference = referenceFromReferenceNode(referenceNode, context);
|
|
30
29
|
|
|
31
30
|
return reference;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
static
|
|
35
|
-
const
|
|
36
|
-
referenceNode =
|
|
37
|
-
|
|
38
|
-
string = stringFromName(name, context),
|
|
39
|
-
reference = new Reference(string, name);
|
|
33
|
+
static fromProcedureCallNode(procedureCallNode, context) {
|
|
34
|
+
const procedureCallReferenceNod = procedureCallReferenceNodeQuery(procedureCallNode),
|
|
35
|
+
referenceNode = procedureCallReferenceNod, ///
|
|
36
|
+
reference = referenceFromReferenceNode(referenceNode, context);
|
|
40
37
|
|
|
41
38
|
return reference;
|
|
42
39
|
}
|
|
43
40
|
});
|
|
44
41
|
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
|
|
42
|
+
function referenceFromReferenceNode(referenceNode, context) {
|
|
43
|
+
const { Reference } = dom,
|
|
44
|
+
name = nameFromReferenceNode(referenceNode, context),
|
|
45
|
+
string = stringFromName(name, context),
|
|
46
|
+
reference = new Reference(string, name);
|
|
48
47
|
|
|
49
|
-
return
|
|
48
|
+
return reference;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
function nameFromReferenceNode(referenceNode, context) {
|
|
@@ -56,3 +55,10 @@ function nameFromReferenceNode(referenceNode, context) {
|
|
|
56
55
|
|
|
57
56
|
return name;
|
|
58
57
|
}
|
|
58
|
+
|
|
59
|
+
function stringFromName(name, context) {
|
|
60
|
+
const nameString = name, ///
|
|
61
|
+
string = nameString; ///
|
|
62
|
+
|
|
63
|
+
return string;
|
|
64
|
+
}
|
package/src/dom/some.js
CHANGED
|
@@ -93,19 +93,25 @@ export default domAssigned(class Some {
|
|
|
93
93
|
const valueSomeNode = valueSomeNodeQuery(valueNode);
|
|
94
94
|
|
|
95
95
|
if (valueSomeNode !== null) {
|
|
96
|
-
const
|
|
97
|
-
someNode = valueSomeNode, ///
|
|
98
|
-
anonymousProcedure = AnonymousProcedure.fromSomeNode(someNode, context),
|
|
99
|
-
variable = Variable.fromSomeNode(someNode, context),
|
|
100
|
-
string = stringFromVariableAndAnonymousProcedure(variable, anonymousProcedure, context);
|
|
96
|
+
const someNode = valueSomeNode; ///
|
|
101
97
|
|
|
102
|
-
some =
|
|
98
|
+
some = someFromSomeNode(someNode, context);
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
return some;
|
|
106
102
|
}
|
|
107
103
|
});
|
|
108
104
|
|
|
105
|
+
function someFromSomeNode(someNode, context) {
|
|
106
|
+
const { Some, Variable, AnonymousProcedure } = dom,
|
|
107
|
+
anonymousProcedure = AnonymousProcedure.fromSomeNode(someNode, context),
|
|
108
|
+
variable = Variable.fromSomeNode(someNode, context),
|
|
109
|
+
string = stringFromVariableAndAnonymousProcedure(variable, anonymousProcedure, context),
|
|
110
|
+
some = new Some(string, variable, anonymousProcedure);
|
|
111
|
+
|
|
112
|
+
return some;
|
|
113
|
+
}
|
|
114
|
+
|
|
109
115
|
function stringFromVariableAndAnonymousProcedure(variable, anonymousProcedure, context) {
|
|
110
116
|
const variableString = variable.getString(),
|
|
111
117
|
anonymousProcedureString = anonymousProcedure.getString(),
|
|
@@ -5,7 +5,7 @@ import dom from "../../dom";
|
|
|
5
5
|
import { nodeQuery } from "../../utilities/query";
|
|
6
6
|
import { domAssigned } from "../../dom";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const returnBlockReturnStatementNodeQuery = nodeQuery("/returnBlock/returnStatement");
|
|
9
9
|
|
|
10
10
|
export default domAssigned(class ReturnStatement {
|
|
11
11
|
constructor(string, value) {
|
|
@@ -38,16 +38,23 @@ export default domAssigned(class ReturnStatement {
|
|
|
38
38
|
static name = "ReturnStatement";
|
|
39
39
|
|
|
40
40
|
static fromReturnBlockNode(returnBlockNode, context) {
|
|
41
|
-
const
|
|
42
|
-
returnStatementNode =
|
|
43
|
-
|
|
44
|
-
string = stringFromValue(value, context),
|
|
45
|
-
returnStatement = new ReturnStatement(string, value);
|
|
41
|
+
const returnBlockReturnStatementNode = returnBlockReturnStatementNodeQuery(returnBlockNode),
|
|
42
|
+
returnStatementNode = returnBlockReturnStatementNode, ///
|
|
43
|
+
returnStatement = returnStatementFromReturnStatementNode(returnStatementNode, context);
|
|
46
44
|
|
|
47
45
|
return returnStatement;
|
|
48
46
|
}
|
|
49
47
|
});
|
|
50
48
|
|
|
49
|
+
function returnStatementFromReturnStatementNode(returnStatementNode, context) {
|
|
50
|
+
const { Value, ReturnStatement } = dom,
|
|
51
|
+
value = Value.fromReturnStatementNode(returnStatementNode, context),
|
|
52
|
+
string = stringFromValue(value, context),
|
|
53
|
+
returnStatement = new ReturnStatement(string, value);
|
|
54
|
+
|
|
55
|
+
return returnStatement;
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
function stringFromValue(value, context) {
|
|
52
59
|
const valueString = value.asString(context),
|
|
53
60
|
string = `Return ${valueString};`;
|
package/src/dom/step.js
CHANGED
|
@@ -44,17 +44,23 @@ export default domAssigned(class Step {
|
|
|
44
44
|
static name = "Step";
|
|
45
45
|
|
|
46
46
|
static fromStepNode(stepNode, context) {
|
|
47
|
-
const
|
|
48
|
-
string = stringFromNothing(context),
|
|
49
|
-
arrayAssignment = ArrayAssignment.fromStepNode(stepNode, context),
|
|
50
|
-
objectAssigment = ObjectAssigment.fromStepNode(stepNode, context),
|
|
51
|
-
variablesDeclaration = VariableAssignments.fromStepNode(stepNode, context),
|
|
52
|
-
step = new Step(string, arrayAssignment, objectAssigment, variablesDeclaration);
|
|
47
|
+
const step = stepFromStepNode(stepNode, context);
|
|
53
48
|
|
|
54
49
|
return step;
|
|
55
50
|
}
|
|
56
51
|
});
|
|
57
52
|
|
|
53
|
+
function stepFromStepNode(stepNode, context) {
|
|
54
|
+
const { Step, ArrayAssignment, ObjectAssigment, VariableAssignments } = dom,
|
|
55
|
+
string = stringFromNothing(context),
|
|
56
|
+
arrayAssignment = ArrayAssignment.fromStepNode(stepNode, context),
|
|
57
|
+
objectAssigment = ObjectAssigment.fromStepNode(stepNode, context),
|
|
58
|
+
variablesDeclaration = VariableAssignments.fromStepNode(stepNode, context),
|
|
59
|
+
step = new Step(string, arrayAssignment, objectAssigment, variablesDeclaration);
|
|
60
|
+
|
|
61
|
+
return step;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
function stringFromNothing(context) {
|
|
59
65
|
const string = EMPTY_STRING;
|
|
60
66
|
|
package/src/dom/ternary.js
CHANGED
|
@@ -8,8 +8,8 @@ import { domAssigned } from "../dom";
|
|
|
8
8
|
import { BOOLEAN_TYPE } from "../types";
|
|
9
9
|
|
|
10
10
|
const ifValueNodeQuery = nodeQuery("/ternary/value[1]"),
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
elseValueNodeQuery = nodeQuery("/ternary/value[2]"),
|
|
12
|
+
valueTernaryNodeQuery = nodeQuery("/value/ternary");
|
|
13
13
|
|
|
14
14
|
export default domAssigned(class Ternary {
|
|
15
15
|
constructor(string, value, ifValue, elseValue) {
|
|
@@ -57,8 +57,8 @@ export default domAssigned(class Ternary {
|
|
|
57
57
|
const boolean = value.getBoolean();
|
|
58
58
|
|
|
59
59
|
value = boolean ?
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
this.ifValue.evaluate(context) :
|
|
61
|
+
this.elseValue.evaluate(context);
|
|
62
62
|
|
|
63
63
|
context.debug(`...evaluated the '${ternaryString}' ternary.`);
|
|
64
64
|
|
|
@@ -70,24 +70,31 @@ export default domAssigned(class Ternary {
|
|
|
70
70
|
static fromValueNode(valueNode, context) {
|
|
71
71
|
let ternary = null;
|
|
72
72
|
|
|
73
|
-
const
|
|
73
|
+
const valueTernaryNode = valueTernaryNodeQuery(valueNode);
|
|
74
74
|
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
77
|
-
ifValueNode = ifValueNodeQuery(ternaryNode),
|
|
78
|
-
elseValueNode = elseValueNodeQuery(ternaryNode),
|
|
79
|
-
value = Value.fromTernaryNode(ternaryNode, context),
|
|
80
|
-
ifValue = Value.fromValueNode(ifValueNode, context),
|
|
81
|
-
elseValue = Value.fromValueNode(elseValueNode, context),
|
|
82
|
-
string = stringFromValueIfValueAndElseValue(value, ifValue, elseValue, context);
|
|
75
|
+
if (valueTernaryNode !== null) {
|
|
76
|
+
const ternaryNode = valueTernaryNode; ///
|
|
83
77
|
|
|
84
|
-
ternary =
|
|
78
|
+
ternary = ternaryFromTernaryNode(ternaryNode, context);
|
|
85
79
|
}
|
|
86
80
|
|
|
87
81
|
return ternary;
|
|
88
82
|
}
|
|
89
83
|
});
|
|
90
84
|
|
|
85
|
+
function ternaryFromTernaryNode(ternaryNode, context) {
|
|
86
|
+
const { Value, Ternary } = dom,
|
|
87
|
+
ifValueNode = ifValueNodeQuery(ternaryNode),
|
|
88
|
+
elseValueNode = elseValueNodeQuery(ternaryNode),
|
|
89
|
+
value = Value.fromTernaryNode(ternaryNode, context),
|
|
90
|
+
ifValue = Value.fromValueNode(ifValueNode, context),
|
|
91
|
+
elseValue = Value.fromValueNode(elseValueNode, context),
|
|
92
|
+
string = stringFromValueIfValueAndElseValue(value, ifValue, elseValue, context),
|
|
93
|
+
ternary = new Ternary(string, value, ifValue, elseValue);
|
|
94
|
+
|
|
95
|
+
return ternary;
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
function stringFromValueIfValueAndElseValue(value, ifValue, elseValue, context) {
|
|
92
99
|
const valueString = value.asString(context),
|
|
93
100
|
ifValueString = ifValue.asString(context),
|
package/src/dom/value/bitwise.js
CHANGED
|
@@ -11,7 +11,7 @@ import { CONJUNCTION, DISJUNCTION } from "../../constants";
|
|
|
11
11
|
const terminalNodeQuery = nodeQuery("/bitwiseValue/@*"),
|
|
12
12
|
leftValueNodeQuery = nodeQuery("/bitwiseValue/value[0]"),
|
|
13
13
|
rightValueNodeQuery = nodeQuery("/bitwiseValue/value[1]"),
|
|
14
|
-
|
|
14
|
+
valueBitwiseValueNodeQuery = nodeQuery("/value/bitwiseValue");
|
|
15
15
|
|
|
16
16
|
export default domAssigned(class BitwiseValue {
|
|
17
17
|
constructor(string, type, disjoint, leftValue, rightValue) {
|
|
@@ -89,25 +89,32 @@ export default domAssigned(class BitwiseValue {
|
|
|
89
89
|
static fromValueNode(valueNode, context) {
|
|
90
90
|
let bitwiseValue = null;
|
|
91
91
|
|
|
92
|
-
const
|
|
92
|
+
const valueBitwiseValueNode = valueBitwiseValueNodeQuery(valueNode);
|
|
93
93
|
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
type = BOOLEAN_TYPE,
|
|
97
|
-
leftValueNode = leftValueNodeQuery(bitwiseValueNode),
|
|
98
|
-
rightValueNode = rightValueNodeQuery(bitwiseValueNode),
|
|
99
|
-
disjoint = disjointFromBitwiseValueNode(bitwiseValueNode, context),
|
|
100
|
-
leftValue = Value.fromValueNode(leftValueNode, context),
|
|
101
|
-
rightValue = Value.fromValueNode(rightValueNode, context),
|
|
102
|
-
string = stringFromTypeDisjointLeftValueAndRightValue(disjoint, leftValue, rightValue, context);
|
|
94
|
+
if (valueBitwiseValueNode !== null) {
|
|
95
|
+
const bitwiseValueNode = valueBitwiseValueNode; ///
|
|
103
96
|
|
|
104
|
-
bitwiseValue =
|
|
97
|
+
bitwiseValue = bitwiseValueFromBitwiseValueNode(bitwiseValueNode, context);
|
|
105
98
|
}
|
|
106
99
|
|
|
107
100
|
return bitwiseValue;
|
|
108
101
|
}
|
|
109
102
|
});
|
|
110
103
|
|
|
104
|
+
function bitwiseValueFromBitwiseValueNode(bitwiseValueNode, context) {
|
|
105
|
+
const { Value, BitwiseValue } = dom,
|
|
106
|
+
leftValueNode = leftValueNodeQuery(bitwiseValueNode),
|
|
107
|
+
rightValueNode = rightValueNodeQuery(bitwiseValueNode),
|
|
108
|
+
type = BOOLEAN_TYPE,
|
|
109
|
+
disjoint = disjointFromBitwiseValueNode(bitwiseValueNode, context),
|
|
110
|
+
leftValue = Value.fromValueNode(leftValueNode, context),
|
|
111
|
+
rightValue = Value.fromValueNode(rightValueNode, context),
|
|
112
|
+
string = stringFromTypeDisjointLeftValueAndRightValue(disjoint, leftValue, rightValue, context),
|
|
113
|
+
bitwiseValue = new BitwiseValue(string, type, disjoint, leftValue, rightValue);
|
|
114
|
+
|
|
115
|
+
return bitwiseValue;
|
|
116
|
+
}
|
|
117
|
+
|
|
111
118
|
function disjointFromBitwiseValueNode(bitwiseValueNode, context) {
|
|
112
119
|
const terminalNode = terminalNodeQuery(bitwiseValueNode),
|
|
113
120
|
terminalNodeContent = terminalNode.getContent(),
|