occam-furtle 3.0.305 → 3.0.310
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/element/assignment/array.js +20 -20
- package/lib/element/assignment/object.js +17 -14
- package/lib/element/binding/named.js +6 -6
- package/lib/element/binding.js +4 -4
- package/lib/element/every.js +8 -8
- package/lib/element/nodeQuery.js +5 -5
- package/lib/element/nodesQuery.js +5 -5
- package/lib/element/parameter.js +4 -4
- package/lib/element/primitive.js +42 -23
- package/lib/element/procedure/anonymous.js +4 -4
- package/lib/element/procedure.js +8 -10
- package/lib/element/reduce.js +6 -6
- package/lib/element/some.js +8 -8
- package/lib/element/term/comparison.js +4 -4
- package/lib/element/term/logical.js +7 -7
- package/lib/element/term/negated.js +5 -5
- package/lib/element/term.js +3 -3
- package/lib/element/ternary.js +5 -5
- package/lib/element/type.js +94 -0
- package/lib/element/value.js +56 -5
- package/lib/element/variable.js +4 -4
- package/lib/node/assignments/variable.js +4 -10
- package/lib/node/binding/named.js +2 -2
- package/lib/node/binding.js +16 -23
- package/lib/node/declaration/procedure.js +4 -10
- package/lib/node/parameter.js +5 -10
- package/lib/node/primitive.js +9 -9
- package/lib/node/procedure/anoymous.js +4 -10
- package/lib/node/type.js +41 -0
- package/lib/nominalValueProperties.js +86 -0
- package/lib/nominalValueProperty.js +45 -0
- package/lib/nonTerminalNodeMap.js +3 -1
- package/lib/preamble.js +2 -1
- package/lib/ruleNames.js +5 -1
- package/lib/typeNames.js +34 -0
- package/lib/utilities/element.js +50 -18
- package/lib/utilities/primitive.js +13 -9
- package/lib/utilities/string.js +35 -22
- package/lib/utilities/value.js +9 -20
- package/lib/utilities/values.js +3 -3
- package/package.json +2 -2
- package/src/element/assignment/array.js +31 -26
- package/src/element/assignment/object.js +20 -13
- package/src/element/binding/named.js +10 -6
- package/src/element/binding.js +5 -3
- package/src/element/every.js +9 -7
- package/src/element/nodeQuery.js +5 -4
- package/src/element/nodesQuery.js +5 -4
- package/src/element/parameter.js +5 -3
- package/src/element/primitive.js +56 -26
- package/src/element/procedure/anonymous.js +5 -3
- package/src/element/procedure.js +8 -12
- package/src/element/reduce.js +6 -5
- package/src/element/some.js +9 -7
- package/src/element/term/comparison.js +6 -3
- package/src/element/term/logical.js +8 -6
- package/src/element/term/negated.js +5 -4
- package/src/element/term.js +3 -2
- package/src/element/ternary.js +5 -4
- package/src/element/type.js +128 -0
- package/src/element/value.js +27 -3
- package/src/element/variable.js +5 -3
- package/src/node/assignments/variable.js +5 -13
- package/src/node/binding/named.js +1 -1
- package/src/node/binding.js +19 -30
- package/src/node/declaration/procedure.js +5 -13
- package/src/node/parameter.js +6 -14
- package/src/node/primitive.js +8 -8
- package/src/node/procedure/anoymous.js +5 -13
- package/src/node/type.js +43 -0
- package/src/nominalValueProperties.js +103 -0
- package/src/nominalValueProperty.js +55 -0
- package/src/nonTerminalNodeMap.js +3 -0
- package/src/preamble.js +1 -0
- package/src/ruleNames.js +1 -0
- package/src/typeNames.js +7 -0
- package/src/utilities/element.js +67 -19
- package/src/utilities/primitive.js +31 -22
- package/src/utilities/string.js +42 -24
- package/src/utilities/value.js +18 -31
- package/src/utilities/values.js +1 -2
- package/lib/nodeProperties.js +0 -78
- package/lib/nodeProperty.js +0 -45
- package/lib/types.js +0 -34
- package/src/nodeProperties.js +0 -89
- package/src/nodeProperty.js +0 -53
- package/src/types.js +0 -7
package/src/element/value.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
|
+
import elements from "../elements";
|
|
6
|
+
|
|
5
7
|
import { define } from "../elements";
|
|
6
|
-
import { BOOLEAN_TYPE } from "../types";
|
|
7
|
-
import { valueFromBoolean } from "../utilities/value";
|
|
8
8
|
|
|
9
9
|
export default define(class Value extends Element {
|
|
10
10
|
constructor(context, string, node, breakPoint, variable, primitive) {
|
|
@@ -44,7 +44,8 @@ export default define(class Value extends Element {
|
|
|
44
44
|
|
|
45
45
|
isBoolean() {
|
|
46
46
|
const type = this.getType(),
|
|
47
|
-
|
|
47
|
+
booleanType = type.isBooleanType(),
|
|
48
|
+
boolean = booleanType; ///
|
|
48
49
|
|
|
49
50
|
return boolean;
|
|
50
51
|
}
|
|
@@ -85,6 +86,29 @@ export default define(class Value extends Element {
|
|
|
85
86
|
return equalTo;
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
lift(context) {
|
|
90
|
+
const { Primitive } = elements,
|
|
91
|
+
primitiveValue = this.getPrimitiveValue(),
|
|
92
|
+
primitiveValues = primitiveValue; ///
|
|
93
|
+
|
|
94
|
+
let type;
|
|
95
|
+
|
|
96
|
+
type = this.getType();
|
|
97
|
+
|
|
98
|
+
const argumentType = type.getArgumentType();
|
|
99
|
+
|
|
100
|
+
type = argumentType; ///
|
|
101
|
+
|
|
102
|
+
const values = primitiveValues.map((primitiveValue)=> {
|
|
103
|
+
const primitive = Primitive.fromPrimitiveValueAndType(primitiveValue, type, context),
|
|
104
|
+
value = Value.fromPrimitive(primitive, context);
|
|
105
|
+
|
|
106
|
+
return value;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return values;
|
|
110
|
+
}
|
|
111
|
+
|
|
88
112
|
static name = "Value";
|
|
89
113
|
|
|
90
114
|
static fromPrimitive(primitive, context) {
|
package/src/element/variable.js
CHANGED
|
@@ -76,10 +76,12 @@ export default define(class Variable extends Element {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const valueType = value.getType(),
|
|
79
|
-
|
|
79
|
+
typeEqualToValueType = this.type.isEqualTo(valueType);
|
|
80
80
|
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
81
|
+
if (!typeEqualToValueType) {
|
|
82
|
+
const typeString = this.type.getString(),
|
|
83
|
+
valueTypeString = valueType.getString(),
|
|
84
|
+
message = `The '${variableString} variable's '${typeString}' type does not compare to the value's '${valueTypeString}' type.'`,
|
|
83
85
|
exception = Exception.fromMessage(message);
|
|
84
86
|
|
|
85
87
|
throw exception;
|
|
@@ -2,22 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import AssignmentsNode from "../../node/assignment";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { VARIABLE_ASSIGNMENT_RULE_NAME } from "../../ruleNames";
|
|
5
|
+
import { TYPE_RULE_NAME, VARIABLE_ASSIGNMENT_RULE_NAME } from "../../ruleNames";
|
|
7
6
|
|
|
8
7
|
export default class VariableAssignmentsNode extends AssignmentsNode {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
getTypeNode() {
|
|
9
|
+
const ruleName = TYPE_RULE_NAME,
|
|
10
|
+
typeNode = this.getNodeByRuleName(ruleName);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.someTerminalNode((terminalNode) => {
|
|
15
|
-
const content = terminalNode.getContent();
|
|
16
|
-
|
|
17
|
-
type = content; ///
|
|
18
|
-
}, tokenType);
|
|
19
|
-
|
|
20
|
-
return type;
|
|
12
|
+
return typeNode;
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
getVariableAssignmentNodes() {
|
|
@@ -11,7 +11,7 @@ export default class NamedBindingNode extends BindingNode {
|
|
|
11
11
|
const tokenType = NAME_TOKEN_TYPE;
|
|
12
12
|
|
|
13
13
|
this.someTerminalNode((terminalNode, index) => {
|
|
14
|
-
if (index ===
|
|
14
|
+
if (index === 1) {
|
|
15
15
|
const content = terminalNode.getContent();
|
|
16
16
|
|
|
17
17
|
alias = content; //
|
package/src/node/binding.js
CHANGED
|
@@ -1,61 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { types } from "occam-lexers";
|
|
4
3
|
import { NonTerminalNode } from "occam-languages";
|
|
5
4
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const { epsilon } = types;
|
|
5
|
+
import { TYPE_RULE_NAME } from "../ruleNames";
|
|
6
|
+
import { NAME_TOKEN_TYPE } from "../tokenTypes";
|
|
9
7
|
|
|
10
8
|
export default class BindingNode extends NonTerminalNode {
|
|
11
|
-
|
|
12
|
-
let
|
|
9
|
+
isElided() {
|
|
10
|
+
let elided = false;
|
|
13
11
|
|
|
14
|
-
const tokenType =
|
|
12
|
+
const tokenType = null
|
|
15
13
|
|
|
16
14
|
this.someTerminalNode((terminalNode) => {
|
|
17
|
-
const
|
|
15
|
+
const terminalNodeEpsilonNode = terminalNode.isEpsilonNode();
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
if (terminalNodeEpsilonNode) {
|
|
18
|
+
elided = true;
|
|
19
|
+
}
|
|
20
20
|
|
|
21
21
|
return true;
|
|
22
22
|
}, tokenType);
|
|
23
23
|
|
|
24
|
-
return
|
|
24
|
+
return elided;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
let
|
|
27
|
+
getName() {
|
|
28
|
+
let name = null;
|
|
29
29
|
|
|
30
|
-
const tokenType =
|
|
30
|
+
const tokenType = NAME_TOKEN_TYPE;
|
|
31
31
|
|
|
32
32
|
this.someTerminalNode((terminalNode) => {
|
|
33
33
|
const content = terminalNode.getContent();
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
name = content; //
|
|
36
36
|
|
|
37
37
|
return true;
|
|
38
38
|
}, tokenType);
|
|
39
39
|
|
|
40
|
-
return
|
|
40
|
+
return name;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const tokenType = null
|
|
47
|
-
|
|
48
|
-
this.someTerminalNode((terminalNode) => {
|
|
49
|
-
const terminalNodeEpsilonNode = terminalNode.isEpsilonNode();
|
|
43
|
+
getTypeNode() {
|
|
44
|
+
const ruleName = TYPE_RULE_NAME,
|
|
45
|
+
typeNode = this.getNodeByRuleName(ruleName);
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
elided = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return true;
|
|
56
|
-
}, tokenType);
|
|
57
|
-
|
|
58
|
-
return elided;
|
|
47
|
+
return typeNode;
|
|
59
48
|
}
|
|
60
49
|
|
|
61
50
|
static fromRuleNameChildNodesOpacityAndPrecedence(Class, ruleName, childNodes, opacity, precedence) {
|
|
@@ -2,22 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import DeclarationNode from "../../node/declaration";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { LABEL_RULE_NAME, PARAMETERS_RULE_NAME, RETURN_BLOCK_RULE_NAME } from "../../ruleNames";
|
|
5
|
+
import { TYPE_RULE_NAME, LABEL_RULE_NAME, PARAMETERS_RULE_NAME, RETURN_BLOCK_RULE_NAME } from "../../ruleNames";
|
|
7
6
|
|
|
8
7
|
export default class ProcedureDeclarationNode extends DeclarationNode {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const tokenType = TYPE_TOKEN_TYPE;
|
|
13
|
-
|
|
14
|
-
this.someTerminalNode((terminalNode) => {
|
|
15
|
-
const content = terminalNode.getContent();
|
|
16
|
-
|
|
17
|
-
type = content; ///
|
|
18
|
-
}, tokenType);
|
|
8
|
+
getTypeNode() {
|
|
9
|
+
const ruleName = TYPE_RULE_NAME,
|
|
10
|
+
labelNode = this.getNodeByRuleName(ruleName);
|
|
19
11
|
|
|
20
|
-
return
|
|
12
|
+
return labelNode;
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
getLabelNode() {
|
package/src/node/parameter.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { NonTerminalNode } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { TYPE_RULE_NAME } from "../ruleNames";
|
|
6
|
+
import { NAME_TOKEN_TYPE } from "../tokenTypes";
|
|
6
7
|
|
|
7
8
|
export default class ParameterNode extends NonTerminalNode {
|
|
8
9
|
getName() {
|
|
@@ -21,20 +22,11 @@ export default class ParameterNode extends NonTerminalNode {
|
|
|
21
22
|
return name;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
getTypeNode() {
|
|
26
|
+
const ruleName = TYPE_RULE_NAME,
|
|
27
|
+
typeNode = this.getNodeByRuleName(ruleName);
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.someTerminalNode((terminalNode) => {
|
|
30
|
-
const content = terminalNode.getContent();
|
|
31
|
-
|
|
32
|
-
type = content; //
|
|
33
|
-
|
|
34
|
-
return true;
|
|
35
|
-
}, tokenType);
|
|
36
|
-
|
|
37
|
-
return type;
|
|
29
|
+
return typeNode;
|
|
38
30
|
}
|
|
39
31
|
|
|
40
32
|
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(ParameterNode, ruleName, childNodes, opacity, precedence); }
|
package/src/node/primitive.js
CHANGED
|
@@ -5,12 +5,12 @@ import { NonTerminalNode } from "occam-languages";
|
|
|
5
5
|
import NominalValue from "../nominalValue";
|
|
6
6
|
|
|
7
7
|
import { NULL, TRUE, FALSE } from "../constants";
|
|
8
|
-
import {
|
|
8
|
+
import { STRING_TYPE_NAME, NUMBER_TYPE_NAME, BOOLEAN_TYPE_NAME, NOMINAL_VALUE_TYPE_NAME } from "../typeNames";
|
|
9
9
|
import { NULL_TOKEN_TYPE, NUMBER_TOKEN_TYPE, BOOLEAN_TOKEN_TYPE, STRING_LITERAL_TOKEN_TYPE } from "../tokenTypes";
|
|
10
10
|
|
|
11
11
|
export default class PrimitiveNode extends NonTerminalNode {
|
|
12
|
-
|
|
13
|
-
let
|
|
12
|
+
getTypeName() {
|
|
13
|
+
let typeName;
|
|
14
14
|
|
|
15
15
|
const number = this.getNumber(),
|
|
16
16
|
boolean = this.getBoolean(),
|
|
@@ -20,16 +20,16 @@ export default class PrimitiveNode extends NonTerminalNode {
|
|
|
20
20
|
if (false) {
|
|
21
21
|
///
|
|
22
22
|
} else if (number !== null) {
|
|
23
|
-
|
|
23
|
+
typeName = NUMBER_TYPE_NAME;
|
|
24
24
|
} else if (boolean !== null) {
|
|
25
|
-
|
|
25
|
+
typeName = BOOLEAN_TYPE_NAME;
|
|
26
26
|
} else if (nominalvalue !== null) {
|
|
27
|
-
|
|
27
|
+
typeName = NOMINAL_VALUE_TYPE_NAME;
|
|
28
28
|
} else if (stringLiteral !== null) {
|
|
29
|
-
|
|
29
|
+
typeName = STRING_TYPE_NAME;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return typeName;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
getValue() {
|
|
@@ -2,22 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import ProcedureNode from "../../node/procedure";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { PARAMETERS_RULE_NAME, RETURN_BLOCK_RULE_NAME } from "../../ruleNames";
|
|
5
|
+
import { TYPE_RULE_NAME, PARAMETERS_RULE_NAME, RETURN_BLOCK_RULE_NAME } from "../../ruleNames";
|
|
7
6
|
|
|
8
7
|
export default class AnonymousProcedureNode extends ProcedureNode {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
getTypeNode() {
|
|
9
|
+
const ruleName = TYPE_RULE_NAME,
|
|
10
|
+
typeNode = this.getNodeByRuleName(ruleName);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.someTerminalNode((terminalNode) => {
|
|
15
|
-
const content = terminalNode.getContent();
|
|
16
|
-
|
|
17
|
-
type = content; ///
|
|
18
|
-
}, tokenType);
|
|
19
|
-
|
|
20
|
-
return type;
|
|
12
|
+
return typeNode;
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
getParametersNode() {
|
package/src/node/type.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NonTerminalNode } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
import { TYPE_TOKEN_TYPE } from "../tokenTypes";
|
|
6
|
+
|
|
7
|
+
export default class TypeNode extends NonTerminalNode {
|
|
8
|
+
getName() {
|
|
9
|
+
let name = null;
|
|
10
|
+
|
|
11
|
+
const tokenType = TYPE_TOKEN_TYPE;
|
|
12
|
+
|
|
13
|
+
this.someTerminalNode((terminalNode) => {
|
|
14
|
+
const content = terminalNode.getContent();
|
|
15
|
+
|
|
16
|
+
name = content; //
|
|
17
|
+
|
|
18
|
+
return true;
|
|
19
|
+
}, tokenType);
|
|
20
|
+
|
|
21
|
+
return name;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getArgumentTypeName() {
|
|
25
|
+
let argumentTypeName = null;
|
|
26
|
+
|
|
27
|
+
const tokenType = TYPE_TOKEN_TYPE;
|
|
28
|
+
|
|
29
|
+
this.someTerminalNode((terminalNode, index) => {
|
|
30
|
+
if (index === 1) {
|
|
31
|
+
const content = terminalNode.getContent();
|
|
32
|
+
|
|
33
|
+
argumentTypeName = content; //
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}, tokenType);
|
|
38
|
+
|
|
39
|
+
return argumentTypeName;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(TypeNode, ruleName, childNodes, opacity, precedence); }
|
|
43
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import elements from "./elements";
|
|
4
|
+
import Exception from "./exception";
|
|
5
|
+
import NominalValueProperty from "./nominalValueProperty";
|
|
6
|
+
|
|
7
|
+
import { nominalValuePropertiesStringFromNominalValuePropertiesArray } from "./utilities/string";
|
|
8
|
+
import { CONTENT_PARAMETER_NAME, TERMINAL_PARAMETER_NAME, CHILD_NODES_PARAMETER_NAME } from "./parameterNames";
|
|
9
|
+
import { LIST_TYPE_NAME, STRING_TYPE_NAME, BOOLEAN_TYPE_NAME, NOMINAL_VALUE_TYPE_NAME } from "./typeNames";
|
|
10
|
+
|
|
11
|
+
class NominalValueProperties {
|
|
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
|
+
someNominalValueProperty(callback) { return this.array.some(callback); }
|
|
26
|
+
|
|
27
|
+
compareNamedBinding(namedBinding, context) {
|
|
28
|
+
const namedBindingString = namedBinding.getString(),
|
|
29
|
+
nominalValuePropertiesString = this.string; ///
|
|
30
|
+
|
|
31
|
+
context.trace(`Comparing the '${namedBindingString}' named binding with the '${nominalValuePropertiesString}' node properties...`);
|
|
32
|
+
|
|
33
|
+
const namedBindingsCompare = this.someNominalValueProperty((nominalValueProperty) => {
|
|
34
|
+
const namedBindingComparesToNominalValueProperty = nominalValueProperty.compareNamedBinding(namedBinding, context);
|
|
35
|
+
|
|
36
|
+
if (namedBindingComparesToNominalValueProperty) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (!namedBindingsCompare) {
|
|
42
|
+
const message = `The '${namedBindingString}' named binding does not compmare to any of the '${nominalValuePropertiesString}' node properties.`,
|
|
43
|
+
exception = Exception.fromMessage(message);
|
|
44
|
+
|
|
45
|
+
throw exception;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
context.debug(`...compared the '${namedBindingString}' named binding with the '${nominalValuePropertiesString}' node properties.`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
compareNamedBindings(namedBindings, context) {
|
|
52
|
+
namedBindings.forEachNamedBinding((namedBinding) => {
|
|
53
|
+
this.compareNamedBinding(namedBinding, context);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static fromNothing() {
|
|
58
|
+
const nominalValuePropertiesArray = nominalValuePropertiesArrayFromNothing(),
|
|
59
|
+
string = nominalValuePropertiesStringFromNominalValuePropertiesArray(nominalValuePropertiesArray),
|
|
60
|
+
array = nominalValuePropertiesArray, ///
|
|
61
|
+
nominalValueProperties = new NominalValueProperties(string, array);
|
|
62
|
+
|
|
63
|
+
return nominalValueProperties;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const nominalValueProperties = NominalValueProperties.fromNothing();
|
|
68
|
+
|
|
69
|
+
export default nominalValueProperties;
|
|
70
|
+
|
|
71
|
+
function nominalValuePropertiesArrayFromNothing() {
|
|
72
|
+
const names = [
|
|
73
|
+
CONTENT_PARAMETER_NAME,
|
|
74
|
+
TERMINAL_PARAMETER_NAME,
|
|
75
|
+
CHILD_NODES_PARAMETER_NAME
|
|
76
|
+
],
|
|
77
|
+
typeNames = [
|
|
78
|
+
STRING_TYPE_NAME,
|
|
79
|
+
BOOLEAN_TYPE_NAME,
|
|
80
|
+
LIST_TYPE_NAME
|
|
81
|
+
],
|
|
82
|
+
argumentTypeNames = [
|
|
83
|
+
null,
|
|
84
|
+
null,
|
|
85
|
+
NOMINAL_VALUE_TYPE_NAME
|
|
86
|
+
],
|
|
87
|
+
types = typeNames.map((typeName, index) => {
|
|
88
|
+
const { Type } = elements,
|
|
89
|
+
context = null,
|
|
90
|
+
argumentTypeName = argumentTypeNames[index],
|
|
91
|
+
type = Type.fromTypeNameAndArgumentTypeName(typeName, argumentTypeName, context);
|
|
92
|
+
|
|
93
|
+
return type;
|
|
94
|
+
}),
|
|
95
|
+
nominalValuePropertiesArray = names.map((name, index) => {
|
|
96
|
+
const type = types[index],
|
|
97
|
+
nominalValueProperty = NominalValueProperty.fromNameAndType(name, type);
|
|
98
|
+
|
|
99
|
+
return nominalValueProperty;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return nominalValuePropertiesArray;
|
|
103
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nominalValuePropertyStringFromNameAndType } from "./utilities/string";
|
|
4
|
+
|
|
5
|
+
export default class NominalValueProperty {
|
|
6
|
+
constructor(string, type, name) {
|
|
7
|
+
this.string = string;
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.name = name;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getString() {
|
|
13
|
+
return this.string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getType() {
|
|
17
|
+
return this.type;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getName() {
|
|
21
|
+
return this.name;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
compareNamedBinding(namedBinding, context) {
|
|
25
|
+
let namedBindingCompares;
|
|
26
|
+
|
|
27
|
+
const nominalValuePropertyString = this.string, ///
|
|
28
|
+
namedBindingString = namedBinding.getString();
|
|
29
|
+
|
|
30
|
+
context.trace(`Comparing the '${nominalValuePropertyString}' node property with the '${namedBindingString}' named binding...`);
|
|
31
|
+
|
|
32
|
+
const namedBindingName = namedBinding.getName(),
|
|
33
|
+
namedBindingType = namedBinding.getType(),
|
|
34
|
+
nameEqualToNamedBindingName = (this.name === namedBindingName),
|
|
35
|
+
typeEqualToNamedBindingType = this.type.isEqualTo(namedBindingType);
|
|
36
|
+
|
|
37
|
+
namedBindingCompares = (nameEqualToNamedBindingName && typeEqualToNamedBindingType);
|
|
38
|
+
|
|
39
|
+
if (namedBindingCompares) {
|
|
40
|
+
context.debug(`...compared the '${nominalValuePropertyString}' node property with the '${namedBindingString}' named binding.`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return namedBindingCompares;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static name = "Parameter";
|
|
47
|
+
|
|
48
|
+
static fromNameAndType(name, type) {
|
|
49
|
+
const nominalValuePropertyString = nominalValuePropertyStringFromNameAndType(name, type),
|
|
50
|
+
string = nominalValuePropertyString, ///
|
|
51
|
+
nominalValueProperty = new NominalValueProperty(string, type, name);
|
|
52
|
+
|
|
53
|
+
return nominalValueProperty;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import StepNode from "./node/step";
|
|
4
4
|
import SomeNode from "./node/some";
|
|
5
5
|
import TermNode from "./node/term";
|
|
6
|
+
import TypeNode from "./node/type";
|
|
6
7
|
import TermsNode from "./node/terms";
|
|
7
8
|
import EveryNode from "./node/every";
|
|
8
9
|
import LabelNode from "./node/label";
|
|
@@ -42,6 +43,7 @@ import ProcedureDeclarationNode from "./node/declaration/procedure";
|
|
|
42
43
|
import { STEP_RULE_NAME,
|
|
43
44
|
SOME_RULE_NAME,
|
|
44
45
|
TERM_RULE_NAME,
|
|
46
|
+
TYPE_RULE_NAME,
|
|
45
47
|
TERMS_RULE_NAME,
|
|
46
48
|
EVERY_RULE_NAME,
|
|
47
49
|
LABEL_RULE_NAME,
|
|
@@ -82,6 +84,7 @@ const NonTerminalNodeMap = {
|
|
|
82
84
|
[STEP_RULE_NAME]: StepNode,
|
|
83
85
|
[SOME_RULE_NAME]: SomeNode,
|
|
84
86
|
[TERM_RULE_NAME]: TermNode,
|
|
87
|
+
[TYPE_RULE_NAME]: TypeNode,
|
|
85
88
|
[TERMS_RULE_NAME]: TermsNode,
|
|
86
89
|
[EVERY_RULE_NAME]: EveryNode,
|
|
87
90
|
[LABEL_RULE_NAME]: LabelNode,
|
package/src/preamble.js
CHANGED
package/src/ruleNames.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export const STEP_RULE_NAME = "step";
|
|
4
4
|
export const SOME_RULE_NAME = "some";
|
|
5
5
|
export const TERM_RULE_NAME = "term";
|
|
6
|
+
export const TYPE_RULE_NAME = "type";
|
|
6
7
|
export const TERMS_RULE_NAME = "terms";
|
|
7
8
|
export const EVERY_RULE_NAME = "every";
|
|
8
9
|
export const LABEL_RULE_NAME = "label";
|
package/src/typeNames.js
ADDED