occam-furtle 2.0.120 → 2.0.121
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/dom/assignment/array.js +12 -12
- package/lib/dom/assignment/object.js +30 -30
- package/lib/dom/assignment/variable.js +13 -13
- package/lib/dom/block/return.js +9 -9
- package/lib/dom/comparison.js +28 -28
- package/lib/dom/every.js +25 -25
- package/lib/dom/expression/bitwise.js +186 -0
- package/lib/dom/expression/bracketed.js +149 -0
- package/lib/dom/expression/negated.js +166 -0
- package/lib/dom/expression.js +578 -0
- package/lib/dom/expressions.js +210 -0
- package/lib/dom/parameter/named.js +9 -9
- package/lib/dom/parameter.js +9 -9
- package/lib/dom/parameters/named.js +11 -11
- package/lib/dom/parameters.js +11 -11
- package/lib/dom/procedure/anonymous.js +7 -7
- package/lib/dom/procedure.js +12 -12
- package/lib/dom/procedureCall.js +17 -17
- package/lib/dom/query/node.js +19 -19
- package/lib/dom/query/nodes.js +19 -19
- package/lib/dom/reduce.js +32 -32
- package/lib/dom/some.js +25 -25
- package/lib/dom/statement/return.js +12 -12
- package/lib/dom/ternary.js +27 -27
- package/lib/dom/variable.js +30 -30
- package/lib/example/utilities/expressions.js +29 -0
- package/lib/example.js +4 -4
- package/lib/index.js +9 -9
- package/package.json +1 -1
- package/src/dom/assignment/array.js +14 -14
- package/src/dom/assignment/object.js +33 -33
- package/src/dom/assignment/variable.js +15 -15
- package/src/dom/block/return.js +7 -7
- package/src/dom/comparison.js +39 -39
- package/src/dom/every.js +25 -25
- package/src/dom/expression/bitwise.js +135 -0
- package/src/dom/expression/bracketed.js +73 -0
- package/src/dom/expression/negated.js +97 -0
- package/src/dom/{value.js → expression.js} +128 -128
- package/src/dom/expressions.js +138 -0
- package/src/dom/parameter/named.js +7 -7
- package/src/dom/parameter.js +7 -7
- package/src/dom/parameters/named.js +9 -9
- package/src/dom/parameters.js +9 -9
- package/src/dom/procedure/anonymous.js +10 -10
- package/src/dom/procedure.js +12 -12
- package/src/dom/procedureCall.js +19 -19
- package/src/dom/query/node.js +19 -19
- package/src/dom/query/nodes.js +19 -19
- package/src/dom/reduce.js +36 -36
- package/src/dom/some.js +25 -25
- package/src/dom/statement/return.js +14 -14
- package/src/dom/ternary.js +39 -39
- package/src/dom/variable.js +31 -31
- package/src/example/utilities/{values.js → expressions.js} +4 -4
- package/src/example.js +4 -4
- package/src/index.js +6 -6
- package/lib/dom/value/bitwise.js +0 -186
- package/lib/dom/value/bracketed.js +0 -149
- package/lib/dom/value/negated.js +0 -166
- package/lib/dom/value.js +0 -578
- package/lib/dom/values.js +0 -210
- package/lib/example/utilities/values.js +0 -29
- package/src/dom/value/bitwise.js +0 -135
- package/src/dom/value/bracketed.js +0 -73
- package/src/dom/value/negated.js +0 -97
- package/src/dom/values.js +0 -138
|
@@ -12,16 +12,16 @@ import { NODE_TYPE, NODES_TYPE, NUMBER_TYPE, STRING_TYPE, BOOLEAN_TYPE } from ".
|
|
|
12
12
|
|
|
13
13
|
const { match } = arrayUtilities;
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export default domAssigned(class
|
|
24
|
-
constructor(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, returnBlock, procedureCall,
|
|
15
|
+
const numberTerminalNodeQuery = nodeQuery("/expression/@number"),
|
|
16
|
+
reduceExpressionNodeQuery = nodeQuery("/reduce/expression"),
|
|
17
|
+
primitiveTerminalNodeQuery = nodeQuery("/expression/@primitive"),
|
|
18
|
+
ternaryExpressionNodeQuery = nodeQuery("/ternary/expression"),
|
|
19
|
+
stringLiteralTerminalNodeQuery = nodeQuery("/expression/@string-literal"),
|
|
20
|
+
returnStatementExpressionNodeQuery = nodeQuery("/returnStatement/expression"),
|
|
21
|
+
variableAssignmentExpressionNodeQuery = nodeQuery("/variableAssignment/expression");
|
|
22
|
+
|
|
23
|
+
export default domAssigned(class Expression {
|
|
24
|
+
constructor(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, returnBlock, procedureCall, negatedExpression, bitwiseExpression, bracketedExpression) {
|
|
25
25
|
this.node = node;
|
|
26
26
|
this.nodes = nodes;
|
|
27
27
|
this.number = number;
|
|
@@ -37,9 +37,9 @@ export default domAssigned(class Value {
|
|
|
37
37
|
this.comparison = comparison;
|
|
38
38
|
this.returnBlock = returnBlock;
|
|
39
39
|
this.procedureCall = procedureCall;
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
40
|
+
this.negatedExpression = negatedExpression;
|
|
41
|
+
this.bitwiseExpression = bitwiseExpression;
|
|
42
|
+
this.bracketedExpression = bracketedExpression;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
getNode() {
|
|
@@ -102,16 +102,16 @@ export default domAssigned(class Value {
|
|
|
102
102
|
return this.procedureCall;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
return this.
|
|
105
|
+
getNegatedExpression() {
|
|
106
|
+
return this.negatedExpression;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
return this.
|
|
109
|
+
getBitwiseExpression() {
|
|
110
|
+
return this.bitwiseExpression;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
return this.
|
|
113
|
+
getBracketedExpression() {
|
|
114
|
+
return this.bracketedExpression;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
getType() {
|
|
@@ -149,12 +149,12 @@ export default domAssigned(class Value {
|
|
|
149
149
|
type = this.returnBlock.getType();
|
|
150
150
|
} else if (this.procedureCall !== null) {
|
|
151
151
|
type = this.procedureCall.getType();
|
|
152
|
-
} else if (this.
|
|
153
|
-
type = this.
|
|
154
|
-
} else if (this.
|
|
155
|
-
type = this.
|
|
156
|
-
} else if (this.
|
|
157
|
-
type = this.
|
|
152
|
+
} else if (this.negatedExpression !== null) {
|
|
153
|
+
type = this.negatedExpression.getType();
|
|
154
|
+
} else if (this.bitwiseExpression !== null) {
|
|
155
|
+
type = this.bitwiseExpression.getType();
|
|
156
|
+
} else if (this.bracketedExpression !== null) {
|
|
157
|
+
type = this.bracketedExpression.getType();
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
return type;
|
|
@@ -195,19 +195,19 @@ export default domAssigned(class Value {
|
|
|
195
195
|
string = this.returnBlock.getString();
|
|
196
196
|
} else if (this.procedureCall !== null) {
|
|
197
197
|
string = this.procedureCall.getString();
|
|
198
|
-
} else if (this.
|
|
199
|
-
string = this.
|
|
200
|
-
} else if (this.
|
|
201
|
-
string = this.
|
|
202
|
-
} else if (this.
|
|
203
|
-
string = this.
|
|
198
|
+
} else if (this.negatedExpression !== null) {
|
|
199
|
+
string = this.negatedExpression.getString();
|
|
200
|
+
} else if (this.bitwiseExpression !== null) {
|
|
201
|
+
string = this.bitwiseExpression.getString();
|
|
202
|
+
} else if (this.bracketedExpression !== null) {
|
|
203
|
+
string = this.bracketedExpression.getString();
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
return string;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
evaluate(context) {
|
|
210
|
-
let
|
|
210
|
+
let expression;
|
|
211
211
|
|
|
212
212
|
if (false) {
|
|
213
213
|
///
|
|
@@ -216,45 +216,45 @@ export default domAssigned(class Value {
|
|
|
216
216
|
(this.number !== null) ||
|
|
217
217
|
(this.string !== null) ||
|
|
218
218
|
(this.boolean !== null)) {
|
|
219
|
-
|
|
219
|
+
expression = this;
|
|
220
220
|
} else if (this.some !== null) {
|
|
221
|
-
|
|
221
|
+
expression = this.some.evaluate(context);
|
|
222
222
|
} else if (this.every !== null) {
|
|
223
|
-
|
|
223
|
+
expression = this.every.evaluate(context);
|
|
224
224
|
} else if (this.reduce !== null) {
|
|
225
|
-
|
|
225
|
+
expression = this.reduce.evaluate(context);
|
|
226
226
|
} else if (this.ternary !== null) {
|
|
227
|
-
|
|
227
|
+
expression = this.ternary.evaluate(context);
|
|
228
228
|
} else if (this.variable !== null) {
|
|
229
|
-
|
|
229
|
+
expression = this.variable.evaluate(context);
|
|
230
230
|
} else if (this.nodeQuery !== null) {
|
|
231
|
-
|
|
231
|
+
expression = this.nodeQuery.evaluate(context);
|
|
232
232
|
} else if (this.nodesQuery !== null) {
|
|
233
|
-
|
|
233
|
+
expression = this.nodesQuery.evaluate(context);
|
|
234
234
|
} else if (this.comparison !== null) {
|
|
235
|
-
|
|
235
|
+
expression = this.comparison.evaluate(context);
|
|
236
236
|
} else if (this.returnBlock !== null) {
|
|
237
|
-
|
|
237
|
+
expression = this.returnBlock.evaluate(context);
|
|
238
238
|
} else if (this.procedureCall !== null) {
|
|
239
|
-
|
|
240
|
-
} else if (this.
|
|
241
|
-
|
|
242
|
-
} else if (this.
|
|
243
|
-
|
|
244
|
-
} else if (this.
|
|
245
|
-
|
|
239
|
+
expression = this.procedureCall.evaluate(context);
|
|
240
|
+
} else if (this.negatedExpression !== null) {
|
|
241
|
+
expression = this.negatedExpression.evaluate(context);
|
|
242
|
+
} else if (this.bitwiseExpression !== null) {
|
|
243
|
+
expression = this.bitwiseExpression.evaluate(context);
|
|
244
|
+
} else if (this.bracketedExpression !== null) {
|
|
245
|
+
expression = this.bracketedExpression.evaluate(context);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
return
|
|
248
|
+
return expression;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
isEqualTo(
|
|
251
|
+
isEqualTo(expression) {
|
|
252
252
|
let equalTo;
|
|
253
253
|
|
|
254
254
|
if (false) {
|
|
255
255
|
///
|
|
256
256
|
} else if (this.node !== null) {
|
|
257
|
-
const node =
|
|
257
|
+
const node = expression.getNode();
|
|
258
258
|
|
|
259
259
|
if (node === null) {
|
|
260
260
|
equalTo = false;
|
|
@@ -266,7 +266,7 @@ export default domAssigned(class Value {
|
|
|
266
266
|
equalTo = nodeMatches; ///
|
|
267
267
|
}
|
|
268
268
|
} else if (this.nodes !== null) {
|
|
269
|
-
const nodes =
|
|
269
|
+
const nodes = expression.getNode();
|
|
270
270
|
|
|
271
271
|
if (nodes === null) {
|
|
272
272
|
equalTo = false;
|
|
@@ -278,15 +278,15 @@ export default domAssigned(class Value {
|
|
|
278
278
|
equalTo = nodesMatch; ///
|
|
279
279
|
}
|
|
280
280
|
} else if (this.number !== null) {
|
|
281
|
-
const number =
|
|
281
|
+
const number = expression.getNumber();
|
|
282
282
|
|
|
283
283
|
equalTo = (this.number === number);
|
|
284
284
|
} else if (this.string !== null) {
|
|
285
|
-
const string =
|
|
285
|
+
const string = expression.getString();
|
|
286
286
|
|
|
287
287
|
equalTo = (this.string === string);
|
|
288
288
|
} else if (this.boolean !== null) {
|
|
289
|
-
const boolean =
|
|
289
|
+
const boolean = expression.getBoolean();
|
|
290
290
|
|
|
291
291
|
equalTo = (this.boolean === boolean);
|
|
292
292
|
} else {
|
|
@@ -296,7 +296,7 @@ export default domAssigned(class Value {
|
|
|
296
296
|
return equalTo;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
static name = "
|
|
299
|
+
static name = "Expression";
|
|
300
300
|
|
|
301
301
|
static fromNode(node, context) {
|
|
302
302
|
if (node === null) {
|
|
@@ -317,12 +317,12 @@ export default domAssigned(class Value {
|
|
|
317
317
|
comparison = null,
|
|
318
318
|
returnBlock = null,
|
|
319
319
|
procedureCall = null,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
320
|
+
negatedExpression = null,
|
|
321
|
+
bitwiseExpression = null,
|
|
322
|
+
bracketedExpression = null,
|
|
323
|
+
expression = new Expression(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, returnBlock, procedureCall, negatedExpression, bitwiseExpression, bracketedExpression);
|
|
324
324
|
|
|
325
|
-
return
|
|
325
|
+
return expression;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
static fromNodes(nodes, context) {
|
|
@@ -340,12 +340,12 @@ export default domAssigned(class Value {
|
|
|
340
340
|
comparison = null,
|
|
341
341
|
returnBlock = null,
|
|
342
342
|
procedureCall = null,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
343
|
+
negatedExpression = null,
|
|
344
|
+
bitwiseExpression = null,
|
|
345
|
+
bracketedExpression = null,
|
|
346
|
+
expression = new Expression(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, returnBlock, procedureCall, negatedExpression, bitwiseExpression, bracketedExpression);
|
|
347
347
|
|
|
348
|
-
return
|
|
348
|
+
return expression;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
static fromString(string, context) {
|
|
@@ -363,12 +363,12 @@ export default domAssigned(class Value {
|
|
|
363
363
|
comparison = null,
|
|
364
364
|
returnBlock = null,
|
|
365
365
|
procedureCall = null,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
negatedExpression = null,
|
|
367
|
+
bitwiseExpression = null,
|
|
368
|
+
bracketedExpression = null,
|
|
369
|
+
expression = new Expression(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, returnBlock, procedureCall, negatedExpression, bitwiseExpression, bracketedExpression);
|
|
370
370
|
|
|
371
|
-
return
|
|
371
|
+
return expression;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
static fromBoolean(boolean, context) {
|
|
@@ -386,50 +386,50 @@ export default domAssigned(class Value {
|
|
|
386
386
|
comparison = null,
|
|
387
387
|
returnBlock = null,
|
|
388
388
|
procedureCall = null,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
389
|
+
negatedExpression = null,
|
|
390
|
+
bitwiseExpression = null,
|
|
391
|
+
bracketedExpression = null,
|
|
392
|
+
expression = new Expression(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, returnBlock, procedureCall, negatedExpression, bitwiseExpression, bracketedExpression);
|
|
393
393
|
|
|
394
|
-
return
|
|
394
|
+
return expression;
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
static
|
|
398
|
-
const
|
|
397
|
+
static fromExpressionNode(expressionNode, context) {
|
|
398
|
+
const expression = expressionFromExpressionNode(expressionNode, context);
|
|
399
399
|
|
|
400
|
-
return
|
|
400
|
+
return expression;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
static fromReduceNode(reduceNode, context) {
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
404
|
+
const reduceExpressionNode = reduceExpressionNodeQuery(reduceNode),
|
|
405
|
+
expressionNode = reduceExpressionNode, ///
|
|
406
|
+
expression = expressionFromExpressionNode(expressionNode, context);
|
|
407
407
|
|
|
408
|
-
return
|
|
408
|
+
return expression;
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
static fromTernaryNode(ternaryNode, context) {
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
412
|
+
const ternaryExpressionNode = ternaryExpressionNodeQuery(ternaryNode),
|
|
413
|
+
expressionNode = ternaryExpressionNode, ///
|
|
414
|
+
expression = expressionFromExpressionNode(expressionNode, context);
|
|
415
415
|
|
|
416
|
-
return
|
|
416
|
+
return expression;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
static fromReturnStatementNode(returnStatementNode, context) {
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
const returnStatementExpressionNode = returnStatementExpressionNodeQuery(returnStatementNode),
|
|
421
|
+
expressionNode = returnStatementExpressionNode, ///
|
|
422
|
+
expression = expressionFromExpressionNode(expressionNode, context);
|
|
423
423
|
|
|
424
|
-
return
|
|
424
|
+
return expression;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
static fromVariableAssignmentNode(variableAssigmentNode, context) {
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
428
|
+
const variableAssignmentExpressionNode = variableAssignmentExpressionNodeQuery(variableAssigmentNode),
|
|
429
|
+
expressionNode = variableAssignmentExpressionNode, ///
|
|
430
|
+
expression = expressionFromExpressionNode(expressionNode, context);
|
|
431
431
|
|
|
432
|
-
return
|
|
432
|
+
return expression;
|
|
433
433
|
}
|
|
434
434
|
});
|
|
435
435
|
|
|
@@ -505,35 +505,35 @@ function booleanAsString(boolean) {
|
|
|
505
505
|
return string;
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
-
function
|
|
509
|
-
const { Some, Every, Reduce,
|
|
510
|
-
node =
|
|
511
|
-
nodes =
|
|
512
|
-
number =
|
|
513
|
-
string =
|
|
514
|
-
boolean =
|
|
515
|
-
some = Some.
|
|
516
|
-
every = Every.
|
|
517
|
-
reduce = Reduce.
|
|
518
|
-
ternary = Ternary.
|
|
519
|
-
variable = Variable.
|
|
520
|
-
nodeQuery = NodeQuery.
|
|
521
|
-
nodesQuery = NodesQuery.
|
|
522
|
-
comparison = Comparison.
|
|
523
|
-
returnBlock = ReturnBlock.
|
|
524
|
-
procedureCall = ProcedureCall.
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
return
|
|
508
|
+
function expressionFromExpressionNode(expressionNode, context) {
|
|
509
|
+
const { Some, Every, Reduce, Expression, Ternary, Variable, NodeQuery, NodesQuery, Comparison, ReturnBlock, ProcedureCall, NegatedExpression, BitwiseExpression, BracketedExpression } = dom,
|
|
510
|
+
node = nodeFromExpressionNode(expressionNode, context),
|
|
511
|
+
nodes = nodesFromExpressionNode(expressionNode, context),
|
|
512
|
+
number = numberFromExpressionNode(expressionNode, context),
|
|
513
|
+
string = stringFromExpressionNode(expressionNode, context),
|
|
514
|
+
boolean = booleanFromExpressionNode(expressionNode, context),
|
|
515
|
+
some = Some.fromExpressionNode(expressionNode, context),
|
|
516
|
+
every = Every.fromExpressionNode(expressionNode, context),
|
|
517
|
+
reduce = Reduce.fromExpressionNode(expressionNode, context),
|
|
518
|
+
ternary = Ternary.fromExpressionNode(expressionNode, context),
|
|
519
|
+
variable = Variable.fromExpressionNode(expressionNode, context),
|
|
520
|
+
nodeQuery = NodeQuery.fromExpressionNode(expressionNode, context),
|
|
521
|
+
nodesQuery = NodesQuery.fromExpressionNode(expressionNode, context),
|
|
522
|
+
comparison = Comparison.fromExpressionNode(expressionNode, context),
|
|
523
|
+
returnBlock = ReturnBlock.fromExpressionNode(expressionNode, context),
|
|
524
|
+
procedureCall = ProcedureCall.fromExpressionNode(expressionNode, context),
|
|
525
|
+
negatedExpression = NegatedExpression.fromExpressionNode(expressionNode, context),
|
|
526
|
+
bitwiseExpression = BitwiseExpression.fromExpressionNode(expressionNode, context),
|
|
527
|
+
bracketedExpression = BracketedExpression.fromExpressionNode(expressionNode, context),
|
|
528
|
+
expression = new Expression(node, nodes, number, string, boolean, some, every, reduce, ternary, variable, nodeQuery, nodesQuery, comparison, returnBlock, procedureCall, negatedExpression, bitwiseExpression, bracketedExpression);
|
|
529
|
+
|
|
530
|
+
return expression;
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
function
|
|
533
|
+
function nodeFromExpressionNode(expressionNode, context) {
|
|
534
534
|
let node = null;
|
|
535
535
|
|
|
536
|
-
const primitiveTerminalNode = primitiveTerminalNodeQuery(
|
|
536
|
+
const primitiveTerminalNode = primitiveTerminalNodeQuery(expressionNode);
|
|
537
537
|
|
|
538
538
|
if (primitiveTerminalNode !== null) {
|
|
539
539
|
const primitiveTerminalNodeContent = primitiveTerminalNode.getContent();
|
|
@@ -550,16 +550,16 @@ function nodeFromValueNode(valueNode, context) {
|
|
|
550
550
|
return node;
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
function
|
|
553
|
+
function nodesFromExpressionNode(expressionNode, context) {
|
|
554
554
|
const nodes = null; ///
|
|
555
555
|
|
|
556
556
|
return nodes;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
function
|
|
559
|
+
function numberFromExpressionNode(expressionNode, context) {
|
|
560
560
|
let number = null;
|
|
561
561
|
|
|
562
|
-
const numberTerminalNode = numberTerminalNodeQuery(
|
|
562
|
+
const numberTerminalNode = numberTerminalNodeQuery(expressionNode);
|
|
563
563
|
|
|
564
564
|
if (numberTerminalNode !== null) {
|
|
565
565
|
const numberTerminalNodeContent = numberTerminalNode.getContent();
|
|
@@ -570,10 +570,10 @@ function numberFromValueNode(valueNode, context) {
|
|
|
570
570
|
return number;
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
-
function
|
|
573
|
+
function stringFromExpressionNode(expressionNode, context) {
|
|
574
574
|
let string = null;
|
|
575
575
|
|
|
576
|
-
const stringLiteralTerminalNode = stringLiteralTerminalNodeQuery(
|
|
576
|
+
const stringLiteralTerminalNode = stringLiteralTerminalNodeQuery(expressionNode);
|
|
577
577
|
|
|
578
578
|
if (stringLiteralTerminalNode !== null) {
|
|
579
579
|
const stringLiteralTerminalNodeContent = stringLiteralTerminalNode.getContent(),
|
|
@@ -585,10 +585,10 @@ function stringFromValueNode(valueNode, context) {
|
|
|
585
585
|
return string;
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
function
|
|
588
|
+
function booleanFromExpressionNode(expressionNode, context) {
|
|
589
589
|
let boolean = null;
|
|
590
590
|
|
|
591
|
-
const primitiveTerminalNode = primitiveTerminalNodeQuery(
|
|
591
|
+
const primitiveTerminalNode = primitiveTerminalNodeQuery(expressionNode);
|
|
592
592
|
|
|
593
593
|
if (primitiveTerminalNode !== null) {
|
|
594
594
|
const primitiveTerminalNodeContent = primitiveTerminalNode.getContent();
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
|
|
5
|
+
import { domAssigned } from "../dom";
|
|
6
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const expressionNodesQuery = nodesQuery("/expressions/expression"),
|
|
9
|
+
procedureCallExpressionsNodeQuery = nodeQuery("/procedureCall/expressions");
|
|
10
|
+
|
|
11
|
+
export default domAssigned(class Expressions {
|
|
12
|
+
constructor(string, array) {
|
|
13
|
+
this.string = string;
|
|
14
|
+
this.array = array;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getString() {
|
|
18
|
+
return this.string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getArray() {
|
|
22
|
+
return this.array;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getLength() {
|
|
26
|
+
const length = this.array.length;
|
|
27
|
+
|
|
28
|
+
return length;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getExpression(index) {
|
|
32
|
+
const expression = this.array[index] || null; ///
|
|
33
|
+
|
|
34
|
+
return expression;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
addExpression(expression) {
|
|
38
|
+
this.array.push(expression);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
mapExpression(callback) { return this.array.map(callback); }
|
|
42
|
+
|
|
43
|
+
forEachExpression(callback) { this.array.forEach(callback); }
|
|
44
|
+
|
|
45
|
+
evaluate(context) {
|
|
46
|
+
const array = this.mapExpression((expression) => {
|
|
47
|
+
expression = expression.evaluate(context);
|
|
48
|
+
|
|
49
|
+
return expression;
|
|
50
|
+
}),
|
|
51
|
+
expressions = Expressions.fromArray(array, context); ///
|
|
52
|
+
|
|
53
|
+
return expressions;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static name = "Expressions";
|
|
57
|
+
|
|
58
|
+
static fromNodes(nodes, context) {
|
|
59
|
+
const array = arrayFromNodes(nodes, context),
|
|
60
|
+
string = stringFromArray(array, context),
|
|
61
|
+
expressions = new Expressions(string, array);
|
|
62
|
+
|
|
63
|
+
return expressions;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static fromArray(array, context) {
|
|
67
|
+
const string = stringFromArray(array, context),
|
|
68
|
+
expressions = new Expressions(string, array);
|
|
69
|
+
|
|
70
|
+
return expressions;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static fromExpression(expression, context) {
|
|
74
|
+
const array = [
|
|
75
|
+
expression
|
|
76
|
+
],
|
|
77
|
+
string = stringFromArray(array, context),
|
|
78
|
+
expressions = new Expressions(string, array);
|
|
79
|
+
|
|
80
|
+
return expressions;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static fromProcedureCallNode(procedureCallNode, context) {
|
|
84
|
+
const procedureCallExpressionsNode = procedureCallExpressionsNodeQuery(procedureCallNode),
|
|
85
|
+
expressionsNode = procedureCallExpressionsNode, ///
|
|
86
|
+
expressions = expressionsFromExpressionsNode(expressionsNode, context);
|
|
87
|
+
|
|
88
|
+
return expressions;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
function arrayFromNodes(nodes, context) {
|
|
93
|
+
const { Expression } = dom,
|
|
94
|
+
array = nodes.map((node) => { ///
|
|
95
|
+
const expression = Expression.fromNode(node, context);
|
|
96
|
+
|
|
97
|
+
return expression;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return array;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function stringFromArray(array, context) {
|
|
104
|
+
const expressionsString = array.reduce((expressionsString, expression) => {
|
|
105
|
+
const expressionString = expression.asString(context);
|
|
106
|
+
|
|
107
|
+
expressionsString = (expressionsString === null) ?
|
|
108
|
+
expressionString :
|
|
109
|
+
`${expressionsString}, ${expressionString}`;
|
|
110
|
+
|
|
111
|
+
return expressionsString;
|
|
112
|
+
}, null),
|
|
113
|
+
string = expressionsString; ///
|
|
114
|
+
|
|
115
|
+
return string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function arrayFromExpressionNodes(expressionNodes, context) {
|
|
119
|
+
const { Expression } = dom,
|
|
120
|
+
array = expressionNodes.map((expressionNode) => { ///
|
|
121
|
+
const expression = Expression.fromExpressionNode(expressionNode, context);
|
|
122
|
+
|
|
123
|
+
return expression;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return array;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function expressionsFromExpressionsNode(expressionsNode, context) {
|
|
130
|
+
const { Expressions } = dom,
|
|
131
|
+
node = expressionsNode, ///
|
|
132
|
+
string = context.nodeAsString(node),
|
|
133
|
+
expressionNodes = expressionNodesQuery(expressionsNode),
|
|
134
|
+
array = arrayFromExpressionNodes(expressionNodes, context),
|
|
135
|
+
expressions = new Expressions(string, array);
|
|
136
|
+
|
|
137
|
+
return expressions;
|
|
138
|
+
}
|
|
@@ -34,22 +34,22 @@ export default domAssigned(class NamedParameter {
|
|
|
34
34
|
return this.asName;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
const
|
|
37
|
+
matchExpression(expression, context) {
|
|
38
|
+
const expressionString = expression.asString(context),
|
|
39
39
|
namedParameterString = this.string; ///
|
|
40
40
|
|
|
41
|
-
context.trace(`Matching the ${
|
|
41
|
+
context.trace(`Matching the ${expressionString} expression against the '${namedParameterString}' named parameter...`);
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const expressionType = expression.getType();
|
|
44
44
|
|
|
45
|
-
if (this.type !==
|
|
46
|
-
const message = `The ${
|
|
45
|
+
if (this.type !== expressionType) {
|
|
46
|
+
const message = `The ${expressionString} expression's '${expressionType}' type and '${namedParameterString}' named parameter's '${this.type}' type do not match.`,
|
|
47
47
|
exception = Exception.fromMessage(message);
|
|
48
48
|
|
|
49
49
|
throw exception;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
context.debug(`...matched the ${
|
|
52
|
+
context.debug(`...matched the ${expressionString} expression against the '${namedParameterString}' named parameter.`);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
matchNamedParameter(namedParameter, context) {
|
package/src/dom/parameter.js
CHANGED
|
@@ -29,22 +29,22 @@ export default domAssigned(class Parameter {
|
|
|
29
29
|
return this.name;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
const
|
|
32
|
+
matchExpression(expression, context) {
|
|
33
|
+
const expressionString = expression.asString(context),
|
|
34
34
|
parameterString = this.string; ///
|
|
35
35
|
|
|
36
|
-
context.trace(`Matching the ${
|
|
36
|
+
context.trace(`Matching the ${expressionString} expression against the '${parameterString}' parameter...`);
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const expressionType = expression.getType();
|
|
39
39
|
|
|
40
|
-
if (this.type !==
|
|
41
|
-
const message = `The ${
|
|
40
|
+
if (this.type !== expressionType) {
|
|
41
|
+
const message = `The ${expressionString} expression's '${expressionType}' type and '${parameterString}' parameter's '${this.type}' type do not match.`,
|
|
42
42
|
exception = Exception.fromMessage(message);
|
|
43
43
|
|
|
44
44
|
throw exception;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
context.debug(`...matched the ${
|
|
47
|
+
context.debug(`...matched the ${expressionString} expression against the '${parameterString}' parameter.`);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
static name = "Parameter";
|