occam-furtle 2.0.340 → 3.0.1

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.
Files changed (118) hide show
  1. package/example.js +6319 -2036
  2. package/lib/context/block.js +81 -41
  3. package/lib/context/file/furtle.js +260 -0
  4. package/lib/context/file/nominal.js +956 -0
  5. package/lib/context/file.js +146 -271
  6. package/lib/context/release.js +675 -0
  7. package/lib/context.js +210 -0
  8. package/lib/element/assignment/array.js +117 -15
  9. package/lib/element/assignment/object.js +119 -17
  10. package/lib/element/assignment/variable.js +121 -14
  11. package/lib/element/assignments/variable.js +120 -13
  12. package/lib/element/declaration/procedure.js +120 -12
  13. package/lib/element/error.js +118 -13
  14. package/lib/element/every.js +116 -13
  15. package/lib/element/expression.js +134 -68
  16. package/lib/element/label.js +119 -12
  17. package/lib/element/nodeQuery.js +120 -18
  18. package/lib/element/nodesQuery.js +120 -18
  19. package/lib/element/parameter/named.js +117 -15
  20. package/lib/element/parameter.js +116 -14
  21. package/lib/element/parameters/named.js +116 -14
  22. package/lib/element/parameters.js +115 -13
  23. package/lib/element/primitive.js +115 -63
  24. package/lib/element/procedure/anonymous.js +118 -16
  25. package/lib/element/procedure.js +118 -16
  26. package/lib/element/procedureCall.js +116 -14
  27. package/lib/element/reduce.js +116 -14
  28. package/lib/element/reference.js +119 -12
  29. package/lib/element/returnBlock.js +116 -14
  30. package/lib/element/some.js +117 -15
  31. package/lib/element/statement/return.js +120 -13
  32. package/lib/element/step.js +121 -14
  33. package/lib/element/term/bracketed.js +120 -13
  34. package/lib/element/term/comparison.js +117 -15
  35. package/lib/element/term/logical.js +119 -17
  36. package/lib/element/term/negated.js +119 -15
  37. package/lib/element/term.js +131 -45
  38. package/lib/element/terms.js +125 -14
  39. package/lib/element/ternary.js +118 -16
  40. package/lib/element/variable.js +127 -19
  41. package/lib/element.js +1 -8
  42. package/lib/index.js +9 -1
  43. package/lib/log.js +13 -12
  44. package/lib/metaTypeNames.js +26 -0
  45. package/lib/metaTypes.js +66 -0
  46. package/lib/node/expression.js +8 -15
  47. package/lib/nodeProperties.js +17 -21
  48. package/lib/nodeProperty.js +4 -7
  49. package/lib/utilities/context.js +8 -37
  50. package/lib/utilities/customGrammar.js +49 -0
  51. package/lib/utilities/element.js +110 -60
  52. package/lib/utilities/lineIndex.js +26 -0
  53. package/lib/utilities/primitive.js +14 -5
  54. package/lib/utilities/string.js +41 -37
  55. package/lib/utilities/term.js +14 -5
  56. package/lib/utilities/terms.js +7 -3
  57. package/package.json +2 -2
  58. package/src/context/block.js +20 -32
  59. package/src/context/file/furtle.js +141 -0
  60. package/src/context/file/nominal.js +946 -0
  61. package/src/context/file.js +32 -209
  62. package/src/context/release.js +653 -0
  63. package/src/context.js +74 -0
  64. package/src/element/assignment/array.js +8 -9
  65. package/src/element/assignment/object.js +12 -11
  66. package/src/element/assignment/variable.js +7 -8
  67. package/src/element/assignments/variable.js +7 -8
  68. package/src/element/declaration/procedure.js +6 -6
  69. package/src/element/error.js +4 -6
  70. package/src/element/every.js +5 -6
  71. package/src/element/expression.js +13 -33
  72. package/src/element/label.js +6 -7
  73. package/src/element/nodeQuery.js +12 -14
  74. package/src/element/nodesQuery.js +12 -14
  75. package/src/element/parameter/named.js +7 -8
  76. package/src/element/parameter.js +6 -8
  77. package/src/element/parameters/named.js +8 -9
  78. package/src/element/parameters.js +6 -8
  79. package/src/element/primitive.js +5 -57
  80. package/src/element/procedure/anonymous.js +7 -9
  81. package/src/element/procedure.js +6 -8
  82. package/src/element/procedureCall.js +6 -8
  83. package/src/element/reduce.js +5 -7
  84. package/src/element/reference.js +6 -7
  85. package/src/element/returnBlock.js +5 -7
  86. package/src/element/some.js +9 -9
  87. package/src/element/statement/return.js +7 -8
  88. package/src/element/step.js +6 -7
  89. package/src/element/term/bracketed.js +7 -8
  90. package/src/element/term/comparison.js +6 -8
  91. package/src/element/term/logical.js +12 -12
  92. package/src/element/term/negated.js +11 -9
  93. package/src/element/term.js +16 -17
  94. package/src/element/terms.js +16 -9
  95. package/src/element/ternary.js +8 -9
  96. package/src/element/variable.js +24 -14
  97. package/src/element.js +0 -8
  98. package/src/index.js +2 -0
  99. package/src/log.js +11 -11
  100. package/src/metaTypeNames.js +5 -0
  101. package/src/metaTypes.js +71 -0
  102. package/src/node/expression.js +9 -17
  103. package/src/nodeProperties.js +23 -32
  104. package/src/nodeProperty.js +5 -10
  105. package/src/utilities/context.js +7 -45
  106. package/src/utilities/customGrammar.js +40 -0
  107. package/src/utilities/element.js +181 -94
  108. package/src/utilities/lineIndex.js +21 -0
  109. package/src/utilities/primitive.js +22 -5
  110. package/src/utilities/string.js +42 -36
  111. package/src/utilities/term.js +22 -5
  112. package/src/utilities/terms.js +12 -4
  113. package/test/helpers/furtle.js +1 -1
  114. package/test/helpers/nominal.js +2 -3
  115. package/test/main.js +4 -3
  116. package/test/context/file.js +0 -127
  117. package/test/context/release.js +0 -151
  118. package/test/helpers/constants.js +0 -17
@@ -1,22 +1,20 @@
1
1
  "use strict";
2
2
 
3
+ import Element from "../element";
3
4
  import Exception from "../exception";
4
5
 
5
6
  import { define } from "../elements";
6
7
  import { BOOLEAN_TYPE } from "../types";
7
8
 
8
- export default define(class Ternary {
9
- constructor(string, term, ifExpression, elseExpression) {
10
- this.string = string;
9
+ export default define(class Ternary extends Element {
10
+ constructor(context, string, node, term, ifExpression, elseExpression) {
11
+ super(context, string, node)
12
+
11
13
  this.term = term;
12
14
  this.ifExpression = ifExpression;
13
15
  this.elseExpression = elseExpression;
14
16
  }
15
17
 
16
- getString() {
17
- return this.string;
18
- }
19
-
20
18
  getTerm() {
21
19
  return this.term;
22
20
  }
@@ -32,7 +30,7 @@ export default define(class Ternary {
32
30
  evaluate(context) {
33
31
  let term;
34
32
 
35
- const ternaryString = this.string; ///
33
+ const ternaryString = this.getString(); ///
36
34
 
37
35
  context.trace(`Evaluating the '${ternaryString}' ternary...`);
38
36
 
@@ -48,7 +46,8 @@ export default define(class Ternary {
48
46
  throw exception;
49
47
  }
50
48
 
51
- const boolean = term.getBoolean();
49
+ const primitiveValue = term.getPrimitiveValue(),
50
+ boolean = primitiveValue; ///
52
51
 
53
52
  term = boolean ?
54
53
  this.ifExpression.evaluate(context) :
@@ -1,22 +1,20 @@
1
1
  "use strict";
2
2
 
3
+ import Element from "../element";
3
4
  import Exception from "../exception";
4
5
 
5
6
  import { define } from "../elements";
6
7
  import { variableStringFromName } from "../utilities/string";
7
8
 
8
- export default define(class Variable {
9
- constructor(string, type, name, term) {
10
- this.string = string;
9
+ export default define(class Variable extends Element {
10
+ constructor(context, string, node, type, name, term) {
11
+ super(context, string, node)
12
+
11
13
  this.type = type;
12
14
  this.name = name;
13
15
  this.term = term;
14
16
  }
15
17
 
16
- getString() {
17
- return this.string;
18
- }
19
-
20
18
  getType() {
21
19
  return this.type;
22
20
  }
@@ -36,7 +34,7 @@ export default define(class Variable {
36
34
  }
37
35
 
38
36
  evaluate(context) {
39
- const variableString = this.string; ///
37
+ const variableString = this.getString(); ///
40
38
 
41
39
  context.trace(`Evaluating the '${variableString}' variable...`);
42
40
 
@@ -64,7 +62,7 @@ export default define(class Variable {
64
62
  const nested = false,
65
63
  termString = term.getString(),
66
64
  variableName = this.name, ///
67
- variableString = this.string, ///
65
+ variableString = this.getString(), ///
68
66
  variablePresent = context.isVariablePresentByVariableName(variableName, nested);
69
67
 
70
68
  context.trace(`Assigning the '${termString}' term to the '${variableString}' variable...`);
@@ -100,10 +98,14 @@ export default define(class Variable {
100
98
  static fromParameter(parameter, context) {
101
99
  const type = parameter.getType(),
102
100
  name = parameter.getName(),
103
- primitive = null,
101
+ term = null,
104
102
  variableString = variableStringFromName(name),
105
103
  string = variableString, ///
106
- variable = new Variable(string, type, name, primitive);
104
+ node = null;
105
+
106
+ context = null;
107
+
108
+ const variable = new Variable(context, string, node, type, name, term);
107
109
 
108
110
  return variable;
109
111
  }
@@ -112,10 +114,14 @@ export default define(class Variable {
112
114
  const aliasedName = namedParameter.getAliasedName(),
113
115
  type = namedParameter.getType(),
114
116
  name = aliasedName, ///
115
- primitive = null,
117
+ term = null,
116
118
  variableString = variableStringFromName(name),
117
119
  string = variableString, ///
118
- variable = new Variable(string, type, name, primitive);
120
+ node = null;
121
+
122
+ context = null;
123
+
124
+ const variable = new Variable(context, string, node, type, name, term);
119
125
 
120
126
  return variable;
121
127
  }
@@ -125,7 +131,11 @@ export default define(class Variable {
125
131
  name = parameter.getName(),
126
132
  variableString = variableStringFromName(name),
127
133
  string = variableString, ///
128
- variable = new Variable(string, type, name, term);
134
+ node = null;
135
+
136
+ context = null;
137
+
138
+ const variable = new Variable(context, string, node, type, name, term);
129
139
 
130
140
  return variable;
131
141
  }
package/src/element.js CHANGED
@@ -32,12 +32,4 @@ export default class Element {
32
32
  }
33
33
 
34
34
  matchNode(node) { return this.node.match(node); }
35
-
36
- isEqualTo(element) {
37
- const elementNode = element.getNode(),
38
- matches = this.node.match(elementNode),
39
- equalTo = matches; ///
40
-
41
- return equalTo;
42
- }
43
35
  }
package/src/index.js CHANGED
@@ -7,7 +7,9 @@ export { default as Terms } from "./element/terms";
7
7
  export { default as Log } from "./log";
8
8
  export { default as Element } from "./element";
9
9
  export { default as FileContext } from "./context/file";
10
+ export { default as ReleaseContext } from "./context/release";
10
11
  export { default as NonTerminalNode } from "./nonTerminalNode";
12
+ export { default as FurtleFileContext } from "./context/file/furtle";
11
13
 
12
14
  export { default as nodeUtilities } from "./utilities/node";
13
15
  export { default as queryUtilities } from "./utilities/query";
package/src/log.js CHANGED
@@ -23,37 +23,37 @@ export default class Log {
23
23
  return this.follow;
24
24
  }
25
25
 
26
- trace(message, filePath = null, lineIndex = null) {
26
+ trace(message, filePath = null) {
27
27
  const level = TRACE_LEVEL;
28
28
 
29
- this.write(level, message, filePath, lineIndex);
29
+ this.write(level, message, filePath);
30
30
  }
31
31
 
32
- debug(message, filePath = null, lineIndex = null) {
32
+ debug(message, filePath = null) {
33
33
  const level = DEBUG_LEVEL;
34
34
 
35
- this.write(level, message, filePath, lineIndex);
35
+ this.write(level, message, filePath);
36
36
  }
37
37
 
38
- info(message, filePath = null, lineIndex = null) {
38
+ info(message, filePath = null) {
39
39
  const level = INFO_LEVEL;
40
40
 
41
- this.write(level, message, filePath, lineIndex);
41
+ this.write(level, message, filePath);
42
42
  }
43
43
 
44
- warning(message, filePath = null, lineIndex = null) {
44
+ warning(message, filePath = null) {
45
45
  const level = WARNING_LEVEL;
46
46
 
47
- this.write(level, message, filePath, lineIndex);
47
+ this.write(level, message, filePath);
48
48
  }
49
49
 
50
- error(message, filePath = null, lineIndex = null) {
50
+ error(message, filePath = null) {
51
51
  const level = ERROR_LEVEL;
52
52
 
53
- this.write(level, message, filePath, lineIndex);
53
+ this.write(level, message, filePath);
54
54
  }
55
55
 
56
- write(level, message, filePath, lineIndex) {
56
+ write(level, message, filePath, lineIndex = null) {
57
57
  const levelIndex = LEVELS.indexOf(level),
58
58
  logLevelIndex = LEVELS.indexOf(this.logLevel);
59
59
 
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export const FRAME_META_TYPE_NAME = "Frame";
4
+ export const REFERENCE_META_TYPE_NAME = "Reference";
5
+ export const STATEMENT_META_TYPE_NAME = "Statement";
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ import elements from "./elements";
4
+
5
+ import { FRAME_META_TYPE_NAME, REFERENCE_META_TYPE_NAME, STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
6
+
7
+ let frameMetaType = null,
8
+ referenceMetaType = null,
9
+ statementMetaType = null;
10
+
11
+ export function getMetaTypes() {
12
+ const frameMetaType = frameMetaTypeFromNothing(),
13
+ referenceMetaType = referenceMetaTypeFromNothing(),
14
+ statementMetaType = statementMetaTypeFromNothing(),
15
+ metaTypes = [
16
+ frameMetaType,
17
+ referenceMetaType,
18
+ statementMetaType
19
+ ];
20
+
21
+ return metaTypes;
22
+ }
23
+
24
+ export function findMetaTypeByMetaTypeName(metaTypeName) {
25
+ const metaTypes = getMetaTypes(),
26
+ metaType = metaTypes.find((metaType) => {
27
+ const metaTypeComparesToMetaTypeName = metaType.compareMetaTypeName(metaTypeName);
28
+
29
+ if (metaTypeComparesToMetaTypeName) {
30
+ return true;
31
+ }
32
+ }) || null;
33
+
34
+ return metaType;
35
+ }
36
+
37
+ function frameMetaTypeFromNothing() {
38
+ if (frameMetaType === null) {
39
+ const { MetaType } = elements,
40
+ name = FRAME_META_TYPE_NAME, ///
41
+ context = null;
42
+
43
+ frameMetaType = MetaType.fromName(name, context);
44
+ }
45
+
46
+ return frameMetaType;
47
+ }
48
+
49
+ function statementMetaTypeFromNothing() {
50
+ if (statementMetaType === null) {
51
+ const { MetaType } = elements,
52
+ name = STATEMENT_META_TYPE_NAME, ///
53
+ context = null;
54
+
55
+ statementMetaType = MetaType.fromName(name, context);
56
+ }
57
+
58
+ return statementMetaType;
59
+ }
60
+
61
+ function referenceMetaTypeFromNothing() {
62
+ if (referenceMetaType === null) {
63
+ const { MetaType } = elements,
64
+ name = REFERENCE_META_TYPE_NAME, ///
65
+ context = null;
66
+
67
+ referenceMetaType = MetaType.fromName(name, context);
68
+ }
69
+
70
+ return referenceMetaType;
71
+ }
@@ -2,18 +2,24 @@
2
2
 
3
3
  import NonTerminalNode from "../nonTerminalNode";
4
4
 
5
- import { SOME_RULE_NAME,
5
+ import { TERM_RULE_NAME,
6
+ SOME_RULE_NAME,
6
7
  EVERY_RULE_NAME,
7
8
  REDUCE_RULE_NAME,
8
9
  TERNARY_RULE_NAME,
9
- VARIABLE_RULE_NAME,
10
- PRIMITIVE_RULE_NAME,
11
10
  NODE_QUERY_RULE_NAME,
12
11
  NODES_QUERY_RULE_NAME,
13
12
  RETURN_BLOCK_RULE_NAME,
14
13
  PROCEDURE_CALL_RULE_NAME } from "../ruleNames";
15
14
 
16
15
  export default class ExpressionNode extends NonTerminalNode {
16
+ getTermNode() {
17
+ const ruleName = TERM_RULE_NAME,
18
+ termNode = this.getNodeByRuleName(ruleName);
19
+
20
+ return termNode;
21
+ }
22
+
17
23
  getSomeNode() {
18
24
  const ruleName = SOME_RULE_NAME,
19
25
  someNode = this.getNodeByRuleName(ruleName);
@@ -42,20 +48,6 @@ export default class ExpressionNode extends NonTerminalNode {
42
48
  return ternaryNode;
43
49
  }
44
50
 
45
- getVariableNode() {
46
- const ruleName = VARIABLE_RULE_NAME,
47
- variableNode = this.getNodeByRuleName(ruleName);
48
-
49
- return variableNode;
50
- }
51
-
52
- getPrimitiveNode() {
53
- const ruleName = PRIMITIVE_RULE_NAME,
54
- primitiveNode = this.getNodeByRuleName(ruleName);
55
-
56
- return primitiveNode;
57
- }
58
-
59
51
  getNodeQueryNode() {
60
52
  const ruleName = NODE_QUERY_RULE_NAME,
61
53
  nodeQueryNode = this.getNodeByRuleName(ruleName);
@@ -4,19 +4,9 @@ import Exception from "./exception";
4
4
  import NodeProperty from "./nodeProperty";
5
5
 
6
6
  import { NODES_TYPE, STRING_TYPE, BOOLEAN_TYPE } from "./types";
7
+ import { nodePropertiesStringFromNodePropertiesArray } from "./utilities/string";
7
8
  import { CONTENT_PARAMETER_NAME, TERMINAL_PARAMETER_NAME, CHILD_NODES_PARAMETER_NAME } from "./parameterNames";
8
9
 
9
- const types = [
10
- STRING_TYPE,
11
- BOOLEAN_TYPE,
12
- NODES_TYPE,
13
- ],
14
- names = [
15
- CONTENT_PARAMETER_NAME,
16
- TERMINAL_PARAMETER_NAME,
17
- CHILD_NODES_PARAMETER_NAME
18
- ];
19
-
20
10
  class NodeProperties {
21
11
  constructor(string, array) {
22
12
  this.string = string;
@@ -64,14 +54,9 @@ class NodeProperties {
64
54
  }
65
55
 
66
56
  static fromNothing() {
67
- const context = null,
68
- array = names.map((name, index) => {
69
- const type = types[index],
70
- nodeProperty = NodeProperty.fromNameAndType(name, type, context);
71
-
72
- return nodeProperty;
73
- }),
74
- string = stringFromArray(array, context),
57
+ const nodePropertiesArray = nodePropertiesArrayFromNothing(),
58
+ string = nodePropertiesStringFromNodePropertiesArray(nodePropertiesArray),
59
+ array = nodePropertiesArray, ///
75
60
  nodeProperties = new NodeProperties(string, array);
76
61
 
77
62
  return nodeProperties;
@@ -82,17 +67,23 @@ const nodeProperties = NodeProperties.fromNothing();
82
67
 
83
68
  export default nodeProperties;
84
69
 
85
- function stringFromArray(array, context) {
86
- const nodePropertiesString = array.reduce((nodePropertiesString, nodeProperty) => {
87
- const nodePropertyString = nodeProperty.getString();
88
-
89
- nodePropertiesString = (nodePropertiesString === null) ?
90
- nodePropertyString :
91
- `${nodePropertiesString}, ${nodePropertyString}`;
92
-
93
- return nodePropertiesString;
94
- }, null),
95
- string = nodePropertiesString; ///
96
-
97
- return string;
70
+ function nodePropertiesArrayFromNothing() {
71
+ const types = [
72
+ STRING_TYPE,
73
+ BOOLEAN_TYPE,
74
+ NODES_TYPE,
75
+ ],
76
+ names = [
77
+ CONTENT_PARAMETER_NAME,
78
+ TERMINAL_PARAMETER_NAME,
79
+ CHILD_NODES_PARAMETER_NAME
80
+ ],
81
+ nodePropertiesArray = names.map((name, index) => {
82
+ const type = types[index],
83
+ nodeProperty = NodeProperty.fromNameAndType(name, type);
84
+
85
+ return nodeProperty;
86
+ });
87
+
88
+ return nodePropertiesArray;
98
89
  }
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import { nodePropertyStringFromNameAndType } from "./utilities/string";
4
+
3
5
  export default class NodeProperty {
4
6
  constructor(string, type, name) {
5
7
  this.string = string;
@@ -41,18 +43,11 @@ export default class NodeProperty {
41
43
 
42
44
  static name = "Parameter";
43
45
 
44
- static fromNameAndType(name, type, context) {
45
- const string = stringFromNameAndType(name, type, context),
46
+ static fromNameAndType(name, type) {
47
+ const nodePropertyString = nodePropertyStringFromNameAndType(name, type),
48
+ string = nodePropertyString, ///
46
49
  nodeProperty = new NodeProperty(string, type, name);
47
50
 
48
51
  return nodeProperty;
49
52
  }
50
53
  };
51
-
52
- function stringFromNameAndType(name, type, context) {
53
- const typeString = type, ///
54
- nameString = name, ///
55
- string = `${typeString} ${nameString}`;
56
-
57
- return string;
58
- }
@@ -1,32 +1,17 @@
1
1
  "use strict";
2
2
 
3
- import { LEVELS, FUNCTION, DOUBLE_SPACE } from "../constants";
3
+ import { FUNCTION } from "../constants";
4
4
 
5
5
  export function chainContext(context) {
6
6
  return new Proxy(context, {
7
- get: (instance, name, receiver) => {
8
- const levelsIncludeName = LEVELS.includes(name);
9
-
10
- if (levelsIncludeName) {
11
- return (message, node = null) => {
12
- const level = name, ///
13
- depth = instance.getDepth(),
14
- indent = DOUBLE_SPACE.repeat(depth);
15
-
16
- message = `${indent}${message}`;
17
-
18
- const fileContext = instance.getFileContext();
19
-
20
- fileContext.writeToLog(level, message, node);
21
- }
7
+ get: (context, name, receiver) => {
8
+ if (name in context) {
9
+ return Reflect.get(context, name, receiver);
22
10
  }
23
11
 
24
- if (name in instance) {
25
- return Reflect.get(instance, name, receiver);
26
- }
12
+ context = context.getContext(); ///
27
13
 
28
- const context = instance.getContext(),
29
- value = context[name];
14
+ const value = context[name];
30
15
 
31
16
  return (typeof value === FUNCTION) ?
32
17
  value.bind(context) :
@@ -35,29 +20,6 @@ export function chainContext(context) {
35
20
  });
36
21
  }
37
22
 
38
- export function lineIndexFromNodeAndTokens(node, tokens, lineIndex) {
39
- if (node !== null) {
40
- lineIndex = 0;
41
-
42
- const firstSignificantTokenIndex = node.getFirstSignificantTokenIndex(tokens);
43
-
44
- tokens.some((token, tokenIndex) => {
45
- const tokenEndOfLineToken = token.isEndOfLineToken();
46
-
47
- if (tokenEndOfLineToken) {
48
- lineIndex += 1;
49
- }
50
-
51
- if (tokenIndex === firstSignificantTokenIndex) {
52
- return true;
53
- }
54
- });
55
- }
56
-
57
- return lineIndex;
58
- }
59
-
60
23
  export default {
61
- chainContext,
62
- lineIndexFromNodeAndTokens
24
+ chainContext
63
25
  };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ import { CustomGrammar, CombinedCustomGrammar } from "occam-custom-grammars";
4
+
5
+ export function customGrammarFromNameAndEntries(name, entries) {
6
+ const termBNF = entries.getTermBNF(),
7
+ statementBNF = entries.getStatementBNF(),
8
+ typeVocabulary = entries.getTypeVocabulary(),
9
+ symbolVocabulary = entries.getSymbolVocabulary(),
10
+ customGrammar = CustomGrammar.fromNameTermBNFStatementBNFTypeVocabularyAndSymbolVocabulary(name, termBNF, statementBNF, typeVocabulary, symbolVocabulary);
11
+
12
+ return customGrammar;
13
+ }
14
+
15
+ export function combinedCustomGrammarFromNothing() {
16
+ const customGrammars = [],
17
+ combinedCustomGrammar = CombinedCustomGrammar.fromCustomGrammars(customGrammars);
18
+
19
+ return combinedCustomGrammar;
20
+ }
21
+
22
+ export function combinedCustomGrammarFromReleaseContexts(releaseContexts) {
23
+ const customGrammars = releaseContexts.map((releaseContext) => {
24
+ const customGrammar = releaseContext.getCustomGrammar();
25
+
26
+ return customGrammar;
27
+ });
28
+
29
+ customGrammars.reverse(); ///
30
+
31
+ const combinedCustomGrammar = CombinedCustomGrammar.fromCustomGrammars(customGrammars);
32
+
33
+ return combinedCustomGrammar;
34
+ }
35
+
36
+ export default {
37
+ customGrammarFromNameAndEntries,
38
+ combinedCustomGrammarFromNothing,
39
+ combinedCustomGrammarFromReleaseContexts
40
+ };