occam-furtle 2.0.63 → 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/_occam-grammars/furtle/entries.js +2 -2
- package/lib/dom/block.js +2 -9
- package/lib/dom/comparison.js +22 -6
- package/lib/dom/condition.js +19 -12
- 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 +10 -22
- package/lib/dom/ternary.js +157 -0
- package/lib/dom/value.js +90 -52
- package/lib/dom/variable.js +9 -9
- package/lib/index.js +3 -2
- package/lib/nullNode.js +48 -0
- package/package.json +4 -4
- package/src/_occam-grammars/furtle/bnf.js +9 -5
- package/src/_occam-grammars/furtle/entries.js +1 -1
- package/src/dom/block.js +1 -14
- package/src/dom/comparison.js +35 -13
- package/src/dom/condition.js +32 -32
- 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 +10 -25
- package/src/dom/ternary.js +93 -0
- package/src/dom/value.js +99 -37
- package/src/dom/variable.js +10 -10
- package/src/index.js +2 -1
- package/src/nullNode.js +14 -0
- package/lib/dom/forEachLoop.js +0 -161
package/lib/nullNode.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _class_call_check(instance, Constructor) {
|
|
12
|
+
if (!(instance instanceof Constructor)) {
|
|
13
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _defineProperties(target, props) {
|
|
17
|
+
for(var i = 0; i < props.length; i++){
|
|
18
|
+
var descriptor = props[i];
|
|
19
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
20
|
+
descriptor.configurable = true;
|
|
21
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
22
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
26
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
27
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
28
|
+
return Constructor;
|
|
29
|
+
}
|
|
30
|
+
var NullNode = /*#__PURE__*/ function() {
|
|
31
|
+
function NullNode() {
|
|
32
|
+
_class_call_check(this, NullNode);
|
|
33
|
+
}
|
|
34
|
+
_create_class(NullNode, null, [
|
|
35
|
+
{
|
|
36
|
+
key: "fromNothing",
|
|
37
|
+
value: function fromNothing() {
|
|
38
|
+
var nullNode = new NullNode();
|
|
39
|
+
return nullNode;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]);
|
|
43
|
+
return NullNode;
|
|
44
|
+
}();
|
|
45
|
+
var nullNode = NullNode.fromNothing();
|
|
46
|
+
var _default = nullNode;
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9udWxsTm9kZS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuY2xhc3MgTnVsbE5vZGUge1xuICBzdGF0aWMgZnJvbU5vdGhpbmcoKSB7XG4gICAgY29uc3QgbnVsbE5vZGUgPSBuZXcgTnVsbE5vZGUoKTtcblxuICAgIHJldHVybiBudWxsTm9kZTtcbiAgfVxufVxuXG5jb25zdCBudWxsTm9kZSA9IE51bGxOb2RlLmZyb21Ob3RoaW5nKCk7XG5cbmV4cG9ydCBkZWZhdWx0IG51bGxOb2RlO1xuXG4iXSwibmFtZXMiOlsiTnVsbE5vZGUiLCJmcm9tTm90aGluZyIsIm51bGxOb2RlIl0sIm1hcHBpbmdzIjoiQUFBQTs7OzsrQkFZQTs7O2VBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFWQSxJQUFBLEFBQU1BLHlCQUFOO2FBQU1BO2dDQUFBQTs7a0JBQUFBOztZQUNHQyxLQUFBQTttQkFBUCxTQUFPQTtnQkFDTCxJQUFNQyxXQUFXLElBRmZGO2dCQUlGLE9BQU9FO1lBQ1Q7OztXQUxJRjs7QUFRTixJQUFNRSxXQUFXRixTQUFTQyxXQUFXO0lBRXJDLFdBQWVDIn0=
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "occam-furtle",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.65",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/occam-furtle",
|
|
7
7
|
"description": "Occam's Furtle language.",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"necessary": "^14.3.2",
|
|
14
|
-
"occam-grammars": "^1.3.
|
|
14
|
+
"occam-grammars": "^1.3.153"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@swc/core": "^1.5.6",
|
|
18
|
-
"occam-custom-grammars": "^5.0.
|
|
19
|
-
"occam-entities": "^1.0.
|
|
18
|
+
"occam-custom-grammars": "^5.0.1081",
|
|
19
|
+
"occam-entities": "^1.0.291",
|
|
20
20
|
"occam-grammar-utilities": "^8.0.258",
|
|
21
21
|
"occam-lexers": "^23.0.45",
|
|
22
22
|
"occam-parsers": "^23.0.50",
|
|
@@ -22,11 +22,9 @@ objectAssignment ::= "{" parameters "}" "=" variable ";" ;
|
|
|
22
22
|
|
|
23
23
|
arrayAssignment ::= "[" parameters "]" "=" variable ";" ;
|
|
24
24
|
|
|
25
|
-
forEachLoop ::= "ForEach"<NO_WHITESPACE>"(" variable "," anonymousProcedure ")" ";" ;
|
|
26
25
|
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
anonymousProcedure ::= "(" parameters? ")" block ;
|
|
27
|
+
anonymousProcedure ::= "(" parameters? ")" returnBlock ;
|
|
30
28
|
|
|
31
29
|
|
|
32
30
|
|
|
@@ -71,8 +69,6 @@ step ::= variablesDeclaration
|
|
|
71
69
|
|
|
72
70
|
| arrayAssignment
|
|
73
71
|
|
|
74
|
-
| forEachLoop
|
|
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,10 @@ value ::= procedureCall
|
|
|
91
89
|
|
|
92
90
|
| ternary
|
|
93
91
|
|
|
92
|
+
| some
|
|
93
|
+
|
|
94
|
+
| [null]
|
|
95
|
+
|
|
94
96
|
| [number]
|
|
95
97
|
|
|
96
98
|
| [primitive]
|
|
@@ -111,6 +113,8 @@ variable ::= [name] ;
|
|
|
111
113
|
|
|
112
114
|
ternary ::= "If" "(" condition ")" value "Else" value ;
|
|
113
115
|
|
|
116
|
+
some ::= "Some"<NO_WHITESPACE>"(" variable "," anonymousProcedure ")" ";" ;
|
|
117
|
+
|
|
114
118
|
|
|
115
119
|
|
|
116
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/condition.js
CHANGED
|
@@ -7,7 +7,8 @@ import { nodeQuery } from "../utilities/query";
|
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
import { BOOLEAN_TYPE } from "../types";
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const ternaryConditionNodeQuery = nodeQuery("/ternary/condition"),
|
|
11
|
+
conditionalBlocksConditionNodeQuery = nodeQuery("/conditionalBlocks/condition");
|
|
11
12
|
|
|
12
13
|
export default domAssigned(class Condition {
|
|
13
14
|
constructor(string, value, comparison, bitwiseCondition, negatedCondition, bracketedCondition) {
|
|
@@ -62,21 +63,13 @@ export default domAssigned(class Condition {
|
|
|
62
63
|
|
|
63
64
|
throw exception;
|
|
64
65
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (this.comparison !== null) {
|
|
66
|
+
} else if (this.comparison !== null) {
|
|
68
67
|
value = this.comparison.evaluate(context);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (this.bitwiseCondition !== null) {
|
|
68
|
+
} else if (this.bitwiseCondition !== null) {
|
|
72
69
|
value = this.bitwiseCondition.evaluate(context);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (this.negatedCondition !== null) {
|
|
70
|
+
} else if (this.negatedCondition !== null) {
|
|
76
71
|
value = this.negatedCondition.evaluate(context);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (this.bracketedCondition !== null) {
|
|
72
|
+
} else if (this.bracketedCondition !== null) {
|
|
80
73
|
value = this.bracketedCondition.evaluate(context);
|
|
81
74
|
}
|
|
82
75
|
|
|
@@ -87,32 +80,39 @@ export default domAssigned(class Condition {
|
|
|
87
80
|
|
|
88
81
|
static name = "Condition";
|
|
89
82
|
|
|
83
|
+
static fromTernaryNode(ternaryNode, context) {
|
|
84
|
+
const ternaryConditionNode = ternaryConditionNodeQuery(ternaryNode),
|
|
85
|
+
conditionNode = ternaryConditionNode, ///
|
|
86
|
+
condition = conditionFromConditionNode(conditionNode, context);
|
|
87
|
+
|
|
88
|
+
return condition;
|
|
89
|
+
}
|
|
90
|
+
|
|
90
91
|
static fromConditionNode(conditionNode, context) {
|
|
91
|
-
const
|
|
92
|
-
node = conditionNode, ///
|
|
93
|
-
string = context.nodeAsString(node),
|
|
94
|
-
value = Value.fromConditionNode(conditionNode, context),
|
|
95
|
-
comparison = Comparison.fromConditionNode(conditionNode, context),
|
|
96
|
-
bitwiseCondition = BitwiseCondition.fromConditionNode(conditionNode, context),
|
|
97
|
-
negatedCondition = NegatedCondition.fromConditionNode(conditionNode, context),
|
|
98
|
-
bracketedCondition = BracketedCondition.fromConditionNode(conditionNode, context),
|
|
99
|
-
condition = new Condition(string, value, comparison, bitwiseCondition, negatedCondition, bracketedCondition);
|
|
92
|
+
const condition = conditionFromConditionNode(conditionNode, context);
|
|
100
93
|
|
|
101
94
|
return condition;
|
|
102
95
|
}
|
|
103
96
|
|
|
104
97
|
static fromConditionalBlocksNode(conditionalBlocksNode, context) {
|
|
105
|
-
const
|
|
106
|
-
conditionNode =
|
|
107
|
-
|
|
108
|
-
string = context.nodeAsString(node),
|
|
109
|
-
value = Value.fromConditionNode(conditionNode, context),
|
|
110
|
-
comparison = Comparison.fromConditionNode(conditionNode, context),
|
|
111
|
-
bitwiseCondition = BitwiseCondition.fromConditionNode(conditionNode, context),
|
|
112
|
-
negatedCondition = NegatedCondition.fromConditionNode(conditionNode, context),
|
|
113
|
-
bracketedCondition = BracketedCondition.fromConditionNode(conditionNode, context),
|
|
114
|
-
condition = new Condition(string, value, comparison, bitwiseCondition, negatedCondition, bracketedCondition);
|
|
98
|
+
const conditionalBlocksConditionNode = conditionalBlocksConditionNodeQuery(conditionalBlocksNode),
|
|
99
|
+
conditionNode = conditionalBlocksConditionNode, ///
|
|
100
|
+
condition = conditionFromConditionNode(conditionNode, context);
|
|
115
101
|
|
|
116
102
|
return condition;
|
|
117
103
|
}
|
|
118
104
|
});
|
|
105
|
+
|
|
106
|
+
function conditionFromConditionNode(conditionNode, context) {
|
|
107
|
+
const { Condition, Value, Comparison, BitwiseCondition, NegatedCondition, BracketedCondition } = dom,
|
|
108
|
+
node = conditionNode, ///
|
|
109
|
+
string = context.nodeAsString(node),
|
|
110
|
+
value = Value.fromConditionNode(conditionNode, context),
|
|
111
|
+
comparison = Comparison.fromConditionNode(conditionNode, context),
|
|
112
|
+
bitwiseCondition = BitwiseCondition.fromConditionNode(conditionNode, context),
|
|
113
|
+
negatedCondition = NegatedCondition.fromConditionNode(conditionNode, context),
|
|
114
|
+
bracketedCondition = BracketedCondition.fromConditionNode(conditionNode, context),
|
|
115
|
+
condition = new Condition(string, value, comparison, bitwiseCondition, negatedCondition, bracketedCondition);
|
|
116
|
+
|
|
117
|
+
return condition;
|
|
118
|
+
}
|
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
|
}
|
|
@@ -44,27 +39,18 @@ export default domAssigned(class Step {
|
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
evaluate(context) {
|
|
47
|
-
if (this.forEachLoop !== null) {
|
|
48
|
-
this.forEachLoop.evaluate(context);
|
|
49
|
-
}
|
|
50
42
|
|
|
51
|
-
if (
|
|
43
|
+
if (false) {
|
|
44
|
+
///
|
|
45
|
+
} else if (this.arrayAssignment !== null) {
|
|
52
46
|
this.arrayAssignment.evaluate(context);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (this.objectAssigment !== null) {
|
|
47
|
+
} else if (this.objectAssigment !== null) {
|
|
56
48
|
this.objectAssigment.evaluate(context);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (this.conditionalBlocks !== null) {
|
|
49
|
+
} else if (this.conditionalBlocks !== null) {
|
|
60
50
|
this.conditionalBlocks.evaluate(context);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (this.variableAssignment !== null) {
|
|
51
|
+
} else if (this.variableAssignment !== null) {
|
|
64
52
|
this.variableAssignment.evaluate(context);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (this.variablesDeclaration !== null) {
|
|
53
|
+
} else if (this.variablesDeclaration !== null) {
|
|
68
54
|
this.variablesDeclaration.evaluate(context);
|
|
69
55
|
}
|
|
70
56
|
}
|
|
@@ -72,16 +58,15 @@ export default domAssigned(class Step {
|
|
|
72
58
|
static name = "Step";
|
|
73
59
|
|
|
74
60
|
static fromStepNode(stepNode, context) {
|
|
75
|
-
const {
|
|
61
|
+
const { ArrayAssignment, ObjectAssigment, ConditionalBlocks, VariableAssignment, VariablesDeclaration } = dom,
|
|
76
62
|
node = stepNode, ///
|
|
77
63
|
string = context.nodeAsString(node),
|
|
78
|
-
forEachLoop = ForEachLoop.fromStepNode(stepNode, context),
|
|
79
64
|
arrayAssignment = ArrayAssignment.fromStepNode(stepNode, context),
|
|
80
65
|
objectAssigment = ObjectAssigment.fromStepNode(stepNode, context),
|
|
81
66
|
conditionalBlocks = ConditionalBlocks.fromStepNode(stepNode, context),
|
|
82
67
|
variableAssignment = VariableAssignment.fromStepNode(stepNode, context),
|
|
83
68
|
variablesDeclaration = VariablesDeclaration.fromStepNode(stepNode, context),
|
|
84
|
-
step = new Step(string,
|
|
69
|
+
step = new Step(string, arrayAssignment, objectAssigment, conditionalBlocks, variableAssignment, variablesDeclaration);
|
|
85
70
|
|
|
86
71
|
return step;
|
|
87
72
|
}
|