occam-furtle 2.0.64 → 2.0.65
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/_occam-grammars/furtle/bnf.js +2 -2
- package/lib/dom/block.js +2 -9
- package/lib/dom/comparison.js +22 -6
- package/lib/dom/parameters.js +11 -11
- package/lib/dom/procedure/anonymous.js +16 -15
- package/lib/dom/some.js +162 -0
- package/lib/dom/step.js +3 -12
- package/lib/dom/value.js +33 -7
- package/lib/dom/variable.js +9 -9
- package/lib/index.js +2 -2
- package/package.json +4 -4
- package/src/_occam-grammars/furtle/bnf.js +6 -4
- package/src/dom/block.js +1 -14
- package/src/dom/comparison.js +35 -13
- package/src/dom/parameters.js +12 -11
- package/src/dom/procedure/anonymous.js +20 -18
- package/src/dom/{forEachLoop.js → some.js} +25 -22
- package/src/dom/step.js +3 -11
- package/src/dom/value.js +38 -7
- package/src/dom/variable.js +10 -10
- package/src/index.js +1 -1
- package/lib/dom/forEachLoop.js +0 -161
|
@@ -22,8 +22,6 @@ objectAssignment ::= "{" parameters "}" "=" variable ";" ;
|
|
|
22
22
|
|
|
23
23
|
arrayAssignment ::= "[" parameters "]" "=" variable ";" ;
|
|
24
24
|
|
|
25
|
-
someLoop ::= "Some"<NO_WHITESPACE>"(" variable "," anonymousProcedure ")" ";" ;
|
|
26
|
-
|
|
27
25
|
|
|
28
26
|
|
|
29
27
|
anonymousProcedure ::= "(" parameters? ")" returnBlock ;
|
|
@@ -71,8 +69,6 @@ step ::= variablesDeclaration
|
|
|
71
69
|
|
|
72
70
|
| arrayAssignment
|
|
73
71
|
|
|
74
|
-
| someLoop
|
|
75
|
-
|
|
76
72
|
;
|
|
77
73
|
|
|
78
74
|
|
|
@@ -83,6 +79,8 @@ assignment ::= "=" value ;
|
|
|
83
79
|
|
|
84
80
|
value ::= procedureCall
|
|
85
81
|
|
|
82
|
+
| comparison
|
|
83
|
+
|
|
86
84
|
| nodesQuery
|
|
87
85
|
|
|
88
86
|
| nodeQuery
|
|
@@ -91,6 +89,8 @@ value ::= procedureCall
|
|
|
91
89
|
|
|
92
90
|
| ternary
|
|
93
91
|
|
|
92
|
+
| some
|
|
93
|
+
|
|
94
94
|
| [null]
|
|
95
95
|
|
|
96
96
|
| [number]
|
|
@@ -113,6 +113,8 @@ variable ::= [name] ;
|
|
|
113
113
|
|
|
114
114
|
ternary ::= "If" "(" condition ")" value "Else" value ;
|
|
115
115
|
|
|
116
|
+
some ::= "Some"<NO_WHITESPACE>"(" variable "," anonymousProcedure ")" ";" ;
|
|
117
|
+
|
|
116
118
|
|
|
117
119
|
|
|
118
120
|
parameters ::= parameter ( "," parameter )* ;
|
package/src/dom/block.js
CHANGED
|
@@ -6,8 +6,7 @@ import BlockContext from "../context/block";
|
|
|
6
6
|
import { domAssigned } from "../dom";
|
|
7
7
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
8
8
|
|
|
9
|
-
const stepNodesQuery = nodesQuery("/block/step")
|
|
10
|
-
forEachLoopBlockNodeQuery = nodeQuery("/forEachLoop/anonymousProcedure/block");
|
|
9
|
+
const stepNodesQuery = nodesQuery("/block/step");
|
|
11
10
|
|
|
12
11
|
export default domAssigned(class Block {
|
|
13
12
|
constructor(string, steps) {
|
|
@@ -55,18 +54,6 @@ export default domAssigned(class Block {
|
|
|
55
54
|
|
|
56
55
|
return block;
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
static fromForEachLoopNode(forEachLoopNode, context) {
|
|
60
|
-
const forEachLoopBockNode = forEachLoopBlockNodeQuery(forEachLoopNode),
|
|
61
|
-
blockNode = forEachLoopBockNode, ///
|
|
62
|
-
stepNodes = stepNodesQuery(blockNode),
|
|
63
|
-
node = blockNode, ///
|
|
64
|
-
string = context.nodeAsString(node),
|
|
65
|
-
steps = stepsFromStepNodes(stepNodes, context),
|
|
66
|
-
block = new Block(string, steps);
|
|
67
|
-
|
|
68
|
-
return block;
|
|
69
|
-
}
|
|
70
57
|
});
|
|
71
58
|
|
|
72
59
|
function stepsFromStepNodes(stepNodes, context) {
|
package/src/dom/comparison.js
CHANGED
|
@@ -10,7 +10,8 @@ import { domAssigned } from "../dom";
|
|
|
10
10
|
const terminalNodeQuery = nodeQuery("/comparison/@*"),
|
|
11
11
|
leftValueNodeQuery = nodeQuery("/comparison/value[0]"),
|
|
12
12
|
rightValueNodeQuery = nodeQuery("/comparison/value[1]"),
|
|
13
|
-
|
|
13
|
+
valueComparisonNodeQuery = nodeQuery("/value/comparison"),
|
|
14
|
+
conditionComparisonNodeQuery = nodeQuery("/condition/comparison");
|
|
14
15
|
|
|
15
16
|
export default domAssigned(class Comparison {
|
|
16
17
|
constructor(string, negated, leftValue, rightValue) {
|
|
@@ -76,22 +77,29 @@ export default domAssigned(class Comparison {
|
|
|
76
77
|
|
|
77
78
|
static name = "Comparison";
|
|
78
79
|
|
|
80
|
+
static fromValueNode(valudNode, context) {
|
|
81
|
+
let comparison = null;
|
|
82
|
+
|
|
83
|
+
const valueComparisonNode = valueComparisonNodeQuery(valudNode);
|
|
84
|
+
|
|
85
|
+
if (valueComparisonNode !== null) {
|
|
86
|
+
const comparisonNode = valueComparisonNode; ///
|
|
87
|
+
|
|
88
|
+
comparison = comparisonFromComparisonNode(comparisonNode, context);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return comparison;
|
|
92
|
+
}
|
|
93
|
+
|
|
79
94
|
static fromConditionNode(conditionNode, context) {
|
|
80
95
|
let comparison = null;
|
|
81
96
|
|
|
82
|
-
const
|
|
97
|
+
const conditionComparisonNode = conditionComparisonNodeQuery(conditionNode);
|
|
83
98
|
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
node = comparisonNode, ///
|
|
87
|
-
string = context.nodeAsString(node),
|
|
88
|
-
leftValueNode = leftValueNodeQuery(comparisonNode),
|
|
89
|
-
rightValueNode = rightValueNodeQuery(comparisonNode),
|
|
90
|
-
negated = negatedFromComparisonNode(comparisonNode, context),
|
|
91
|
-
leftValue = Value.fromValueNode(leftValueNode, context),
|
|
92
|
-
rightValue = Value.fromValueNode(rightValueNode, context);
|
|
99
|
+
if (conditionComparisonNode !== null) {
|
|
100
|
+
const comparisonNode = conditionComparisonNode; ///
|
|
93
101
|
|
|
94
|
-
comparison =
|
|
102
|
+
comparison = comparisonFromComparisonNode(comparisonNode, context);
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
return comparison;
|
|
@@ -104,4 +112,18 @@ function negatedFromComparisonNode(comparisonNode) {
|
|
|
104
112
|
negated = (terminalNodeContent !== EQUAL_TO);
|
|
105
113
|
|
|
106
114
|
return negated;
|
|
107
|
-
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function comparisonFromComparisonNode(comparisonNode, context) {
|
|
118
|
+
const { Value, Comparison } = dom,
|
|
119
|
+
node = comparisonNode, ///
|
|
120
|
+
string = context.nodeAsString(node),
|
|
121
|
+
leftValueNode = leftValueNodeQuery(comparisonNode),
|
|
122
|
+
rightValueNode = rightValueNodeQuery(comparisonNode),
|
|
123
|
+
negated = negatedFromComparisonNode(comparisonNode, context),
|
|
124
|
+
leftValue = Value.fromValueNode(leftValueNode, context),
|
|
125
|
+
rightValue = Value.fromValueNode(rightValueNode, context),
|
|
126
|
+
comparison = new Comparison(string, negated, leftValue, rightValue);
|
|
127
|
+
|
|
128
|
+
return comparison;
|
|
129
|
+
}
|
package/src/dom/parameters.js
CHANGED
|
@@ -6,8 +6,8 @@ import Exception from "../exception";
|
|
|
6
6
|
import { domAssigned } from "../dom";
|
|
7
7
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const parameterNodesQuery = nodesQuery("/parameters/parameter"),
|
|
10
|
+
someParametersNodeQuery = nodeQuery("/some/parameters"),
|
|
11
11
|
arrayAssignmentParametersNodeQuery = nodeQuery("/arrayAssignment/parameters"),
|
|
12
12
|
objectAssignmentParametersNodeQuery = nodeQuery("/objectAssignment/parameters"),
|
|
13
13
|
procedureDeclarationParametersNodeQuery = nodeQuery("/procedureDeclaration/parameters");
|
|
@@ -107,16 +107,11 @@ export default domAssigned(class Parameters {
|
|
|
107
107
|
|
|
108
108
|
static name = "Parameters";
|
|
109
109
|
|
|
110
|
-
static
|
|
111
|
-
const parameters = new Parameters(string, array);
|
|
112
|
-
|
|
113
|
-
return parameters;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static fromForEachLoopNode(forEachLoopNode, context) {
|
|
110
|
+
static fromSomeNode(someNode, context) {
|
|
117
111
|
const { Parameter } = dom,
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
someParametersNode = someParametersNodeQuery(someNode),
|
|
113
|
+
parameterNode = someParametersNode, ///
|
|
114
|
+
parameterNodes = parameterNodesQuery(parameterNode),
|
|
120
115
|
array = parameterNodes.map((parameterNode) => {
|
|
121
116
|
const parameter = Parameter.fromParameterNode(parameterNode, context);
|
|
122
117
|
|
|
@@ -128,6 +123,12 @@ export default domAssigned(class Parameters {
|
|
|
128
123
|
return parameters;
|
|
129
124
|
}
|
|
130
125
|
|
|
126
|
+
static fromStringAndArray(string, array) {
|
|
127
|
+
const parameters = new Parameters(string, array);
|
|
128
|
+
|
|
129
|
+
return parameters;
|
|
130
|
+
}
|
|
131
|
+
|
|
131
132
|
static fromArrayAssignmentNode(arrayAssignmentNode, context) {
|
|
132
133
|
const arrayAssignmentParametersNode = arrayAssignmentParametersNodeQuery(arrayAssignmentNode),
|
|
133
134
|
parametersNode = arrayAssignmentParametersNode, ///
|
|
@@ -7,15 +7,15 @@ import { domAssigned } from "../../dom";
|
|
|
7
7
|
import { nodeQuery, nodesQuery } from "../../utilities/query";
|
|
8
8
|
import { variablesFromValuesAndParameters } from "../procedure";
|
|
9
9
|
|
|
10
|
-
const nonsenseNodesQuery = nodesQuery("/
|
|
11
|
-
parametersNodeQuery = nodeQuery("/
|
|
10
|
+
const nonsenseNodesQuery = nodesQuery("/some/anonymousProcedure/returnBlock/nonsense"),
|
|
11
|
+
parametersNodeQuery = nodeQuery("/some/anonymousProcedure/parameters");
|
|
12
12
|
|
|
13
13
|
export default domAssigned(class AnonymousProcedure {
|
|
14
|
-
constructor(string, parameters, nonsensical,
|
|
14
|
+
constructor(string, parameters, nonsensical, returnBlock) {
|
|
15
15
|
this.string = string;
|
|
16
16
|
this.parameters = parameters;
|
|
17
17
|
this.nonsensical = nonsensical;
|
|
18
|
-
this.
|
|
18
|
+
this.returnBlock = returnBlock;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
getString() {
|
|
@@ -30,11 +30,13 @@ export default domAssigned(class AnonymousProcedure {
|
|
|
30
30
|
return this.nonsensical;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
getReturnBlock() {
|
|
34
|
+
return this.returnBlock;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
call(values, context) {
|
|
38
|
+
debugger
|
|
39
|
+
|
|
38
40
|
const anonymousProcedureString = this.string; ///
|
|
39
41
|
|
|
40
42
|
context.trace(`Calling the '${anonymousProcedureString}' anonymous procedure...`);
|
|
@@ -50,35 +52,35 @@ export default domAssigned(class AnonymousProcedure {
|
|
|
50
52
|
|
|
51
53
|
const variables = variablesFromValuesAndParameters(values, this.parameters, context);
|
|
52
54
|
|
|
53
|
-
this.
|
|
55
|
+
this.returnBlock.evaluate(variables, context);
|
|
54
56
|
|
|
55
57
|
context.debug(`...called the '${anonymousProcedureString}' anonymous procedure.`);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
static name = "AnonymousProcedure";
|
|
59
61
|
|
|
60
|
-
static
|
|
61
|
-
const {
|
|
62
|
-
string =
|
|
63
|
-
parameters = Parameters.
|
|
64
|
-
nonsensical =
|
|
65
|
-
|
|
66
|
-
anonymousProcedureDeclaration = new AnonymousProcedure(string, parameters, nonsensical,
|
|
62
|
+
static fromSomeNode(someNode, context) {
|
|
63
|
+
const { ReturnBlock, Parameters } = dom,
|
|
64
|
+
string = stringFromSomeNode(someNode, context),
|
|
65
|
+
parameters = Parameters.fromSomeNode(someNode, context),
|
|
66
|
+
nonsensical = nonsensicalFromSomeNode(someNode, context),
|
|
67
|
+
returnBlock = ReturnBlock.fromSomeNode(someNode, context),
|
|
68
|
+
anonymousProcedureDeclaration = new AnonymousProcedure(string, parameters, nonsensical, returnBlock);
|
|
67
69
|
|
|
68
70
|
return anonymousProcedureDeclaration;
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
73
|
|
|
72
|
-
function
|
|
73
|
-
const parametersNode = parametersNodeQuery(
|
|
74
|
+
function stringFromSomeNode(someNode, context) {
|
|
75
|
+
const parametersNode = parametersNodeQuery(someNode),
|
|
74
76
|
parametersString = context.nodeAsString(parametersNode),
|
|
75
77
|
string = `(${parametersString}) { ... }`;
|
|
76
78
|
|
|
77
79
|
return string;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
function
|
|
81
|
-
const nonsenseNodes = nonsenseNodesQuery(
|
|
82
|
+
function nonsensicalFromSomeNode(someNode, context) {
|
|
83
|
+
const nonsenseNodes = nonsenseNodesQuery(someNode),
|
|
82
84
|
nonsenseNodesLength = nonsenseNodes.length,
|
|
83
85
|
nonsensical = (nonsenseNodesLength > 0);
|
|
84
86
|
|
|
@@ -7,11 +7,11 @@ import { nodeQuery } from "../utilities/query";
|
|
|
7
7
|
import { NODES_TYPE } from "../types";
|
|
8
8
|
import { domAssigned } from "../dom";
|
|
9
9
|
|
|
10
|
-
const variableNodeQuery = nodeQuery("/
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const variableNodeQuery = nodeQuery("/some/variable"),
|
|
11
|
+
valueSomeNodeQuery = nodeQuery("/value/some"),
|
|
12
|
+
parametersNodeQuery = nodeQuery("/some/anonymousProcedure/parameters");
|
|
13
13
|
|
|
14
|
-
export default domAssigned(class
|
|
14
|
+
export default domAssigned(class Some {
|
|
15
15
|
constructor(string, variable, anonymousProcedure) {
|
|
16
16
|
this.string = string;
|
|
17
17
|
this.variable = variable;
|
|
@@ -31,9 +31,11 @@ export default domAssigned(class ForEachLoop {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
evaluate(context) {
|
|
34
|
-
|
|
34
|
+
debugger
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const someString = this.getString();
|
|
37
|
+
|
|
38
|
+
context.trace(`Evaluating the '${someString}' some loop...`);
|
|
37
39
|
|
|
38
40
|
const value = this.variable.evaluate(context),
|
|
39
41
|
valueType = value.getType();
|
|
@@ -48,7 +50,7 @@ export default domAssigned(class ForEachLoop {
|
|
|
48
50
|
|
|
49
51
|
const nodes = value.getNodes();
|
|
50
52
|
|
|
51
|
-
nodes.
|
|
53
|
+
nodes.some((node) => {
|
|
52
54
|
const { Value, Values } = dom,
|
|
53
55
|
value = Value.fromNode(node, context),
|
|
54
56
|
values = Values.fromValue(value, context);
|
|
@@ -56,35 +58,36 @@ export default domAssigned(class ForEachLoop {
|
|
|
56
58
|
this.anonymousProcedure.call(values, context);
|
|
57
59
|
});
|
|
58
60
|
|
|
59
|
-
context.trace(`...evaluated the '${
|
|
61
|
+
context.trace(`...evaluated the '${someString}' some loop.`);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
static name = "
|
|
64
|
+
static name = "Some";
|
|
63
65
|
|
|
64
|
-
static
|
|
65
|
-
let
|
|
66
|
+
static fromValueNode(valueNode, context) {
|
|
67
|
+
let some = null;
|
|
66
68
|
|
|
67
|
-
const
|
|
69
|
+
const valueSomeNode = valueSomeNodeQuery(valueNode);
|
|
68
70
|
|
|
69
|
-
if (
|
|
71
|
+
if (valueSomeNode !== null) {
|
|
70
72
|
const { Variable, AnonymousProcedure } = dom,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
someNode = valueSomeNode, ///
|
|
74
|
+
string = stringFromSomeNode(someNode, context),
|
|
75
|
+
variable = Variable.fromSomeNode(someNode, context),
|
|
76
|
+
anonymousProcedure = AnonymousProcedure.fromSomeNode(someNode, context);
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
some = new Some(string, variable, anonymousProcedure);
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
return
|
|
81
|
+
return some;
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
84
|
|
|
82
|
-
function
|
|
83
|
-
const variableNode = variableNodeQuery(
|
|
84
|
-
parametersNode = parametersNodeQuery(
|
|
85
|
+
function stringFromSomeNode(someNode, context) {
|
|
86
|
+
const variableNode = variableNodeQuery(someNode),
|
|
87
|
+
parametersNode = parametersNodeQuery(someNode),
|
|
85
88
|
variableString = context.nodeAsString(variableNode),
|
|
86
89
|
parametersString = context.nodeAsString(parametersNode),
|
|
87
|
-
string = `
|
|
90
|
+
string = `Some(${variableString}, (${parametersString}) { ... })`;
|
|
88
91
|
|
|
89
92
|
return string;
|
|
90
93
|
}
|
package/src/dom/step.js
CHANGED
|
@@ -5,9 +5,8 @@ import dom from "../dom";
|
|
|
5
5
|
import { domAssigned } from "../dom";
|
|
6
6
|
|
|
7
7
|
export default domAssigned(class Step {
|
|
8
|
-
constructor(string,
|
|
8
|
+
constructor(string, arrayAssignment, objectAssigment, conditionalBlocks, variableAssignment, variablesDeclaration) {
|
|
9
9
|
this.string = string;
|
|
10
|
-
this.forEachLoop = forEachLoop;
|
|
11
10
|
this.arrayAssignment = arrayAssignment;
|
|
12
11
|
this.objectAssigment = objectAssigment;
|
|
13
12
|
this.conditionalBlocks = conditionalBlocks;
|
|
@@ -19,10 +18,6 @@ export default domAssigned(class Step {
|
|
|
19
18
|
return this.string;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
getForEachLoop() {
|
|
23
|
-
return this.forEachLoop;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
getArrayAssignment() {
|
|
27
22
|
return this.arrayAssignment;
|
|
28
23
|
}
|
|
@@ -47,8 +42,6 @@ export default domAssigned(class Step {
|
|
|
47
42
|
|
|
48
43
|
if (false) {
|
|
49
44
|
///
|
|
50
|
-
} else if (this.forEachLoop !== null) {
|
|
51
|
-
this.forEachLoop.evaluate(context);
|
|
52
45
|
} else if (this.arrayAssignment !== null) {
|
|
53
46
|
this.arrayAssignment.evaluate(context);
|
|
54
47
|
} else if (this.objectAssigment !== null) {
|
|
@@ -65,16 +58,15 @@ export default domAssigned(class Step {
|
|
|
65
58
|
static name = "Step";
|
|
66
59
|
|
|
67
60
|
static fromStepNode(stepNode, context) {
|
|
68
|
-
const {
|
|
61
|
+
const { ArrayAssignment, ObjectAssigment, ConditionalBlocks, VariableAssignment, VariablesDeclaration } = dom,
|
|
69
62
|
node = stepNode, ///
|
|
70
63
|
string = context.nodeAsString(node),
|
|
71
|
-
forEachLoop = ForEachLoop.fromStepNode(stepNode, context),
|
|
72
64
|
arrayAssignment = ArrayAssignment.fromStepNode(stepNode, context),
|
|
73
65
|
objectAssigment = ObjectAssigment.fromStepNode(stepNode, context),
|
|
74
66
|
conditionalBlocks = ConditionalBlocks.fromStepNode(stepNode, context),
|
|
75
67
|
variableAssignment = VariableAssignment.fromStepNode(stepNode, context),
|
|
76
68
|
variablesDeclaration = VariablesDeclaration.fromStepNode(stepNode, context),
|
|
77
|
-
step = new Step(string,
|
|
69
|
+
step = new Step(string, arrayAssignment, objectAssigment, conditionalBlocks, variableAssignment, variablesDeclaration);
|
|
78
70
|
|
|
79
71
|
return step;
|
|
80
72
|
}
|
package/src/dom/value.js
CHANGED
|
@@ -20,16 +20,18 @@ const numberTerminalNodeQuery = nodeQuery("/value/@number"),
|
|
|
20
20
|
stringLiteralTerminalNodeQuery = nodeQuery("/value/@string-literal");
|
|
21
21
|
|
|
22
22
|
export default domAssigned(class Value {
|
|
23
|
-
constructor(node, nodes, number, string, boolean, ternary, variable, nodeQuery, nodesQuery, procedureCall) {
|
|
23
|
+
constructor(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, procedureCall) {
|
|
24
24
|
this.node = node;
|
|
25
25
|
this.nodes = nodes;
|
|
26
26
|
this.number = number;
|
|
27
27
|
this.string = string;
|
|
28
28
|
this.boolean = boolean;
|
|
29
|
+
this.some = some;
|
|
29
30
|
this.ternary = ternary;
|
|
30
31
|
this.variable = variable;
|
|
31
32
|
this.nodeQuery = nodeQuery;
|
|
32
33
|
this.nodesQuery = nodesQuery;
|
|
34
|
+
this.comparison = comparison;
|
|
33
35
|
this.procedureCall = procedureCall;
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -53,6 +55,10 @@ export default domAssigned(class Value {
|
|
|
53
55
|
return this.boolean;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
getSome() {
|
|
59
|
+
return this.some;
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
getTernary() {
|
|
57
63
|
return this.ternay;
|
|
58
64
|
}
|
|
@@ -69,6 +75,10 @@ export default domAssigned(class Value {
|
|
|
69
75
|
return this.nodesQuery;
|
|
70
76
|
}
|
|
71
77
|
|
|
78
|
+
getComparison() {
|
|
79
|
+
return this.comparison;
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
getProcedureCall() {
|
|
73
83
|
return this.procedureCall;
|
|
74
84
|
}
|
|
@@ -88,6 +98,8 @@ export default domAssigned(class Value {
|
|
|
88
98
|
type = STRING_TYPE;
|
|
89
99
|
} else if (this.boolean !== null) {
|
|
90
100
|
type = BOOLEAN_TYPE;
|
|
101
|
+
} else if (this.some !== null) {
|
|
102
|
+
type = this.some.getType();
|
|
91
103
|
} else if (this.ternary !== null) {
|
|
92
104
|
type = this.ternary.getType();
|
|
93
105
|
} else if (this.variable !== null) {
|
|
@@ -96,6 +108,8 @@ export default domAssigned(class Value {
|
|
|
96
108
|
type = this.nodeQuery.getType();
|
|
97
109
|
} else if (this.nodesQuery !== null) {
|
|
98
110
|
type = this.nodesQuery.getType();
|
|
111
|
+
} else if (this.comparison !== null) {
|
|
112
|
+
type = this.comparison.getType();
|
|
99
113
|
} else if (this.procedureCall !== null) {
|
|
100
114
|
type = this.procedureCall.getType();
|
|
101
115
|
}
|
|
@@ -118,6 +132,8 @@ export default domAssigned(class Value {
|
|
|
118
132
|
string = stringAsString(this.string, context)
|
|
119
133
|
} else if (this.boolean !== null) {
|
|
120
134
|
string = booleanAsString(this.boolean, context)
|
|
135
|
+
} else if (this.some !== null) {
|
|
136
|
+
string = this.some.asString(context);
|
|
121
137
|
} else if (this.ternary !== null) {
|
|
122
138
|
string = this.ternary.asString(context);
|
|
123
139
|
} else if (this.variable !== null) {
|
|
@@ -126,6 +142,8 @@ export default domAssigned(class Value {
|
|
|
126
142
|
string = this.nodeQuery.asString(context);
|
|
127
143
|
} else if (this.nodesQuery !== null) {
|
|
128
144
|
string = this.nodesQuery.asString(context);
|
|
145
|
+
} else if (this.comparison !== null) {
|
|
146
|
+
string = this.comparison.asString(context);
|
|
129
147
|
} else if (this.procedureCall !== null) {
|
|
130
148
|
string = this.procedureCall.asString(context);
|
|
131
149
|
}
|
|
@@ -144,6 +162,8 @@ export default domAssigned(class Value {
|
|
|
144
162
|
(this.string !== null) ||
|
|
145
163
|
(this.boolean !== null)) {
|
|
146
164
|
value = this;
|
|
165
|
+
} else if (this.some !== null) {
|
|
166
|
+
value = this.some.evaluate(context);
|
|
147
167
|
} else if (this.ternary !== null) {
|
|
148
168
|
value = this.ternary.evaluate(context);
|
|
149
169
|
} else if (this.variable !== null) {
|
|
@@ -152,6 +172,8 @@ export default domAssigned(class Value {
|
|
|
152
172
|
value = this.nodeQuery.evaluate(context);
|
|
153
173
|
} else if (this.nodesQuery !== null) {
|
|
154
174
|
value = this.nodesQuery.evaluate(context);
|
|
175
|
+
} else if (this.comparison !== null) {
|
|
176
|
+
value = this.comparison.evaluate(context);
|
|
155
177
|
} else if (this.procedureCall !== null) {
|
|
156
178
|
value = this.procedureCall.evaluate(context);
|
|
157
179
|
}
|
|
@@ -218,12 +240,14 @@ export default domAssigned(class Value {
|
|
|
218
240
|
number = null,
|
|
219
241
|
string = null,
|
|
220
242
|
boolean = null,
|
|
243
|
+
some = null,
|
|
221
244
|
ternary = null,
|
|
222
245
|
variable = null,
|
|
223
246
|
nodeQuery = null,
|
|
224
247
|
nodesQuery = null,
|
|
248
|
+
comparison = null,
|
|
225
249
|
procedureCall = null,
|
|
226
|
-
value = new Value(node, nodes, number, string, boolean, ternary, variable, nodeQuery, nodesQuery, procedureCall);
|
|
250
|
+
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, procedureCall);
|
|
227
251
|
|
|
228
252
|
return value;
|
|
229
253
|
}
|
|
@@ -234,11 +258,13 @@ export default domAssigned(class Value {
|
|
|
234
258
|
string = null,
|
|
235
259
|
boolean = null,
|
|
236
260
|
ternary = null,
|
|
261
|
+
some = null,
|
|
237
262
|
variable = null,
|
|
238
263
|
nodeQuery = null,
|
|
239
264
|
nodesQuery = null,
|
|
265
|
+
comparison = null,
|
|
240
266
|
procedureCall = null,
|
|
241
|
-
value = new Value(node, nodes, number, string, boolean, ternary, variable, nodeQuery, nodesQuery, procedureCall);
|
|
267
|
+
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, procedureCall);
|
|
242
268
|
|
|
243
269
|
return value;
|
|
244
270
|
}
|
|
@@ -248,12 +274,14 @@ export default domAssigned(class Value {
|
|
|
248
274
|
nodes = null,
|
|
249
275
|
number = null,
|
|
250
276
|
boolean = null,
|
|
277
|
+
some = null,
|
|
251
278
|
ternary = null,
|
|
252
279
|
variable = null,
|
|
253
280
|
nodeQuery = null,
|
|
254
281
|
nodesQuery = null,
|
|
282
|
+
comparison = null,
|
|
255
283
|
procedureCall = null,
|
|
256
|
-
value = new Value(node, nodes, number, string, boolean, ternary, variable, nodeQuery, nodesQuery, procedureCall);
|
|
284
|
+
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, procedureCall);
|
|
257
285
|
|
|
258
286
|
return value;
|
|
259
287
|
}
|
|
@@ -263,12 +291,14 @@ export default domAssigned(class Value {
|
|
|
263
291
|
nodes = null,
|
|
264
292
|
number = null,
|
|
265
293
|
string = null,
|
|
294
|
+
some = null,
|
|
266
295
|
ternary = null,
|
|
267
296
|
variable = null,
|
|
268
297
|
nodeQuery = null,
|
|
269
298
|
nodesQuery = null,
|
|
299
|
+
comparison = null,
|
|
270
300
|
procedureCall = null,
|
|
271
|
-
value = new Value(node, nodes, number, string, boolean, ternary, variable, nodeQuery, nodesQuery, procedureCall);
|
|
301
|
+
value = new Value(node, nodes, number, string, boolean, some, ternary, variable, nodeQuery, nodesQuery, comparison, procedureCall);
|
|
272
302
|
|
|
273
303
|
return value;
|
|
274
304
|
}
|
|
@@ -395,7 +425,7 @@ function booleanAsString(boolean, context) {
|
|
|
395
425
|
}
|
|
396
426
|
|
|
397
427
|
function valueFromValueNode(valueNode, context) {
|
|
398
|
-
const { Value, Ternary, Variable, NodeQuery, NodesQuery, ProcedureCall } = dom,
|
|
428
|
+
const { Value, Ternary, Variable, NodeQuery, NodesQuery, Comparison, ProcedureCall } = dom,
|
|
399
429
|
node = nodeFromValueNode(valueNode, context),
|
|
400
430
|
nodes = nodesFromValueNode(valueNode, context),
|
|
401
431
|
number = numberFromValueNode(valueNode, context),
|
|
@@ -405,8 +435,9 @@ function valueFromValueNode(valueNode, context) {
|
|
|
405
435
|
variable = Variable.fromValueNode(valueNode, context),
|
|
406
436
|
nodeQuery = NodeQuery.fromValueNode(valueNode, context),
|
|
407
437
|
nodesQuery = NodesQuery.fromValueNode(valueNode, context),
|
|
438
|
+
comparison = Comparison.fromValueNode(valueNode, context),
|
|
408
439
|
procedureCall = ProcedureCall.fromValueNode(valueNode, context),
|
|
409
|
-
value = new Value(node, nodes, number, string, boolean, ternary, variable, nodeQuery, nodesQuery, procedureCall);
|
|
440
|
+
value = new Value(node, nodes, number, string, boolean, ternary, variable, nodeQuery, nodesQuery, comparison, procedureCall);
|
|
410
441
|
|
|
411
442
|
return value;
|
|
412
443
|
}
|
package/src/dom/variable.js
CHANGED
|
@@ -6,10 +6,10 @@ import Exception from "../exception";
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const someVariableNodeQuery = nodeQuery("/some/variable"),
|
|
10
|
+
valueVariableNodeQuery = nodeQuery("/value/variable"),
|
|
10
11
|
nodeQueryVariableNodeQuery = nodeQuery("/nodeQuery/variable"),
|
|
11
12
|
nodesQueryVariableNodeQuery = nodeQuery("/nodesQuery/variable"),
|
|
12
|
-
forEachLoopVariableNodeQuery = nodeQuery("/forEachLoop/variable"),
|
|
13
13
|
variableNameTerminalNodeQuery = nodeQuery("/variable/@name"),
|
|
14
14
|
arrayAssignmentVariableNodeQuery = nodeQuery("/arrayAssignment/variable"),
|
|
15
15
|
objectAssignmentVariableNodeQuery = nodeQuery("/objectAssignment/variable"),
|
|
@@ -133,6 +133,14 @@ export default domAssigned(class Variable {
|
|
|
133
133
|
|
|
134
134
|
static name = "Variable";
|
|
135
135
|
|
|
136
|
+
static fromSomeNode(someLoopNode, context) {
|
|
137
|
+
const someVariableNode = someVariableNodeQuery(someLoopNode),
|
|
138
|
+
variableNode = someVariableNode, ///
|
|
139
|
+
variable = variableFromVariableNode(variableNode, context);
|
|
140
|
+
|
|
141
|
+
return variable;
|
|
142
|
+
}
|
|
143
|
+
|
|
136
144
|
static fromValueNode(valueNode, context) {
|
|
137
145
|
let variable = null;
|
|
138
146
|
|
|
@@ -163,14 +171,6 @@ export default domAssigned(class Variable {
|
|
|
163
171
|
return variable;
|
|
164
172
|
}
|
|
165
173
|
|
|
166
|
-
static fromForEachLoopNode(forEachLoopLoopNode, context) {
|
|
167
|
-
const forEachLoopVariableNode = forEachLoopVariableNodeQuery(forEachLoopLoopNode),
|
|
168
|
-
variableNode = forEachLoopVariableNode, ///
|
|
169
|
-
variable = variableFromVariableNode(variableNode, context);
|
|
170
|
-
|
|
171
|
-
return variable;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
174
|
static fromValueAndParameter(value, parameter, context) {
|
|
175
175
|
const type = parameter.getType(),
|
|
176
176
|
name = parameter.getName(),
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Step from "./dom/step";
|
|
4
|
+
import Some from "./dom/some";
|
|
4
5
|
import Label from "./dom/label";
|
|
5
6
|
import Block from "./dom/block";
|
|
6
7
|
import Error from "./dom/error";
|
|
@@ -18,7 +19,6 @@ import NodesQuery from "./dom/query/nodes";
|
|
|
18
19
|
import Comparison from "./dom/comparison";
|
|
19
20
|
import Assignment from "./dom/assignment";
|
|
20
21
|
import ReturnBlock from "./dom/block/return";
|
|
21
|
-
import ForEachLoop from "./dom/forEachLoop";
|
|
22
22
|
import ProcedureCall from "./dom/procedureCall";
|
|
23
23
|
import ArrayAssigment from "./dom/assignment/array";
|
|
24
24
|
import ReturnStatement from "./dom/returnStatement";
|