occam-furtle 3.0.366 → 3.0.370

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 (67) hide show
  1. package/lib/context/file/furtle.js +1 -1
  2. package/lib/context/literal.js +42 -0
  3. package/lib/element/anonymousProcedure.js +51 -0
  4. package/lib/element/label.js +17 -1
  5. package/lib/element/parameters.js +17 -1
  6. package/lib/element/procedure.js +112 -0
  7. package/lib/element/returnBlock.js +7 -7
  8. package/lib/element/returnStatement.js +33 -0
  9. package/lib/element/statement.js +43 -0
  10. package/lib/element/type.js +24 -1
  11. package/lib/example/furtle/bnf.js +11 -5
  12. package/lib/example/furtle/entries.js +2 -2
  13. package/lib/node/anoymousProcedure.js +31 -0
  14. package/lib/node/procedure.js +20 -3
  15. package/lib/node/returnBlock.js +4 -4
  16. package/lib/node/returnStatement.js +23 -0
  17. package/lib/node/statement.js +16 -3
  18. package/lib/nonTerminalNodeMap.js +10 -10
  19. package/lib/preamble.js +4 -5
  20. package/lib/process/instantiate.js +255 -0
  21. package/lib/process/verify.js +6 -6
  22. package/lib/ruleNames.js +7 -7
  23. package/lib/utilities/context.js +15 -1
  24. package/lib/utilities/element.js +82 -100
  25. package/lib/utilities/json.js +52 -1
  26. package/lib/utilities/string.js +1 -8
  27. package/package.json +5 -5
  28. package/src/context/file/furtle.js +0 -1
  29. package/src/context/literal.js +46 -0
  30. package/src/element/{procedure/anonymous.js → anonymousProcedure.js} +3 -3
  31. package/src/element/label.js +26 -1
  32. package/src/element/parameters.js +26 -1
  33. package/src/element/procedure.js +58 -3
  34. package/src/element/returnBlock.js +6 -6
  35. package/src/element/{statement/return.js → returnStatement.js} +1 -1
  36. package/src/element/{step.js → statement.js} +2 -2
  37. package/src/element/type.js +41 -1
  38. package/src/example/furtle/bnf.js +10 -4
  39. package/src/example/furtle/entries.js +2 -2
  40. package/src/node/{procedure/anoymous.js → anoymousProcedure.js} +4 -4
  41. package/src/node/procedure.js +31 -1
  42. package/src/node/returnBlock.js +5 -5
  43. package/src/node/returnStatement.js +16 -0
  44. package/src/node/statement.js +24 -1
  45. package/src/nonTerminalNodeMap.js +11 -11
  46. package/src/preamble.js +3 -4
  47. package/src/process/instantiate.js +194 -0
  48. package/src/process/verify.js +7 -7
  49. package/src/ruleNames.js +2 -2
  50. package/src/utilities/context.js +9 -0
  51. package/src/utilities/element.js +113 -145
  52. package/src/utilities/json.js +57 -0
  53. package/src/utilities/string.js +0 -14
  54. package/lib/element/declaration/procedure.js +0 -36
  55. package/lib/element/procedure/anonymous.js +0 -51
  56. package/lib/element/statement/return.js +0 -33
  57. package/lib/element/step.js +0 -43
  58. package/lib/node/declaration/procedure.js +0 -40
  59. package/lib/node/declaration.js +0 -18
  60. package/lib/node/procedure/anoymous.js +0 -36
  61. package/lib/node/statement/return.js +0 -28
  62. package/lib/node/step.js +0 -31
  63. package/src/element/declaration/procedure.js +0 -38
  64. package/src/node/declaration/procedure.js +0 -37
  65. package/src/node/declaration.js +0 -7
  66. package/src/node/statement/return.js +0 -16
  67. package/src/node/step.js +0 -30
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  const LATIN = "[\\p{Script=Latin}]",
4
- DECIMAL = "[0-9]";
4
+ DECIMAL = "[0-9]";
5
5
 
6
6
  const entries = [
7
7
  {
8
8
  "bracket": "^(?:\\{|\\})"
9
9
  },
10
10
  {
11
- "primary-keyword": "^return"
11
+ "primary-keyword": "^(?:export|import|from|return)"
12
12
  },
13
13
  {
14
14
  "secondary-keyword": "^(?:as|if|else)"
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
 
3
- import ProcedureNode from "../../node/procedure";
3
+ import { NonTerminalNode } from "occam-languages";
4
4
 
5
- import { TYPE_RULE_NAME, PARAMETERS_RULE_NAME, RETURN_BLOCK_RULE_NAME } from "../../ruleNames";
5
+ import { TYPE_RULE_NAME, PARAMETERS_RULE_NAME, RETURN_BLOCK_RULE_NAME } from "../ruleNames";
6
6
 
7
- export default class AnonymousProcedureNode extends ProcedureNode {
7
+ export default class AnonymousProcedureNode extends NonTerminalNode {
8
8
  getTypeNode() {
9
9
  const ruleName = TYPE_RULE_NAME,
10
10
  typeNode = this.getNodeByRuleName(ruleName);
@@ -26,5 +26,5 @@ export default class AnonymousProcedureNode extends ProcedureNode {
26
26
  return returnBlockNode;
27
27
  }
28
28
 
29
- static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return ProcedureNode.fromRuleNameChildNodesOpacityAndPrecedence(AnonymousProcedureNode, ruleName, childNodes, opacity, precedence); }
29
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(AnonymousProcedureNode, ruleName, childNodes, opacity, precedence); }
30
30
  }
@@ -2,6 +2,36 @@
2
2
 
3
3
  import { NonTerminalNode } from "occam-languages";
4
4
 
5
+ import { TYPE_RULE_NAME, LABEL_RULE_NAME, PARAMETERS_RULE_NAME, RETURN_BLOCK_RULE_NAME } from "../ruleNames";
6
+
5
7
  export default class ProcedureNode extends NonTerminalNode {
6
- static fromRuleNameChildNodesOpacityAndPrecedence(Class, ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(Class, ruleName, childNodes, opacity, precedence); }
8
+ getTypeNode() {
9
+ const ruleName = TYPE_RULE_NAME,
10
+ labelNode = this.getNodeByRuleName(ruleName);
11
+
12
+ return labelNode;
13
+ }
14
+
15
+ getLabelNode() {
16
+ const ruleName = LABEL_RULE_NAME,
17
+ labelNode = this.getNodeByRuleName(ruleName);
18
+
19
+ return labelNode;
20
+ }
21
+
22
+ getParametersNode() {
23
+ const ruleName = PARAMETERS_RULE_NAME,
24
+ parametersNode = this.getNodeByRuleName(ruleName);
25
+
26
+ return parametersNode;
27
+ }
28
+
29
+ getReturnBlockNode() {
30
+ const ruleName = RETURN_BLOCK_RULE_NAME,
31
+ returnBlockNode = this.getNodeByRuleName(ruleName);
32
+
33
+ return returnBlockNode;
34
+ }
35
+
36
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(ProcedureNode, ruleName, childNodes, opacity, precedence); }
7
37
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { NonTerminalNode } from "occam-languages";
4
4
 
5
- import { STEP_RULE_NAME, NONSENSE_RULE_NAME, RETURN_STATEMENT_RULE_NAME } from "../ruleNames";
5
+ import { STATEMENT_RULE_NAME, NONSENSE_RULE_NAME, RETURN_STATEMENT_RULE_NAME } from "../ruleNames";
6
6
 
7
7
  export default class ReturnBlockNode extends NonTerminalNode {
8
8
  isNonsensical() {
@@ -13,11 +13,11 @@ export default class ReturnBlockNode extends NonTerminalNode {
13
13
  return nonsensical;
14
14
  }
15
15
 
16
- getStepNodes() {
17
- const ruleName = STEP_RULE_NAME,
18
- stepNodes = this.getNodesByRuleName(ruleName);
16
+ getStatementNodes() {
17
+ const ruleName = STATEMENT_RULE_NAME,
18
+ statementNodes = this.getNodesByRuleName(ruleName);
19
19
 
20
- return stepNodes;
20
+ return statementNodes;
21
21
  }
22
22
 
23
23
  getNonsenseNodes() {
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ import { NonTerminalNode } from "occam-languages";
4
+
5
+ import { VALUE_RULE_NAME } from "../ruleNames";
6
+
7
+ export default class ReturnStatementNode extends NonTerminalNode {
8
+ getValueNode() {
9
+ const ruleName = VALUE_RULE_NAME,
10
+ valueNode = this.getNodeByRuleName(ruleName);
11
+
12
+ return valueNode;
13
+ }
14
+
15
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(ReturnStatementNode, ruleName, childNodes, opacity, precedence); }
16
+ }
@@ -2,6 +2,29 @@
2
2
 
3
3
  import { NonTerminalNode } from "occam-languages";
4
4
 
5
+ import { ARRAY_ASSIGNMENT_RULE_NAME, OBJECT_ASSIGNMENT_RULE_NAME, VARIABLE_ASSIGNMENTS_RULE_NAME } from "../ruleNames"
6
+
5
7
  export default class StatementNode extends NonTerminalNode {
6
- static fromRuleNameChildNodesOpacityAndPrecedence(Class, ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(Class, ruleName, childNodes, opacity, precedence); }
8
+ getArrayAssignmentNode() {
9
+ const ruleName = ARRAY_ASSIGNMENT_RULE_NAME,
10
+ arrayAssignmentNode = this.getNodeByRuleName(ruleName);
11
+
12
+ return arrayAssignmentNode;
13
+ }
14
+
15
+ getObjectAssignmentNode() {
16
+ const ruleName = OBJECT_ASSIGNMENT_RULE_NAME,
17
+ objectAssignmentNode = this.getNodeByRuleName(ruleName);
18
+
19
+ return objectAssignmentNode;
20
+ }
21
+
22
+ getVariableAssignmentsNode() {
23
+ const ruleName = VARIABLE_ASSIGNMENTS_RULE_NAME,
24
+ variableAssignmentsNode = this.getNodeByRuleName(ruleName);
25
+
26
+ return variableAssignmentsNode;
27
+ }
28
+
29
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(StatementNode, ruleName, childNodes, opacity, precedence); }
7
30
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import StepNode from "./node/step";
4
3
  import SomeNode from "./node/some";
5
4
  import TermNode from "./node/term";
6
5
  import TypeNode from "./node/type";
@@ -21,8 +20,10 @@ import LengthOfNode from "./node/lengthOf";
21
20
  import PrimitiveNode from "./node/primitive";
22
21
  import ReferenceNode from "./node/reference";
23
22
  import ParameterNode from "./node/parameter";
23
+ import StatementNode from "./node/statement";
24
24
  import NodeQueryNode from "./node/nodeQuery";
25
25
  import ToIntegerNode from "./node/toInteger";
26
+ import ProcedureNode from "./node/procedure";
26
27
  import TryIntegerNode from "./node/tryInteger";
27
28
  import NodesQueryNode from "./node/nodesQuery";
28
29
  import ExpressionNode from "./node/expression";
@@ -35,16 +36,14 @@ import ProcedureCallNode from "./node/procedureCall";
35
36
  import NamedBindingsNode from "./node/bindings/named";
36
37
  import BracketedTermNode from "./node/term/bracketed";
37
38
  import ComparisonTermNode from "./node/term/comparison";
38
- import ReturnStatementNode from "./node/statement/return";
39
+ import ReturnStatementNode from "./node/returnStatement";
39
40
  import ArrayAssignmentNode from "./node/assignment/array";
40
41
  import ObjectAssignmentNode from "./node/assignment/object";
41
- import AnonymousProcedureNode from "./node/procedure/anoymous";
42
+ import AnonymousProcedureNode from "./node/anoymousProcedure";
42
43
  import VariableAssignmentNode from "./node/assignment/variable";
43
44
  import VariableAssignmentsNode from "./node/assignments/variable";
44
- import ProcedureDeclarationNode from "./node/declaration/procedure";
45
45
 
46
- import { STEP_RULE_NAME,
47
- SOME_RULE_NAME,
46
+ import { SOME_RULE_NAME,
48
47
  TERM_RULE_NAME,
49
48
  TYPE_RULE_NAME,
50
49
  TERMS_RULE_NAME,
@@ -64,6 +63,8 @@ import { STEP_RULE_NAME,
64
63
  PRIMITIVE_RULE_NAME,
65
64
  REFERENCE_RULE_NAME,
66
65
  PARAMETER_RULE_NAME,
66
+ STATEMENT_RULE_NAME,
67
+ PROCEDURE_RULE_NAME,
67
68
  NODE_QUERY_RULE_NAME,
68
69
  EXPRESSION_RULE_NAME,
69
70
  PARAMETERS_RULE_NAME,
@@ -83,11 +84,9 @@ import { STEP_RULE_NAME,
83
84
  OBJECT_ASSIGNMENT_RULE_NAME,
84
85
  VARIABLE_ASSIGNMENT_RULE_NAME,
85
86
  ANONYMOUS_PROCEDURE_RULE_NAME,
86
- VARIABLE_ASSIGNMENTS_RULE_NAME,
87
- PROCEDURE_DECLARATION_RULE_NAME } from "./ruleNames";
87
+ VARIABLE_ASSIGNMENTS_RULE_NAME } from "./ruleNames";
88
88
 
89
89
  const NonTerminalNodeMap = {
90
- [STEP_RULE_NAME]: StepNode,
91
90
  [SOME_RULE_NAME]: SomeNode,
92
91
  [TERM_RULE_NAME]: TermNode,
93
92
  [TYPE_RULE_NAME]: TypeNode,
@@ -107,7 +106,9 @@ const NonTerminalNodeMap = {
107
106
  [LENGTH_OF_RULE_NAME]: LengthOfNode,
108
107
  [PRIMITIVE_RULE_NAME]: PrimitiveNode,
109
108
  [REFERENCE_RULE_NAME]: ReferenceNode,
109
+ [STATEMENT_RULE_NAME]: StatementNode,
110
110
  [PARAMETER_RULE_NAME]: ParameterNode,
111
+ [PROCEDURE_RULE_NAME]: ProcedureNode,
111
112
  [TO_INTEGER_RULE_NAME]: ToIntegerNode,
112
113
  [NODE_QUERY_RULE_NAME]: NodeQueryNode,
113
114
  [EXPRESSION_RULE_NAME]: ExpressionNode,
@@ -127,8 +128,7 @@ const NonTerminalNodeMap = {
127
128
  [OBJECT_ASSIGNMENT_RULE_NAME]: ObjectAssignmentNode,
128
129
  [ANONYMOUS_PROCEDURE_RULE_NAME]: AnonymousProcedureNode,
129
130
  [VARIABLE_ASSIGNMENT_RULE_NAME]: VariableAssignmentNode,
130
- [VARIABLE_ASSIGNMENTS_RULE_NAME]: VariableAssignmentsNode,
131
- [PROCEDURE_DECLARATION_RULE_NAME]: ProcedureDeclarationNode
131
+ [VARIABLE_ASSIGNMENTS_RULE_NAME]: VariableAssignmentsNode
132
132
  };
133
133
 
134
134
  export default NonTerminalNodeMap;
package/src/preamble.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import Step from "./element/step";
4
3
  import Some from "./element/some";
5
4
  import Term from "./element/term";
6
5
  import Type from "./element/type";
@@ -22,6 +21,7 @@ import Procedure from "./element/procedure";
22
21
  import NodeQuery from "./element/nodeQuery";
23
22
  import Parameter from "./element/parameter";
24
23
  import ToInteger from "./element/toInteger";
24
+ import Statement from "./element/statement";
25
25
  import TryInteger from "./element/tryInteger";
26
26
  import Parameters from "./element/parameters";
27
27
  import NodesQuery from "./element/nodesQuery";
@@ -35,9 +35,8 @@ import NamedBindings from "./element/bindings/named";
35
35
  import BracketedTerm from "./element/term/bracketed";
36
36
  import ComparisonTerm from "./element/term/comparison";
37
37
  import ArrayAssigment from "./element/assignment/array";
38
- import ReturnStatement from "./element/statement/return";
38
+ import ReturnStatement from "./element/returnStatement";
39
39
  import ObjectAssignment from "./element/assignment/object";
40
- import AnonymousProcedure from "./element/procedure/anonymous";
40
+ import AnonymousProcedure from "./element/anonymousProcedure";
41
41
  import VariableAssignment from "./element/assignment/variable";
42
42
  import VariableAssignments from "./element/assignments/variable";
43
- import ProcedureDeclaration from "./element/declaration/procedure";
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ import { ruleFromRuleName } from "../utilities/bnf";
4
+ import { TERM_RULE_NAME,
5
+ TYPE_RULE_NAME,
6
+ FRAME_RULE_NAME,
7
+ LABEL_RULE_NAME,
8
+ PREMISE_RULE_NAME,
9
+ VARIABLE_RULE_NAME,
10
+ EQUALITY_RULE_NAME,
11
+ PROPERTY_RULE_NAME,
12
+ JUDGEMENT_RULE_NAME,
13
+ DEDUCTION_RULE_NAME,
14
+ PARAMETER_RULE_NAME,
15
+ STATEMENT_RULE_NAME,
16
+ REFERENCE_RULE_NAME,
17
+ SIGNATURE_RULE_NAME,
18
+ GENERATOR_RULE_NAME,
19
+ COMBINATOR_RULE_NAME,
20
+ CONCLUSION_RULE_NAME,
21
+ HYPOTHESIS_RULE_NAME,
22
+ CONSTRAINT_RULE_NAME,
23
+ TYPE_PREFIX_RULE_NAME,
24
+ SUPPOSITION_RULE_NAME,
25
+ CONSTRUCTOR_RULE_NAME,
26
+ EQUIVALENCE_RULE_NAME,
27
+ METAVARIABLE_RULE_NAME,
28
+ TYPE_ASSERTION_RULE_NAME,
29
+ DEFINED_ASSERTION_RULE_NAME,
30
+ TERM_SUBSTITUTION_RULE_NAME,
31
+ PROPERTY_ASSERTION_RULE_NAME,
32
+ SUBPROOF_ASSERTION_RULE_NAME,
33
+ FRAME_SUBSTITUTION_RULE_NAME,
34
+ PROCEDURE_REFERENCE_RULE_NAME,
35
+ CONTAINED_ASSERTION_RULE_NAME,
36
+ SIGNATURE_ASSERTION_RULE_NAME,
37
+ IMPLICIT_ASSUMPTION_RULE_NAME,
38
+ STATEMENT_SUBSTITUTION_RULE_NAME,
39
+ REFERENCE_SUBSTITUTION_RULE_NAME } from "../ruleNames";
40
+
41
+ const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
42
+ typePlaceholderRule = ruleFromRuleName(TYPE_RULE_NAME),
43
+ framePlaceholderRule = ruleFromRuleName(FRAME_RULE_NAME),
44
+ labelPlaceholderRule = ruleFromRuleName(LABEL_RULE_NAME),
45
+ premisePlaceholderRule = ruleFromRuleName(PREMISE_RULE_NAME),
46
+ variablePlaceholderRule = ruleFromRuleName(VARIABLE_RULE_NAME),
47
+ equalityPlaceholderRule = ruleFromRuleName(EQUALITY_RULE_NAME),
48
+ propertyPlaceholderRule = ruleFromRuleName(PROPERTY_RULE_NAME),
49
+ judgementPlaceholderRule = ruleFromRuleName(JUDGEMENT_RULE_NAME),
50
+ generatorPlaceholderRule = ruleFromRuleName(GENERATOR_RULE_NAME),
51
+ deductionPlaceholderRule = ruleFromRuleName(DEDUCTION_RULE_NAME),
52
+ parameterPlaceholderRule = ruleFromRuleName(PARAMETER_RULE_NAME),
53
+ statementPlaceholderRule = ruleFromRuleName(STATEMENT_RULE_NAME),
54
+ referencePlaceholderRule = ruleFromRuleName(REFERENCE_RULE_NAME),
55
+ signaturePlaceholderRule = ruleFromRuleName(SIGNATURE_RULE_NAME),
56
+ constraintPlaceholderRule = ruleFromRuleName(CONSTRAINT_RULE_NAME),
57
+ combinatorPlaceholderRule = ruleFromRuleName(COMBINATOR_RULE_NAME),
58
+ conclusionPlaceholderRule = ruleFromRuleName(CONCLUSION_RULE_NAME),
59
+ hypothesisPlaceholderRule = ruleFromRuleName(HYPOTHESIS_RULE_NAME),
60
+ typePrefixPlaceholderRule = ruleFromRuleName(TYPE_PREFIX_RULE_NAME),
61
+ suppositionPlaceholderRule = ruleFromRuleName(SUPPOSITION_RULE_NAME),
62
+ constructorPlaceholderRule = ruleFromRuleName(CONSTRUCTOR_RULE_NAME),
63
+ equivalencePlaceholderRule = ruleFromRuleName(EQUIVALENCE_RULE_NAME),
64
+ metavariablePlaceholderRule = ruleFromRuleName(METAVARIABLE_RULE_NAME),
65
+ typeAssertionPlaceholderRule = ruleFromRuleName(TYPE_ASSERTION_RULE_NAME),
66
+ definedAssertionPlaceholderRule = ruleFromRuleName(DEFINED_ASSERTION_RULE_NAME),
67
+ termSubstitutionPlaceholderRule = ruleFromRuleName(TERM_SUBSTITUTION_RULE_NAME),
68
+ subproofAssertionlaceholderRule = ruleFromRuleName(SUBPROOF_ASSERTION_RULE_NAME),
69
+ propertyAssertionPlaceholderRule = ruleFromRuleName(PROPERTY_ASSERTION_RULE_NAME),
70
+ frameSubstitutionPlaceholderRule = ruleFromRuleName(FRAME_SUBSTITUTION_RULE_NAME),
71
+ procedureReferencelaceholderRule = ruleFromRuleName(PROCEDURE_REFERENCE_RULE_NAME),
72
+ containedAssertionPlaceholderRule = ruleFromRuleName(CONTAINED_ASSERTION_RULE_NAME),
73
+ signatureAssertionPlaceholderRule = ruleFromRuleName(SIGNATURE_ASSERTION_RULE_NAME),
74
+ implicitAssumptionPlaceholderRule = ruleFromRuleName(IMPLICIT_ASSUMPTION_RULE_NAME),
75
+ statementSubstitutionPlaceholderRule = ruleFromRuleName(STATEMENT_SUBSTITUTION_RULE_NAME),
76
+ referenceSubstitutionPlaceholderRule = ruleFromRuleName(REFERENCE_SUBSTITUTION_RULE_NAME);
77
+
78
+ export function instantiatePremise(string, context) {
79
+ string = `${string}
80
+ `; ///
81
+
82
+ return instantiate(premisePlaceholderRule, string, context);
83
+ }
84
+
85
+ export function instantiateDeduction(string, context) {
86
+ string = `${string}
87
+ `; ///
88
+
89
+ return instantiate(deductionPlaceholderRule, string, context);
90
+ }
91
+
92
+ export function instantiateConclusion(string, context) {
93
+ string = `${string}
94
+ `; ///
95
+
96
+ return instantiate(conclusionPlaceholderRule, string, context);
97
+ }
98
+
99
+ export function instantiateSupposition(string, context) {
100
+ string = `${string}
101
+ `; ///
102
+
103
+ return instantiate(suppositionPlaceholderRule, string, context);
104
+ }
105
+
106
+ export function instantiateTerm(string, context) { return instantiate(termPlaceholderRule, string, context); }
107
+
108
+ export function instantiateType(string, context) { return instantiate(typePlaceholderRule, string, context); }
109
+
110
+ export function instantiateFrame(string, context) { return instantiate(framePlaceholderRule, string, context); }
111
+
112
+ export function instantiateLabel(string, context) { return instantiate(labelPlaceholderRule, string, context); }
113
+
114
+ export function instantiateVariable(string, context) { return instantiate(variablePlaceholderRule, string, context); }
115
+
116
+ export function instantiateEquality(string, context) { return instantiate(equalityPlaceholderRule, string, context); }
117
+
118
+ export function instantiateProperty(string, context) { return instantiate(propertyPlaceholderRule, string, context); }
119
+
120
+ export function instantiateGenerator(string, context) { return instantiate(generatorPlaceholderRule, string, context); }
121
+
122
+ export function instantiateJudgement(string, context) { return instantiate(judgementPlaceholderRule, string, context); }
123
+
124
+ export function instantiateParameter(string, context) { return instantiate(parameterPlaceholderRule, string, context); }
125
+
126
+ export function instantiateStatement(string, context) { return instantiate(statementPlaceholderRule, string, context); }
127
+
128
+ export function instantiateReference(string, context) { return instantiate(referencePlaceholderRule, string, context); }
129
+
130
+ export function instantiateSignature(string, context) { return instantiate(signaturePlaceholderRule, string, context); }
131
+
132
+ export function instantiateCombinator(string, context) { return instantiate(combinatorPlaceholderRule, string, context); }
133
+
134
+ export function instantiateHypothesis(string, context) { return instantiate(hypothesisPlaceholderRule, string, context); }
135
+
136
+ export function instantiateConstraint(string, context) { return instantiate(constraintPlaceholderRule, string, context); }
137
+
138
+ export function instantiateTypePrefix(string, context) { return instantiate(typePrefixPlaceholderRule, string, context); }
139
+
140
+ export function instantiateConstructor(string, context) { return instantiate(constructorPlaceholderRule, string, context); }
141
+
142
+ export function instantiateEquivalence(string, context) { return instantiate(equivalencePlaceholderRule, string, context); }
143
+
144
+ export function instantiateMetavariable(string, context) { return instantiate(metavariablePlaceholderRule, string, context); }
145
+
146
+ export function instantiateTypeAssertion(string, context) { return instantiate(typeAssertionPlaceholderRule, string, context); }
147
+
148
+ export function instantiateDefinedAssertion(string, context) { return instantiate(definedAssertionPlaceholderRule, string, context); }
149
+
150
+ export function instantiateTermSubstitution(string, context) { return instantiate(termSubstitutionPlaceholderRule, string, context); }
151
+
152
+ export function instantiateSubproofAssertion(string, context) { return instantiate(subproofAssertionlaceholderRule, string, context); }
153
+
154
+ export function instantiatePropertyAssertion(string, context) { return instantiate(propertyAssertionPlaceholderRule, string, context); }
155
+
156
+ export function instantiateFrameSubstitution(string, context) { return instantiate(frameSubstitutionPlaceholderRule, string, context); }
157
+
158
+ export function instantiateProcedureReference(string, context) { return instantiate(procedureReferencelaceholderRule, string, context); }
159
+
160
+ export function instantiateContainedAssertion(string, context) { return instantiate(containedAssertionPlaceholderRule, string, context); }
161
+
162
+ export function instantiateSignatureAssertion(string, context) { return instantiate(signatureAssertionPlaceholderRule, string, context); }
163
+
164
+ export function instantiateImplicitAssumption(string, context) { return instantiate(implicitAssumptionPlaceholderRule, string, context); }
165
+
166
+ export function instantiateStatementSubstitution(string, context) { return instantiate(statementSubstitutionPlaceholderRule, string, context); }
167
+
168
+ export function instantiateReferenceSubstitution(string, context) { return instantiate(referenceSubstitutionPlaceholderRule, string, context); }
169
+
170
+ function instantiate(placeholderRule, string, context) {
171
+ let node;
172
+
173
+ const lexer = context.getLexer(),
174
+ parser = context.getParser(),
175
+ content = `${string}
176
+ `,
177
+ tokens = lexer.tokenise(content);
178
+
179
+ context.setTokens(tokens);
180
+
181
+ const startRule = placeholderRule; ///
182
+
183
+ node = parser.parse(tokens, startRule);
184
+
185
+ const nonTerminalNode = node; ///
186
+
187
+ nonTerminalNode.someChildNode((childNode) => {
188
+ node = childNode; ///
189
+
190
+ return true;
191
+ });
192
+
193
+ return node;
194
+ }
@@ -3,12 +3,12 @@
3
3
  import { SimplePass } from "occam-languages";
4
4
  import { queryUtilities } from "occam-query";
5
5
 
6
- import { errorFromErrorNode, procedureDeclarationFromProcedureDeclarationNode } from "../utilities/element";
6
+ import { errorFromErrorNode, procedureFromProcedureNode } from "../utilities/element";
7
7
 
8
8
  const { nodeQuery } = queryUtilities;
9
9
 
10
10
  const errorNodeQuery = nodeQuery("/error"),
11
- procedureDeclarationNodeQuery = nodeQuery("/procedureDeclaration");
11
+ procedureNodeQuery = nodeQuery("/procedure");
12
12
 
13
13
  class TopLevelPass extends SimplePass {
14
14
  static maps = [
@@ -28,14 +28,14 @@ class TopLevelPass extends SimplePass {
28
28
  }
29
29
  },
30
30
  {
31
- nodeQuery: procedureDeclarationNodeQuery,
32
- run: (procedureDeclarationNode, context) => {
31
+ nodeQuery: procedureNodeQuery,
32
+ run: (procedureNode, context) => {
33
33
  let success = false;
34
34
 
35
- const procedureDeclaration = procedureDeclarationFromProcedureDeclarationNode(procedureDeclarationNode, context),
36
- procedureDeclarationVerifies = procedureDeclaration.verify(context);
35
+ const procedure = procedureFromProcedureNode(procedureNode, context),
36
+ procedureVerifies = procedure.verify(context);
37
37
 
38
- if (procedureDeclarationVerifies) {
38
+ if (procedureVerifies) {
39
39
  success = true;
40
40
  }
41
41
 
package/src/ruleNames.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- export const STEP_RULE_NAME = "step";
4
3
  export const SOME_RULE_NAME = "some";
5
4
  export const TERM_RULE_NAME = "term";
6
5
  export const TYPE_RULE_NAME = "type";
@@ -17,6 +16,8 @@ export const VARIABLE_RULE_NAME = "variable";
17
16
  export const NONSENSE_RULE_NAME = "nonsense";
18
17
  export const DOCUMENT_RULE_NAME = "document";
19
18
  export const BINDINGS_RULE_NAME = "bindings";
19
+ export const STATEMENT_RULE_NAME = "statement";
20
+ export const PROCEDURE_RULE_NAME = "procedure";
20
21
  export const LENGTH_OF_RULE_NAME = "lengthOf";
21
22
  export const PRIMITIVE_RULE_NAME = "primitive";
22
23
  export const REFERENCE_RULE_NAME = "reference";
@@ -41,5 +42,4 @@ export const OBJECT_ASSIGNMENT_RULE_NAME = "objectAssignment";
41
42
  export const VARIABLE_ASSIGNMENT_RULE_NAME = "variableAssignment";
42
43
  export const ANONYMOUS_PROCEDURE_RULE_NAME = "anonymousProcedure";
43
44
  export const VARIABLE_ASSIGNMENTS_RULE_NAME = "variableAssignments";
44
- export const PROCEDURE_DECLARATION_RULE_NAME = "procedureDeclaration";
45
45
 
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import BlockContext from "../context/block";
4
+ import LiteralContext from "../context/literal";
4
5
 
5
6
  import { isContextBlockContext } from "../context/block";
6
7
 
@@ -18,6 +19,14 @@ export function confine(innerFunction, variables, context) {
18
19
  return innerFunction(context);
19
20
  }
20
21
 
22
+ export function instantiate(innerFunction, context) {
23
+ const literalContext = LiteralContext.fromNothing(context);
24
+
25
+ context = literalContext; ///
26
+
27
+ return innerFunction(context);
28
+ }
29
+
21
30
  function freeContext(context) {
22
31
  let contextBlockContext = isContextBlockContext(context);
23
32