occam-furtle 2.0.120 → 2.0.122
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
package/src/dom/some.js
CHANGED
|
@@ -7,7 +7,7 @@ import { nodeQuery } from "../utilities/query";
|
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
import { NODES_TYPE, BOOLEAN_TYPE } from "../types";
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const expressionSomeNodeQuery = nodeQuery("/expression/some");
|
|
11
11
|
|
|
12
12
|
export default domAssigned(class Some {
|
|
13
13
|
constructor(string, variable, anonymousProcedure) {
|
|
@@ -29,69 +29,69 @@ export default domAssigned(class Some {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
evaluate(context) {
|
|
32
|
-
let
|
|
32
|
+
let expression;
|
|
33
33
|
|
|
34
34
|
const someString = this.getString();
|
|
35
35
|
|
|
36
36
|
context.trace(`Evaluating the '${someString}' some...`);
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
expression = this.variable.evaluate(context);
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const expressionType = expression.getType();
|
|
41
41
|
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
message = `The ${
|
|
42
|
+
if (expressionType !== NODES_TYPE) {
|
|
43
|
+
const expressionString = expression.asString(context),
|
|
44
|
+
message = `The ${expressionString} expression's '${expressionType}' type should be '${NODES_TYPE}'.`,
|
|
45
45
|
exception = Exception.fromMessage(message);
|
|
46
46
|
|
|
47
47
|
throw exception;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const nodes =
|
|
50
|
+
const nodes = expression.getNodes(),
|
|
51
51
|
boolean = nodes.some((node) => {
|
|
52
|
-
let
|
|
52
|
+
let expression;
|
|
53
53
|
|
|
54
|
-
const {
|
|
54
|
+
const { Expression, Expressions } = dom;
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
expression = Expression.fromNode(node, context);
|
|
57
57
|
|
|
58
|
-
const
|
|
58
|
+
const expressions = Expressions.fromExpression(expression, context);
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
expression = this.anonymousProcedure.call(expressions, context);
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const expressionType = expression.getType();
|
|
63
63
|
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
message = `The ${
|
|
64
|
+
if (expressionType !== BOOLEAN_TYPE) {
|
|
65
|
+
const expressionString = expression.asString(context),
|
|
66
|
+
message = `The ${expressionString} expression's type is '${expressionType}' when it should be of type '${BOOLEAN_TYPE}'.`,
|
|
67
67
|
exception = Exception.fromMessage(message);
|
|
68
68
|
|
|
69
69
|
throw exception;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const boolean =
|
|
72
|
+
const boolean = expression.getBoolean();
|
|
73
73
|
|
|
74
74
|
return boolean;
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
const {
|
|
77
|
+
const { Expression } = dom;
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
expression = Expression.fromBoolean(boolean, context);
|
|
80
80
|
|
|
81
81
|
context.trace(`...evaluated the '${someString}' some.`);
|
|
82
82
|
|
|
83
|
-
return
|
|
83
|
+
return expression;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
static name = "Some";
|
|
87
87
|
|
|
88
|
-
static
|
|
88
|
+
static fromExpressionNode(expressionNode, context) {
|
|
89
89
|
let some = null;
|
|
90
90
|
|
|
91
|
-
const
|
|
91
|
+
const expressionSomeNode = expressionSomeNodeQuery(expressionNode);
|
|
92
92
|
|
|
93
|
-
if (
|
|
94
|
-
const someNode =
|
|
93
|
+
if (expressionSomeNode !== null) {
|
|
94
|
+
const someNode = expressionSomeNode; ///
|
|
95
95
|
|
|
96
96
|
some = someFromSomeNode(someNode, context);
|
|
97
97
|
}
|
|
@@ -8,31 +8,31 @@ import { domAssigned } from "../../dom";
|
|
|
8
8
|
const returnBlockReturnStatementNodeQuery = nodeQuery("/returnBlock/returnStatement");
|
|
9
9
|
|
|
10
10
|
export default domAssigned(class ReturnStatement {
|
|
11
|
-
constructor(string,
|
|
11
|
+
constructor(string, expression) {
|
|
12
12
|
this.string = string;
|
|
13
|
-
this.
|
|
13
|
+
this.expression = expression;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
getString() {
|
|
17
17
|
return this.string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
return this.
|
|
20
|
+
getExpression() {
|
|
21
|
+
return this.expression;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
evaluate(context) {
|
|
25
|
-
let
|
|
25
|
+
let expression;
|
|
26
26
|
|
|
27
27
|
const returnStatementString = this.string; ///
|
|
28
28
|
|
|
29
29
|
context.trace(`Evaluating the '${returnStatementString}' return statement...`);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
expression = this.expression.evaluate(context);
|
|
32
32
|
|
|
33
33
|
context.debug(`...evaluated the '${returnStatementString}' return statement.`);
|
|
34
34
|
|
|
35
|
-
return
|
|
35
|
+
return expression;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
static name = "ReturnStatement";
|
|
@@ -47,17 +47,17 @@ export default domAssigned(class ReturnStatement {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
function returnStatementFromReturnStatementNode(returnStatementNode, context) {
|
|
50
|
-
const {
|
|
51
|
-
|
|
52
|
-
string =
|
|
53
|
-
returnStatement = new ReturnStatement(string,
|
|
50
|
+
const { Expression, ReturnStatement } = dom,
|
|
51
|
+
expression = Expression.fromReturnStatementNode(returnStatementNode, context),
|
|
52
|
+
string = stringFromExpression(expression, context),
|
|
53
|
+
returnStatement = new ReturnStatement(string, expression);
|
|
54
54
|
|
|
55
55
|
return returnStatement;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function
|
|
59
|
-
const
|
|
60
|
-
string = `Return ${
|
|
58
|
+
function stringFromExpression(expression, context) {
|
|
59
|
+
const expressionString = expression.asString(context),
|
|
60
|
+
string = `Return ${expressionString};`;
|
|
61
61
|
|
|
62
62
|
return string;
|
|
63
63
|
}
|
package/src/dom/ternary.js
CHANGED
|
@@ -7,73 +7,73 @@ import { nodeQuery } from "../utilities/query";
|
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
import { BOOLEAN_TYPE } from "../types";
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const ifExpressionNodeQuery = nodeQuery("/ternary/expression[1]"),
|
|
11
|
+
elseExpressionNodeQuery = nodeQuery("/ternary/expression[2]"),
|
|
12
|
+
expressionTernaryNodeQuery = nodeQuery("/expression/ternary");
|
|
13
13
|
|
|
14
14
|
export default domAssigned(class Ternary {
|
|
15
|
-
constructor(string,
|
|
15
|
+
constructor(string, expression, ifExpression, elseExpression) {
|
|
16
16
|
this.string = string;
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
17
|
+
this.expression = expression;
|
|
18
|
+
this.ifExpression = ifExpression;
|
|
19
|
+
this.elseExpression = elseExpression;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
getString() {
|
|
23
23
|
return this.string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
return this.
|
|
26
|
+
getExpression() {
|
|
27
|
+
return this.expression;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
getIfBlock() {
|
|
31
|
-
return this.
|
|
31
|
+
return this.ifExpression;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
getElseBlock() {
|
|
35
|
-
return this.
|
|
35
|
+
return this.elseExpression;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
evaluate(context) {
|
|
39
|
-
let
|
|
39
|
+
let expression;
|
|
40
40
|
|
|
41
41
|
const ternaryString = this.string; ///
|
|
42
42
|
|
|
43
43
|
context.trace(`Evaluating the '${ternaryString}' ternary...`);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
expression = this.expression.evaluate(context);
|
|
46
46
|
|
|
47
|
-
const
|
|
47
|
+
const expressionType = expression.getType();
|
|
48
48
|
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
message = `The ${
|
|
49
|
+
if (expressionType !== BOOLEAN_TYPE) {
|
|
50
|
+
const expressionString = expression.asString(context),
|
|
51
|
+
message = `The ${expressionString} expression's type is '${expressionType}' when it should be of type '${BOOLEAN_TYPE}'.`,
|
|
52
52
|
exception = Exception.fromMessage(message);
|
|
53
53
|
|
|
54
54
|
throw exception;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const boolean =
|
|
57
|
+
const boolean = expression.getBoolean();
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
this.
|
|
61
|
-
this.
|
|
59
|
+
expression = boolean ?
|
|
60
|
+
this.ifExpression.evaluate(context) :
|
|
61
|
+
this.elseExpression.evaluate(context);
|
|
62
62
|
|
|
63
63
|
context.debug(`...evaluated the '${ternaryString}' ternary.`);
|
|
64
64
|
|
|
65
|
-
return
|
|
65
|
+
return expression;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
static name = "Ternary";
|
|
69
69
|
|
|
70
|
-
static
|
|
70
|
+
static fromExpressionNode(expressionNode, context) {
|
|
71
71
|
let ternary = null;
|
|
72
72
|
|
|
73
|
-
const
|
|
73
|
+
const expressionTernaryNode = expressionTernaryNodeQuery(expressionNode);
|
|
74
74
|
|
|
75
|
-
if (
|
|
76
|
-
const ternaryNode =
|
|
75
|
+
if (expressionTernaryNode !== null) {
|
|
76
|
+
const ternaryNode = expressionTernaryNode; ///
|
|
77
77
|
|
|
78
78
|
ternary = ternaryFromTernaryNode(ternaryNode, context);
|
|
79
79
|
}
|
|
@@ -83,23 +83,23 @@ export default domAssigned(class Ternary {
|
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
function ternaryFromTernaryNode(ternaryNode, context) {
|
|
86
|
-
const {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
string =
|
|
93
|
-
ternary = new Ternary(string,
|
|
86
|
+
const { Expression, Ternary } = dom,
|
|
87
|
+
ifExpressionNode = ifExpressionNodeQuery(ternaryNode),
|
|
88
|
+
elseExpressionNode = elseExpressionNodeQuery(ternaryNode),
|
|
89
|
+
expression = Expression.fromTernaryNode(ternaryNode, context),
|
|
90
|
+
ifExpression = Expression.fromExpressionNode(ifExpressionNode, context),
|
|
91
|
+
elseExpression = Expression.fromExpressionNode(elseExpressionNode, context),
|
|
92
|
+
string = stringFromExpressionIfExpressionAndElseExpression(expression, ifExpression, elseExpression, context),
|
|
93
|
+
ternary = new Ternary(string, expression, ifExpression, elseExpression);
|
|
94
94
|
|
|
95
95
|
return ternary;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
function
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
string = `If (${
|
|
98
|
+
function stringFromExpressionIfExpressionAndElseExpression(expression, ifExpression, elseExpression, context) {
|
|
99
|
+
const expressionString = expression.asString(context),
|
|
100
|
+
ifExpressionString = ifExpression.asString(context),
|
|
101
|
+
elseExpressionString = elseExpression.asString(context),
|
|
102
|
+
string = `If (${expressionString}) ${ifExpressionString} Else ${elseExpressionString};`;
|
|
103
103
|
|
|
104
104
|
return string;
|
|
105
105
|
}
|
package/src/dom/variable.js
CHANGED
|
@@ -7,10 +7,10 @@ import { nodeQuery } from "../utilities/query";
|
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
|
|
9
9
|
const someVariableNodeQuery = nodeQuery("/some/variable"),
|
|
10
|
-
valueVariableNodeQuery = nodeQuery("/value/variable"),
|
|
11
10
|
everyVariableNodeQuery = nodeQuery("/every/variable"),
|
|
12
11
|
reduceVariableNodeQuery = nodeQuery("/reduce/variable"),
|
|
13
12
|
nodeQueryVariableNodeQuery = nodeQuery("/nodeQuery/variable"),
|
|
13
|
+
expressionVariableNodeQuery = nodeQuery("/expression/variable"),
|
|
14
14
|
nodesQueryVariableNodeQuery = nodeQuery("/nodesQuery/variable"),
|
|
15
15
|
variableNameTerminalNodeQuery = nodeQuery("/variable/@name"),
|
|
16
16
|
arrayAssignmentVariableNodeQuery = nodeQuery("/arrayAssignment/variable"),
|
|
@@ -18,11 +18,11 @@ const someVariableNodeQuery = nodeQuery("/some/variable"),
|
|
|
18
18
|
variableAssignmentVariableNodeQuery = nodeQuery("/variableAssignment/variable");
|
|
19
19
|
|
|
20
20
|
export default domAssigned(class Variable {
|
|
21
|
-
constructor(string, type, name,
|
|
21
|
+
constructor(string, type, name, expression) {
|
|
22
22
|
this.string = string;
|
|
23
23
|
this.type = type;
|
|
24
24
|
this.name = name;
|
|
25
|
-
this.
|
|
25
|
+
this.expression = expression;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
getString() {
|
|
@@ -37,8 +37,8 @@ export default domAssigned(class Variable {
|
|
|
37
37
|
return this.name;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
return this.
|
|
40
|
+
getExpression() {
|
|
41
|
+
return this.expression;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
matchVariableName(variableName) {
|
|
@@ -64,22 +64,22 @@ export default domAssigned(class Variable {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const variable = context.findVariableByVariableName(variableName),
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
expression = variable.getExpression(),
|
|
68
|
+
expressionString = expression.asString(context);
|
|
69
69
|
|
|
70
|
-
context.debug(`...evaluated the '${variableString}' variable to the ${
|
|
70
|
+
context.debug(`...evaluated the '${variableString}' variable to the ${expressionString} expression.`);
|
|
71
71
|
|
|
72
|
-
return
|
|
72
|
+
return expression;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
assign(
|
|
75
|
+
assign(expression, context) {
|
|
76
76
|
const nested = false,
|
|
77
|
-
|
|
77
|
+
expressionString = expression.asString(context), ///
|
|
78
78
|
variableName = this.name, ///
|
|
79
79
|
variableString = this.string, ///
|
|
80
80
|
variablePresent = context.isVariablePresentByVariableName(variableName, nested);
|
|
81
81
|
|
|
82
|
-
context.trace(`Assigning the ${
|
|
82
|
+
context.trace(`Assigning the ${expressionString} expression to the '${variableString}' variable...`);
|
|
83
83
|
|
|
84
84
|
if (variablePresent) {
|
|
85
85
|
const message = `The '${variableString}' variable is already present.`,
|
|
@@ -88,23 +88,23 @@ export default domAssigned(class Variable {
|
|
|
88
88
|
throw exception;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
const
|
|
91
|
+
const expressionType = expression.getType(),
|
|
92
92
|
variableType = this.type;
|
|
93
93
|
|
|
94
|
-
if (
|
|
95
|
-
const message = `The '${variableString} variable's '${variableType}' type does not match the
|
|
94
|
+
if (expressionType !== variableType) {
|
|
95
|
+
const message = `The '${variableString} variable's '${variableType}' type does not match the expression's '${expressionType}' type.'`,
|
|
96
96
|
exception = Exception.fromMessage(message);
|
|
97
97
|
|
|
98
98
|
throw exception;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
this.
|
|
101
|
+
this.expression = expression;
|
|
102
102
|
|
|
103
103
|
const variable = this; ///
|
|
104
104
|
|
|
105
105
|
context.addVariable(variable);
|
|
106
106
|
|
|
107
|
-
context.debug(`...assigned the ${
|
|
107
|
+
context.debug(`...assigned the ${expressionString} expression to the '${variableString}' variable.`);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
static name = "Variable";
|
|
@@ -117,13 +117,13 @@ export default domAssigned(class Variable {
|
|
|
117
117
|
return variable;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
static
|
|
120
|
+
static fromExpressionNode(expressionNode, context) {
|
|
121
121
|
let variable = null;
|
|
122
122
|
|
|
123
|
-
const
|
|
123
|
+
const expressionVariableNode = expressionVariableNodeQuery(expressionNode);
|
|
124
124
|
|
|
125
|
-
if (
|
|
126
|
-
const variableNode =
|
|
125
|
+
if (expressionVariableNode !== null) {
|
|
126
|
+
const variableNode = expressionVariableNode; ///
|
|
127
127
|
|
|
128
128
|
variable = variableFromVariableNode(variableNode, context);
|
|
129
129
|
}
|
|
@@ -142,9 +142,9 @@ export default domAssigned(class Variable {
|
|
|
142
142
|
static fromParameter(parameter, context) {
|
|
143
143
|
const type = parameter.getType(),
|
|
144
144
|
name = parameter.getName(),
|
|
145
|
-
|
|
145
|
+
expression = null,
|
|
146
146
|
string = stringFromName(name, context),
|
|
147
|
-
variable = new Variable(string, type, name,
|
|
147
|
+
variable = new Variable(string, type, name, expression);
|
|
148
148
|
|
|
149
149
|
return variable;
|
|
150
150
|
}
|
|
@@ -179,18 +179,18 @@ export default domAssigned(class Variable {
|
|
|
179
179
|
name = (asName !== null) ?
|
|
180
180
|
asName : ///
|
|
181
181
|
namedParameter.getName(),
|
|
182
|
-
|
|
182
|
+
expression = null,
|
|
183
183
|
string = stringFromName(name, context),
|
|
184
|
-
variable = new Variable(string, type, name,
|
|
184
|
+
variable = new Variable(string, type, name, expression);
|
|
185
185
|
|
|
186
186
|
return variable;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
static
|
|
189
|
+
static fromExpressionAndParameter(expression, parameter, context) {
|
|
190
190
|
const type = parameter.getType(),
|
|
191
191
|
name = parameter.getName(),
|
|
192
192
|
string = stringFromName(name, context),
|
|
193
|
-
variable = new Variable(string, type, name,
|
|
193
|
+
variable = new Variable(string, type, name, expression);
|
|
194
194
|
|
|
195
195
|
return variable;
|
|
196
196
|
}
|
|
@@ -223,9 +223,9 @@ export default domAssigned(class Variable {
|
|
|
223
223
|
function variableFromTypeAndVariableNode(type, variableNode, context) {
|
|
224
224
|
const { Variable } = dom,
|
|
225
225
|
name = nameFromVariableNode(variableNode),
|
|
226
|
-
|
|
226
|
+
expression = null,
|
|
227
227
|
string = stringFromName(name, context),
|
|
228
|
-
variable = new Variable(string, type, name,
|
|
228
|
+
variable = new Variable(string, type, name, expression);
|
|
229
229
|
|
|
230
230
|
return variable;
|
|
231
231
|
}
|
|
@@ -234,9 +234,9 @@ function variableFromVariableNode(variableNode, context) {
|
|
|
234
234
|
const { Variable } = dom,
|
|
235
235
|
type = null,
|
|
236
236
|
name = nameFromVariableNode(variableNode),
|
|
237
|
-
|
|
237
|
+
expression = null,
|
|
238
238
|
string = stringFromName(name, context),
|
|
239
|
-
variable = new Variable(string, type, name,
|
|
239
|
+
variable = new Variable(string, type, name, expression);
|
|
240
240
|
|
|
241
241
|
return variable;
|
|
242
242
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Query } from "occam-query";
|
|
4
|
-
import {
|
|
4
|
+
import { Expressions } from "../../index"; ///
|
|
5
5
|
import { arrayUtilities } from "necessary";
|
|
6
6
|
|
|
7
7
|
const { first } = arrayUtilities;
|
|
@@ -9,12 +9,12 @@ const { first } = arrayUtilities;
|
|
|
9
9
|
const freeTermNodeQuery = Query.fromExpressionString("//term[1]"),
|
|
10
10
|
boundTermNodeQuery = Query.fromExpressionString("//term[0]");
|
|
11
11
|
|
|
12
|
-
export function
|
|
12
|
+
export function expressionsFromFileContext(fileContext, free = true) {
|
|
13
13
|
const context = fileContext, ///
|
|
14
14
|
nodes = nodesFromFileContext(fileContext, free),
|
|
15
|
-
|
|
15
|
+
expressions = Expressions.fromNodes(nodes, context);
|
|
16
16
|
|
|
17
|
-
return
|
|
17
|
+
return expressions;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function nodesFromFileContext(fileContext, free) {
|
package/src/example.js
CHANGED
|
@@ -5,7 +5,7 @@ import "./index";
|
|
|
5
5
|
import { ReleaseContext } from "./example/context/release";
|
|
6
6
|
|
|
7
7
|
import { furtleFileFromNothing } from "./example/utilities/furtle";
|
|
8
|
-
import {
|
|
8
|
+
import { expressionsFromFileContext } from "./example/utilities/expressions";
|
|
9
9
|
import { procedureFromReleaseContext } from "./example/utilities/procedure";
|
|
10
10
|
import { nominalFileContextFromReleaseContext } from "./example/utilities/nominal";
|
|
11
11
|
|
|
@@ -23,12 +23,12 @@ const nominalFileContext = nominalFileContextFromReleaseContext(releaseContext),
|
|
|
23
23
|
releaseContext.addFileContext(fileContext);
|
|
24
24
|
|
|
25
25
|
const free = true,
|
|
26
|
-
|
|
26
|
+
expressions = expressionsFromFileContext(fileContext, free),
|
|
27
27
|
procedure = procedureFromReleaseContext(releaseContext);
|
|
28
28
|
|
|
29
29
|
// try {
|
|
30
|
-
const
|
|
31
|
-
boolean =
|
|
30
|
+
const expression = procedure.call(expressions, fileContext),
|
|
31
|
+
boolean = expression.getBoolean();
|
|
32
32
|
|
|
33
33
|
console.log(boolean);
|
|
34
34
|
// } catch (exception) {
|
package/src/index.js
CHANGED
|
@@ -4,9 +4,7 @@ import Step from "./dom/step";
|
|
|
4
4
|
import Some from "./dom/some";
|
|
5
5
|
import Label from "./dom/label";
|
|
6
6
|
import Error from "./dom/error";
|
|
7
|
-
import Value from "./dom/value";
|
|
8
7
|
import Every from "./dom/every";
|
|
9
|
-
import Values from "./dom/values";
|
|
10
8
|
import Reduce from "./dom/reduce";
|
|
11
9
|
import Ternary from "./dom/ternary";
|
|
12
10
|
import Variable from "./dom/variable";
|
|
@@ -17,21 +15,23 @@ import Parameter from "./dom/parameter";
|
|
|
17
15
|
import Parameters from "./dom/parameters";
|
|
18
16
|
import NodesQuery from "./dom/query/nodes";
|
|
19
17
|
import Comparison from "./dom/comparison";
|
|
18
|
+
import Expression from "./dom/expression";
|
|
19
|
+
import Expressions from "./dom/expressions";
|
|
20
20
|
import ReturnBlock from "./dom/block/return";
|
|
21
|
-
import NegatedValue from "./dom/value/negated";
|
|
22
|
-
import BitwiseValue from "./dom/value/bitwise";
|
|
23
21
|
import ProcedureCall from "./dom/procedureCall";
|
|
24
22
|
import NamedParameter from "./dom/parameter/named";
|
|
25
|
-
import BracketedValue from "./dom/value/bracketed";
|
|
26
23
|
import ArrayAssigment from "./dom/assignment/array";
|
|
27
24
|
import ReturnStatement from "./dom/statement/return";
|
|
28
25
|
import NamedParameters from "./dom/parameters/named";
|
|
29
26
|
import ObjectAssignment from "./dom/assignment/object";
|
|
27
|
+
import NegatedExpression from "./dom/expression/negated";
|
|
28
|
+
import BitwiseExpression from "./dom/expression/bitwise";
|
|
30
29
|
import AnonymousProcedure from "./dom/procedure/anonymous";
|
|
31
30
|
import VariableAssignment from "./dom/assignment/variable";
|
|
31
|
+
import BracketedExpression from "./dom/expression/bracketed";
|
|
32
32
|
import VariableAssignments from "./dom/assignments/variable";
|
|
33
33
|
import ProcedureDeclaration from "./dom/declaration/procedure";
|
|
34
34
|
|
|
35
|
-
export { default as
|
|
35
|
+
export { default as Expressions } from "./dom/expressions";
|
|
36
36
|
export { default as FileContext } from "./context/file";
|
|
37
37
|
export { default as stringUtilities } from "./utilities/string";
|