occam-furtle 3.0.521 → 3.0.525
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/apply.js +126 -0
- package/lib/element/assignment/object.js +23 -1
- package/lib/element/error.js +3 -3
- package/lib/element/every.js +13 -13
- package/lib/element/expression.js +18 -2
- package/lib/element/importStatement.js +3 -2
- package/lib/element/procedure.js +2 -1
- package/lib/element/procedureCall.js +8 -1
- package/lib/element/reduce.js +5 -5
- package/lib/element/referenceListLiteral.js +24 -0
- package/lib/element/references.js +32 -0
- package/lib/element/some.js +7 -7
- package/lib/element/terms.js +2 -2
- package/lib/element/values.js +16 -3
- package/lib/example/furtle/bnf.js +3 -5
- package/lib/example/furtle/entries.js +2 -2
- package/lib/node/apply.js +39 -0
- package/lib/node/expression.js +5 -1
- package/lib/node/references.js +23 -0
- package/lib/node/referencesListLiteral.js +27 -0
- package/lib/nominalValueProperties.js +34 -18
- package/lib/nonTerminalNodeMap.js +8 -2
- package/lib/parameterNames.js +5 -1
- package/lib/preamble.js +7 -3
- package/lib/process/instantiate.js +1 -1
- package/lib/ruleNames.js +13 -1
- package/lib/utilities/element.js +110 -7
- package/lib/utilities/string.js +38 -5
- package/package.json +5 -5
- package/src/element/apply.js +119 -0
- package/src/element/assignment/object.js +48 -1
- package/src/element/error.js +3 -3
- package/src/element/every.js +14 -12
- package/src/element/expression.js +19 -1
- package/src/element/importStatement.js +3 -1
- package/src/element/procedure.js +2 -0
- package/src/element/procedureCall.js +14 -0
- package/src/element/reduce.js +4 -4
- package/src/element/referenceListLiteral.js +19 -0
- package/src/element/references.js +31 -0
- package/src/element/some.js +7 -6
- package/src/element/terms.js +1 -1
- package/src/element/values.js +26 -2
- package/src/example/furtle/bnf.js +2 -4
- package/src/example/furtle/entries.js +1 -1
- package/src/node/apply.js +44 -0
- package/src/node/expression.js +9 -1
- package/src/node/references.js +16 -0
- package/src/node/referencesListLiteral.js +23 -0
- package/src/nominalValueProperties.js +43 -25
- package/src/nonTerminalNodeMap.js +11 -2
- package/src/parameterNames.js +1 -0
- package/src/preamble.js +6 -2
- package/src/process/instantiate.js +6 -1
- package/src/ruleNames.js +3 -0
- package/src/utilities/element.js +147 -14
- package/src/utilities/string.js +49 -6
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Element } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
import { define } from "../elements";
|
|
6
|
+
|
|
7
|
+
export default define(class ReferenceListLiteral extends Element {
|
|
8
|
+
constructor(context, string, node, breakPoint, references) {
|
|
9
|
+
super(context, string, node, breakPoint);
|
|
10
|
+
|
|
11
|
+
this.references = references;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getReferences() {
|
|
15
|
+
return this.references;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static name = "ReferenceListLiteral";
|
|
19
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Element } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
import { define } from "../elements";
|
|
6
|
+
|
|
7
|
+
export default define(class References extends Element {
|
|
8
|
+
constructor(context, string, node, breakPoint, array) {
|
|
9
|
+
super(context, string, node, breakPoint);
|
|
10
|
+
|
|
11
|
+
this.array = array;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getArray() {
|
|
15
|
+
return this.array;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getLength() {
|
|
19
|
+
const length = this.array.length;
|
|
20
|
+
|
|
21
|
+
return length;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getReference(index) {
|
|
25
|
+
const reference = this.array[index] || null;
|
|
26
|
+
|
|
27
|
+
return reference;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static name = "References";
|
|
31
|
+
});
|
package/src/element/some.js
CHANGED
|
@@ -10,7 +10,7 @@ import { LIST_TYPE_NAME, BOOLEAN_TYPE_NAME } from "../typeNames";
|
|
|
10
10
|
import { valueFromBoolean, valueFromNominalValue } from "../utilities/value";
|
|
11
11
|
|
|
12
12
|
const { some } = continuationUtilities,
|
|
13
|
-
{
|
|
13
|
+
{ unbreakable } = breakPointUtilities;
|
|
14
14
|
|
|
15
15
|
export default define(class Some extends Element {
|
|
16
16
|
constructor(context, string, node, breakPoint, variable, anonymousProcedure) {
|
|
@@ -28,10 +28,10 @@ export default define(class Some extends Element {
|
|
|
28
28
|
return this.anonymousProcedure;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
evaluate =
|
|
31
|
+
evaluate = unbreakable(function (context, forward, back) {
|
|
32
32
|
const someString = this.getString();
|
|
33
33
|
|
|
34
|
-
context.trace(`Evaluating the '${someString}'
|
|
34
|
+
context.trace(`Evaluating the '${someString}' function...`);
|
|
35
35
|
|
|
36
36
|
return this.variable.evaluate(context, (value, back) => {
|
|
37
37
|
const valueType = value.getType(),
|
|
@@ -50,11 +50,12 @@ export default define(class Some extends Element {
|
|
|
50
50
|
|
|
51
51
|
return some(nominalValues, (nominalValue, forward, back) => {
|
|
52
52
|
return this.evaluateAnonymousProcedure(nominalValue, context, forward, back);
|
|
53
|
-
}, (
|
|
54
|
-
const
|
|
53
|
+
}, context, (context, back) => {
|
|
54
|
+
const boolean = true,
|
|
55
|
+
value = valueFromBoolean(boolean, context),
|
|
55
56
|
valueString = value.getString();
|
|
56
57
|
|
|
57
|
-
context.trace(`...evaluated the '${someString}'
|
|
58
|
+
context.trace(`...evaluated the '${someString}' function as '${valueString}'.`);
|
|
58
59
|
|
|
59
60
|
return forward(value, back);
|
|
60
61
|
}, back);
|
package/src/element/terms.js
CHANGED
|
@@ -44,7 +44,7 @@ export default define(class Terms extends Element {
|
|
|
44
44
|
return this.mapTerm((term, forward, back) => {
|
|
45
45
|
return term.evaluate(context, forward, back);
|
|
46
46
|
}, (valuesArray) => {
|
|
47
|
-
const valuesString = valuesStringFromValuesArray(valuesArray
|
|
47
|
+
const valuesString = valuesStringFromValuesArray(valuesArray),
|
|
48
48
|
string = valuesString, ///
|
|
49
49
|
array = valuesArray, ///
|
|
50
50
|
node = null,
|
package/src/element/values.js
CHANGED
|
@@ -46,7 +46,7 @@ export default define(class Values extends Element {
|
|
|
46
46
|
return this.mapValue((value, forward, back) => {
|
|
47
47
|
return value.evaluate(context, forward, back);
|
|
48
48
|
}, (valuesArray, back) => {
|
|
49
|
-
const valuesString = valuesStringFromValuesArray(valuesArray
|
|
49
|
+
const valuesString = valuesStringFromValuesArray(valuesArray),
|
|
50
50
|
string = valuesString, ///
|
|
51
51
|
array = valuesArray, ///
|
|
52
52
|
node = null,
|
|
@@ -60,13 +60,37 @@ export default define(class Values extends Element {
|
|
|
60
60
|
}, back);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
merge(values, context) {
|
|
64
|
+
let array;
|
|
65
|
+
|
|
66
|
+
array = values.getArray();
|
|
67
|
+
|
|
68
|
+
const valuesArray = [
|
|
69
|
+
...this.array,
|
|
70
|
+
...array,
|
|
71
|
+
],
|
|
72
|
+
valuesString = valuesStringFromValuesArray(valuesArray),
|
|
73
|
+
string = valuesString; ///
|
|
74
|
+
|
|
75
|
+
array = valuesArray; ///
|
|
76
|
+
|
|
77
|
+
const node = null,
|
|
78
|
+
breakPoint = null;
|
|
79
|
+
|
|
80
|
+
context = null;
|
|
81
|
+
|
|
82
|
+
values = new Values(context, string, node, breakPoint, array);
|
|
83
|
+
|
|
84
|
+
return values;
|
|
85
|
+
}
|
|
86
|
+
|
|
63
87
|
static name = "Values";
|
|
64
88
|
|
|
65
89
|
static fromValue(value, context) {
|
|
66
90
|
const valuesArray = [
|
|
67
91
|
value
|
|
68
92
|
],
|
|
69
|
-
valuesString = valuesStringFromValuesArray(valuesArray
|
|
93
|
+
valuesString = valuesStringFromValuesArray(valuesArray),
|
|
70
94
|
string = valuesString, ///
|
|
71
95
|
array = valuesArray, ///
|
|
72
96
|
node = null,
|
|
@@ -28,7 +28,7 @@ const bnf = `
|
|
|
28
28
|
|
|
29
29
|
objectAssignment ::= "{" namedBindings "}" "=" variable ";" ;
|
|
30
30
|
|
|
31
|
-
listAssignment
|
|
31
|
+
listAssignment ::= "[" bindings "]" "=" variable ";" ;
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
@@ -44,9 +44,7 @@ const bnf = `
|
|
|
44
44
|
|
|
45
45
|
some ::= "some"<NO_WHITESPACE>"(" variable "," anonymousProcedure ")" ;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
exists ::= "exists"<NO_WHITESPACE>"(" variable "," referencesListLiteral ( "," values )? ")" ;
|
|
47
|
+
apply ::= "all"<NO_WHITESPACE>"(" variable "," referencesListLiteral ( "," values )? ")" ;
|
|
50
48
|
|
|
51
49
|
|
|
52
50
|
|
|
@@ -14,7 +14,7 @@ const entries = [
|
|
|
14
14
|
"secondary-keyword": "^(?:as|if|else)"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"function-name": "^(?:nodeQuery|nodesQuery|reduce|every|some|lengthOf|toInteger|tryInteger|startsWith|endsWith|contains|
|
|
17
|
+
"function-name": "^(?:nodeQuery|nodesQuery|reduce|every|some|lengthOf|toInteger|tryInteger|startsWith|endsWith|contains|apply)"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"type": "^(?:List|Node|String|Boolean|Integer)"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NonTerminalNode } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
import { VALUES_RULE_NAME, VARIABLE_RULE_NAME, REFERENCE_LIST_LITERAL_RULE_NAME } from "../ruleNames";
|
|
6
|
+
|
|
7
|
+
export default class AllNode extends NonTerminalNode {
|
|
8
|
+
getReferencesNode() {
|
|
9
|
+
const referenceListLiteralNode = this.getReferenceListLiteralNode(),
|
|
10
|
+
referencesNode = referenceListLiteralNode.getReferencesNode();
|
|
11
|
+
|
|
12
|
+
return referencesNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getValueNodes() {
|
|
16
|
+
const valuesNode = this.getValuesNode(),
|
|
17
|
+
valueNodes = valuesNode.getValueNodes();
|
|
18
|
+
|
|
19
|
+
return valueNodes;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getValuesNode() {
|
|
23
|
+
const ruleName = VALUES_RULE_NAME,
|
|
24
|
+
valuesNode = this.getNodeByRuleName(ruleName);
|
|
25
|
+
|
|
26
|
+
return valuesNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getVariableNode() {
|
|
30
|
+
const ruleName = VARIABLE_RULE_NAME,
|
|
31
|
+
variableNode = this.getNodeByRuleName(ruleName);
|
|
32
|
+
|
|
33
|
+
return variableNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getReferenceListLiteralNode() {
|
|
37
|
+
const ruleName = REFERENCE_LIST_LITERAL_RULE_NAME,
|
|
38
|
+
referenceListLiteralNode = this.getNodeByRuleName(ruleName);
|
|
39
|
+
|
|
40
|
+
return referenceListLiteralNode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(AllNode, ruleName, childNodes, opacity, precedence); }
|
|
44
|
+
}
|
package/src/node/expression.js
CHANGED
|
@@ -4,6 +4,7 @@ import { NonTerminalNode } from "occam-languages";
|
|
|
4
4
|
|
|
5
5
|
import { TERM_RULE_NAME,
|
|
6
6
|
SOME_RULE_NAME,
|
|
7
|
+
APPLY_RULE_NAME,
|
|
7
8
|
EVERY_RULE_NAME,
|
|
8
9
|
REDUCE_RULE_NAME,
|
|
9
10
|
TERNARY_RULE_NAME,
|
|
@@ -19,6 +20,13 @@ import { TERM_RULE_NAME,
|
|
|
19
20
|
PROCEDURE_CALL_RULE_NAME } from "../ruleNames";
|
|
20
21
|
|
|
21
22
|
export default class ExpressionNode extends NonTerminalNode {
|
|
23
|
+
getApplyNode() {
|
|
24
|
+
const ruleName = APPLY_RULE_NAME,
|
|
25
|
+
applyNode = this.getNodeByRuleName(ruleName);
|
|
26
|
+
|
|
27
|
+
return applyNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
getTermNode() {
|
|
23
31
|
const ruleName = TERM_RULE_NAME,
|
|
24
32
|
termNode = this.getNodeByRuleName(ruleName);
|
|
@@ -49,7 +57,7 @@ export default class ExpressionNode extends NonTerminalNode {
|
|
|
49
57
|
|
|
50
58
|
getTernaryNode() {
|
|
51
59
|
const ruleName = TERNARY_RULE_NAME,
|
|
52
|
-
|
|
60
|
+
ternaryNode = this.getNodeByRuleName(ruleName);
|
|
53
61
|
|
|
54
62
|
return ternaryNode;
|
|
55
63
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NonTerminalNode } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
import { REFERENCE_RULE_NAME } from "../ruleNames";
|
|
6
|
+
|
|
7
|
+
export default class ReferencesNode extends NonTerminalNode {
|
|
8
|
+
getReferenceNodes() {
|
|
9
|
+
const ruleName = REFERENCE_RULE_NAME,
|
|
10
|
+
referenceNodes = this.getNodesByRuleName(ruleName);
|
|
11
|
+
|
|
12
|
+
return referenceNodes;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(ReferencesNode, ruleName, childNodes, opacity, precedence); }
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NonTerminalNode } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
import { REFERENCES_RULE_NAME } from "../ruleNames";
|
|
6
|
+
|
|
7
|
+
export default class ReferencesListLiteralNode extends NonTerminalNode {
|
|
8
|
+
getReferenceNodes() {
|
|
9
|
+
const referencesNode = this.getReferencesNode(),
|
|
10
|
+
referenceNodes = referencesNode.getReferenceNodes();
|
|
11
|
+
|
|
12
|
+
return referenceNodes;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getReferencesNode() {
|
|
16
|
+
const ruleName = REFERENCES_RULE_NAME,
|
|
17
|
+
referencesNode = this.getNodeByRuleName(ruleName);
|
|
18
|
+
|
|
19
|
+
return referencesNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(ReferencesListLiteralNode, ruleName, childNodes, opacity, precedence); }
|
|
23
|
+
}
|
|
@@ -8,10 +8,34 @@ import NominalValueProperty from "./nominalValueProperty";
|
|
|
8
8
|
|
|
9
9
|
import { nominalValuePropertiesStringFromNominalValuePropertiesArray } from "./utilities/string";
|
|
10
10
|
import { LIST_TYPE_NAME, STRING_TYPE_NAME, BOOLEAN_TYPE_NAME, NOMINAL_VALUE_TYPE_NAME } from "./typeNames";
|
|
11
|
-
import { CONTENT_PARAMETER_NAME, TERMINAL_PARAMETER_NAME, CHILD_NODES_PARAMETER_NAME, NO_WHITESPACE_PARAMETER_NAME } from "./parameterNames";
|
|
11
|
+
import { TYPE_PARAMETER_NAME, CONTENT_PARAMETER_NAME, TERMINAL_PARAMETER_NAME, CHILD_NODES_PARAMETER_NAME, NO_WHITESPACE_PARAMETER_NAME } from "./parameterNames";
|
|
12
12
|
|
|
13
13
|
const { some } = continuationUtilities;
|
|
14
14
|
|
|
15
|
+
const properties = [
|
|
16
|
+
{
|
|
17
|
+
name: TYPE_PARAMETER_NAME,
|
|
18
|
+
typeName: STRING_TYPE_NAME
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: CONTENT_PARAMETER_NAME,
|
|
22
|
+
typeName: STRING_TYPE_NAME
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: TERMINAL_PARAMETER_NAME,
|
|
26
|
+
typeName: BOOLEAN_TYPE_NAME
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: NO_WHITESPACE_PARAMETER_NAME,
|
|
30
|
+
typeName: BOOLEAN_TYPE_NAME
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: CHILD_NODES_PARAMETER_NAME,
|
|
34
|
+
typeName: LIST_TYPE_NAME,
|
|
35
|
+
argumentTypeName: NOMINAL_VALUE_TYPE_NAME
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
|
|
15
39
|
class NominalValueProperties {
|
|
16
40
|
constructor(string, array) {
|
|
17
41
|
this.string = string;
|
|
@@ -71,30 +95,9 @@ const nominalValueProperties = NominalValueProperties.fromNothing();
|
|
|
71
95
|
export default nominalValueProperties;
|
|
72
96
|
|
|
73
97
|
function nominalValuePropertiesArrayFromNothing() {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
NO_WHITESPACE_PARAMETER_NAME,
|
|
78
|
-
CHILD_NODES_PARAMETER_NAME,
|
|
79
|
-
],
|
|
80
|
-
typeNames = [
|
|
81
|
-
STRING_TYPE_NAME,
|
|
82
|
-
BOOLEAN_TYPE_NAME,
|
|
83
|
-
BOOLEAN_TYPE_NAME,
|
|
84
|
-
LIST_TYPE_NAME
|
|
85
|
-
],
|
|
86
|
-
argumentTypeNames = [
|
|
87
|
-
null,
|
|
88
|
-
null,
|
|
89
|
-
null,
|
|
90
|
-
NOMINAL_VALUE_TYPE_NAME
|
|
91
|
-
],
|
|
92
|
-
nominalValuePropertiesArray = names.map((name, index) => {
|
|
93
|
-
const { Type } = elements,
|
|
94
|
-
context = null,
|
|
95
|
-
typeName = typeNames[index],
|
|
96
|
-
argumentTypeName = argumentTypeNames[index],
|
|
97
|
-
type = Type.fromTypeNameAndArgumentTypeName(typeName, argumentTypeName, context),
|
|
98
|
+
const nominalValuePropertiesArray = properties.map((property) => {
|
|
99
|
+
const name = nameFromProperty(property),
|
|
100
|
+
type = typeFromProperty(property),
|
|
98
101
|
nominalValueProperty = NominalValueProperty.fromNameAndType(name, type);
|
|
99
102
|
|
|
100
103
|
return nominalValueProperty;
|
|
@@ -102,3 +105,18 @@ function nominalValuePropertiesArrayFromNothing() {
|
|
|
102
105
|
|
|
103
106
|
return nominalValuePropertiesArray;
|
|
104
107
|
}
|
|
108
|
+
|
|
109
|
+
function nameFromProperty(property) {
|
|
110
|
+
const { name } = property;
|
|
111
|
+
|
|
112
|
+
return name;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function typeFromProperty(property) {
|
|
116
|
+
const { typeName, argumentTypeName = null } = property,
|
|
117
|
+
{ Type } = elements,
|
|
118
|
+
context = null,
|
|
119
|
+
type = Type.fromTypeNameAndArgumentTypeName(typeName, argumentTypeName, context);
|
|
120
|
+
|
|
121
|
+
return type;
|
|
122
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import SomeNode from "./node/some";
|
|
4
4
|
import TermNode from "./node/term";
|
|
5
5
|
import TypeNode from "./node/type";
|
|
6
|
+
import ApplyNode from "./node/apply";
|
|
6
7
|
import TermsNode from "./node/terms";
|
|
7
8
|
import EveryNode from "./node/every";
|
|
8
9
|
import LabelNode from "./node/label";
|
|
@@ -26,6 +27,7 @@ import StatementNode from "./node/statement";
|
|
|
26
27
|
import NodeQueryNode from "./node/nodeQuery";
|
|
27
28
|
import ToIntegerNode from "./node/toInteger";
|
|
28
29
|
import ProcedureNode from "./node/procedure";
|
|
30
|
+
import ReferencesNode from "./node/references";
|
|
29
31
|
import StartsWithNode from "./node/startsWith";
|
|
30
32
|
import TryIntegerNode from "./node/tryInteger";
|
|
31
33
|
import NodesQueryNode from "./node/nodesQuery";
|
|
@@ -48,10 +50,12 @@ import ObjectAssignmentNode from "./node/assignment/object";
|
|
|
48
50
|
import AnonymousProcedureNode from "./node/anoymousProcedure";
|
|
49
51
|
import VariableAssignmentNode from "./node/assignment/variable";
|
|
50
52
|
import VariableAssignmentsNode from "./node/assignments/variable";
|
|
53
|
+
import ReferenceListLiteralNode from "./node/referencesListLiteral";
|
|
51
54
|
|
|
52
55
|
import { SOME_RULE_NAME,
|
|
53
56
|
TERM_RULE_NAME,
|
|
54
57
|
TYPE_RULE_NAME,
|
|
58
|
+
APPLY_RULE_NAME,
|
|
55
59
|
TERMS_RULE_NAME,
|
|
56
60
|
EVERY_RULE_NAME,
|
|
57
61
|
LABEL_RULE_NAME,
|
|
@@ -77,6 +81,7 @@ import { SOME_RULE_NAME,
|
|
|
77
81
|
EXPRESSION_RULE_NAME,
|
|
78
82
|
PARAMETERS_RULE_NAME,
|
|
79
83
|
TO_INTEGER_RULE_NAME,
|
|
84
|
+
REFERENCES_RULE_NAME,
|
|
80
85
|
TRY_INTEGER_RULE_NAME,
|
|
81
86
|
NODES_QUERY_RULE_NAME,
|
|
82
87
|
STARTS_WITH_RULE_NAME,
|
|
@@ -96,12 +101,14 @@ import { SOME_RULE_NAME,
|
|
|
96
101
|
OBJECT_ASSIGNMENT_RULE_NAME,
|
|
97
102
|
VARIABLE_ASSIGNMENT_RULE_NAME,
|
|
98
103
|
ANONYMOUS_PROCEDURE_RULE_NAME,
|
|
99
|
-
VARIABLE_ASSIGNMENTS_RULE_NAME
|
|
104
|
+
VARIABLE_ASSIGNMENTS_RULE_NAME,
|
|
105
|
+
REFERENCE_LIST_LITERAL_RULE_NAME } from "./ruleNames";
|
|
100
106
|
|
|
101
107
|
const NonTerminalNodeMap = {
|
|
102
108
|
[SOME_RULE_NAME]: SomeNode,
|
|
103
109
|
[TERM_RULE_NAME]: TermNode,
|
|
104
110
|
[TYPE_RULE_NAME]: TypeNode,
|
|
111
|
+
[APPLY_RULE_NAME]: ApplyNode,
|
|
105
112
|
[TERMS_RULE_NAME]: TermsNode,
|
|
106
113
|
[EVERY_RULE_NAME]: EveryNode,
|
|
107
114
|
[LABEL_RULE_NAME]: LabelNode,
|
|
@@ -127,6 +134,7 @@ const NonTerminalNodeMap = {
|
|
|
127
134
|
[NODE_QUERY_RULE_NAME]: NodeQueryNode,
|
|
128
135
|
[EXPRESSION_RULE_NAME]: ExpressionNode,
|
|
129
136
|
[PARAMETERS_RULE_NAME]: ParametersNode,
|
|
137
|
+
[REFERENCES_RULE_NAME]: ReferencesNode,
|
|
130
138
|
[STARTS_WITH_RULE_NAME]: StartsWithNode,
|
|
131
139
|
[TRY_INTEGER_RULE_NAME]: TryIntegerNode,
|
|
132
140
|
[NODES_QUERY_RULE_NAME]: NodesQueryNode,
|
|
@@ -146,7 +154,8 @@ const NonTerminalNodeMap = {
|
|
|
146
154
|
[OBJECT_ASSIGNMENT_RULE_NAME]: ObjectAssignmentNode,
|
|
147
155
|
[ANONYMOUS_PROCEDURE_RULE_NAME]: AnonymousProcedureNode,
|
|
148
156
|
[VARIABLE_ASSIGNMENT_RULE_NAME]: VariableAssignmentNode,
|
|
149
|
-
[VARIABLE_ASSIGNMENTS_RULE_NAME]: VariableAssignmentsNode
|
|
157
|
+
[VARIABLE_ASSIGNMENTS_RULE_NAME]: VariableAssignmentsNode,
|
|
158
|
+
[REFERENCE_LIST_LITERAL_RULE_NAME]: ReferenceListLiteralNode
|
|
150
159
|
};
|
|
151
160
|
|
|
152
161
|
export default NonTerminalNodeMap;
|
package/src/parameterNames.js
CHANGED
package/src/preamble.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import All from "./element/all";
|
|
3
4
|
import Some from "./element/some";
|
|
4
5
|
import Term from "./element/term";
|
|
5
6
|
import Type from "./element/type";
|
|
@@ -10,6 +11,7 @@ import Every from "./element/every";
|
|
|
10
11
|
import Value from "./element/value";
|
|
11
12
|
import Values from "./element/values";
|
|
12
13
|
import Reduce from "./element/reduce";
|
|
14
|
+
import Exists from "./element/exists";
|
|
13
15
|
import Ternary from "./element/ternary";
|
|
14
16
|
import Binding from "./element/binding";
|
|
15
17
|
import Bindings from "./element/bindings";
|
|
@@ -29,20 +31,22 @@ import TryInteger from "./element/tryInteger";
|
|
|
29
31
|
import Parameters from "./element/parameters";
|
|
30
32
|
import NodesQuery from "./element/nodesQuery";
|
|
31
33
|
import Expression from "./element/expression";
|
|
34
|
+
import References from "./element/references";
|
|
32
35
|
import ReturnBlock from "./element/returnBlock";
|
|
33
36
|
import NegatedTerm from "./element/term/negated";
|
|
34
37
|
import LogicalTerm from "./element/term/logical";
|
|
35
38
|
import NamedBinding from "./element/binding/named";
|
|
36
39
|
import ProcedureCall from "./element/procedureCall";
|
|
40
|
+
import ImportBinding from "./element/importBinding";
|
|
37
41
|
import NamedBindings from "./element/bindings/named";
|
|
38
42
|
import BracketedTerm from "./element/term/bracketed";
|
|
39
|
-
import
|
|
43
|
+
import ImportBindings from "./element/importBindings";
|
|
40
44
|
import listAssignment from "./element/assignment/list";
|
|
41
45
|
import ComparisonTerm from "./element/term/comparison";
|
|
42
|
-
import ImportBindings from "./element/importBindings";
|
|
43
46
|
import ImportStatement from "./element/importStatement";
|
|
44
47
|
import ReturnStatement from "./element/returnStatement";
|
|
45
48
|
import ObjectAssignment from "./element/assignment/object";
|
|
46
49
|
import AnonymousProcedure from "./element/anonymousProcedure";
|
|
47
50
|
import VariableAssignment from "./element/assignment/variable";
|
|
48
51
|
import VariableAssignments from "./element/assignments/variable";
|
|
52
|
+
import ReferenceListLiteral from "./element/referenceListLiteral";
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import { bnfUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { PERIOD, PERIOD_STRING_LITERAL } from "../constants";
|
|
6
|
-
import { TYPE_RULE_NAME,
|
|
6
|
+
import { TYPE_RULE_NAME,
|
|
7
|
+
LABEL_RULE_NAME,
|
|
8
|
+
REFERENCE_RULE_NAME,
|
|
9
|
+
PARAMETERS_RULE_NAME,
|
|
10
|
+
IMPORT_BINDING_RULE_NAME,
|
|
11
|
+
IMPORT_STATEMENT_RULE_NAME } from "../ruleNames";
|
|
7
12
|
|
|
8
13
|
const { instantiate, ruleFromRuleName } = bnfUtilities;
|
|
9
14
|
|
package/src/ruleNames.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export const SOME_RULE_NAME = "some";
|
|
4
4
|
export const TERM_RULE_NAME = "term";
|
|
5
5
|
export const TYPE_RULE_NAME = "type";
|
|
6
|
+
export const APPLY_RULE_NAME = "apply";
|
|
6
7
|
export const TERMS_RULE_NAME = "terms";
|
|
7
8
|
export const EVERY_RULE_NAME = "every";
|
|
8
9
|
export const LABEL_RULE_NAME = "label";
|
|
@@ -24,6 +25,7 @@ export const PRIMITIVE_RULE_NAME = "primitive";
|
|
|
24
25
|
export const REFERENCE_RULE_NAME = "reference";
|
|
25
26
|
export const PARAMETER_RULE_NAME = "parameter";
|
|
26
27
|
export const ENDS_WITH_RULE_NAME = "endsWith";
|
|
28
|
+
export const REFERENCES_RULE_NAME = "references";
|
|
27
29
|
export const NODE_QUERY_RULE_NAME = "nodeQuery";
|
|
28
30
|
export const EXPRESSION_RULE_NAME = "expression";
|
|
29
31
|
export const PARAMETERS_RULE_NAME = "parameters";
|
|
@@ -48,3 +50,4 @@ export const OBJECT_ASSIGNMENT_RULE_NAME = "objectAssignment";
|
|
|
48
50
|
export const VARIABLE_ASSIGNMENT_RULE_NAME = "variableAssignment";
|
|
49
51
|
export const ANONYMOUS_PROCEDURE_RULE_NAME = "anonymousProcedure";
|
|
50
52
|
export const VARIABLE_ASSIGNMENTS_RULE_NAME = "variableAssignments";
|
|
53
|
+
export const REFERENCE_LIST_LITERAL_RULE_NAME = "referencesListLiteral";
|