occam-verify-cli 0.0.864 → 0.0.866

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 (87) hide show
  1. package/lib/axiomLemmaTheoremConjecture.js +7 -7
  2. package/lib/context/file.js +162 -60
  3. package/lib/context/local.js +4 -4
  4. package/lib/context/release.js +32 -1
  5. package/lib/label.js +6 -6
  6. package/lib/metaConsequent.js +88 -0
  7. package/lib/metaLemma.js +126 -0
  8. package/lib/metaLemmaMetatheorem.js +196 -0
  9. package/lib/metaSupposition.js +140 -0
  10. package/lib/metaType.js +33 -3
  11. package/lib/metaTypeNames.js +13 -4
  12. package/lib/metaTypes.js +9 -4
  13. package/lib/metatheorem.js +126 -0
  14. package/lib/mixins/context.js +30 -22
  15. package/lib/rule.js +7 -7
  16. package/lib/ruleNames.js +5 -1
  17. package/lib/step/metaproof.js +18 -4
  18. package/lib/type.js +9 -1
  19. package/lib/utilities/name.js +52 -0
  20. package/lib/utilities/query.js +1 -38
  21. package/lib/verifier/node/metastatement.js +3 -3
  22. package/lib/verifier/nodes/statementAgainstCombinator.js +4 -4
  23. package/lib/verifier/nodes/termAgainstConstructor.js +3 -3
  24. package/lib/verifier/nodes.js +10 -10
  25. package/lib/verify/declaration/metavariable.js +4 -4
  26. package/lib/verify/declaration/topLevel.js +11 -3
  27. package/lib/verify/givenMetavariable.js +31 -0
  28. package/lib/verify/givenType.js +2 -3
  29. package/lib/verify/label.js +3 -4
  30. package/lib/verify/metaConsequent.js +36 -0
  31. package/lib/verify/metaDerivation.js +111 -0
  32. package/lib/verify/metaLemma.js +51 -0
  33. package/lib/verify/metaSupposition.js +40 -0
  34. package/lib/verify/metaSuppositions.js +28 -0
  35. package/lib/verify/metaproof.js +34 -0
  36. package/lib/verify/metastatement/qualified.js +2 -2
  37. package/lib/verify/metatheorem.js +50 -0
  38. package/lib/verify/metavariable.js +30 -10
  39. package/lib/verify/proof.js +3 -3
  40. package/lib/verify/statement/qualified.js +28 -28
  41. package/lib/verify/termAsConstructor.js +4 -5
  42. package/lib/verify/type.js +18 -20
  43. package/lib/verify/variable.js +13 -16
  44. package/package.json +4 -4
  45. package/src/axiomLemmaTheoremConjecture.js +6 -6
  46. package/src/context/file.js +187 -73
  47. package/src/context/local.js +1 -1
  48. package/src/context/release.js +37 -0
  49. package/src/label.js +4 -6
  50. package/src/metaConsequent.js +58 -0
  51. package/src/metaLemma.js +9 -0
  52. package/src/metaLemmaMetatheorem.js +194 -0
  53. package/src/metaSupposition.js +103 -0
  54. package/src/metaType.js +23 -3
  55. package/src/metaTypeNames.js +1 -0
  56. package/src/metaTypes.js +8 -1
  57. package/src/metatheorem.js +9 -0
  58. package/src/mixins/context.js +20 -14
  59. package/src/rule.js +6 -6
  60. package/src/ruleNames.js +1 -0
  61. package/src/step/metaproof.js +20 -4
  62. package/src/type.js +10 -0
  63. package/src/utilities/name.js +50 -0
  64. package/src/utilities/query.js +0 -47
  65. package/src/verifier/node/metastatement.js +2 -1
  66. package/src/verifier/nodes/statementAgainstCombinator.js +3 -3
  67. package/src/verifier/nodes/termAgainstConstructor.js +3 -4
  68. package/src/verifier/nodes.js +9 -9
  69. package/src/verify/declaration/metavariable.js +4 -3
  70. package/src/verify/declaration/topLevel.js +14 -0
  71. package/src/verify/givenMetavariable.js +31 -0
  72. package/src/verify/givenType.js +1 -4
  73. package/src/verify/label.js +2 -5
  74. package/src/verify/metaConsequent.js +36 -0
  75. package/src/verify/metaDerivation.js +151 -0
  76. package/src/verify/metaLemma.js +67 -0
  77. package/src/verify/metaSupposition.js +44 -0
  78. package/src/verify/metaSuppositions.js +17 -0
  79. package/src/verify/metaproof.js +32 -0
  80. package/src/verify/metastatement/qualified.js +2 -3
  81. package/src/verify/metatheorem.js +62 -0
  82. package/src/verify/metavariable.js +46 -16
  83. package/src/verify/proof.js +2 -2
  84. package/src/verify/statement/qualified.js +27 -23
  85. package/src/verify/termAsConstructor.js +4 -6
  86. package/src/verify/type.js +20 -22
  87. package/src/verify/variable.js +14 -17
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ import Metatheorem from "../metatheorem";
4
+ import verifyLabels from "../verify/labels";
5
+ import verifyMetaproof from "../verify/metaproof";
6
+ import LocalMetaContext from "../context/localMeta";
7
+ import verifyMetaConsequent from "../verify/metaConsequent";
8
+ import verifyMetaSuppositions from "../verify/metaSuppositions";
9
+
10
+ import { first } from "../utilities/array";
11
+ import { nodeQuery, nodesQuery } from "../utilities/query";
12
+
13
+ const labelNodesQuery = nodesQuery("/metatheorem//labels/label"),
14
+ metaproofNodeQuery = nodeQuery("/metatheorem/metaproof!"),
15
+ metaConsequentNodeQuery = nodeQuery("/metatheorem/metaConsequent!"),
16
+ metaSuppositionsNodeQuery = nodesQuery("/metatheorem/metaSupposition");
17
+
18
+ export default function verifyMetatheorem(metatheoremNode, fileContext) {
19
+ let metatheoremVerified = false;
20
+
21
+ const labelNodes = labelNodesQuery(metatheoremNode),
22
+ labelsString = fileContext.nodesAsString(labelNodes),
23
+ localMetaContext = LocalMetaContext.fromFileContext(fileContext);
24
+
25
+ fileContext.trace(`Verifying the '${labelsString}' metatheorem...`, metatheoremNode);
26
+
27
+ const labels = [],
28
+ labelsVerified = verifyLabels(labelNodes, labels, fileContext);
29
+
30
+ if (labelsVerified) {
31
+ const metaSuppositions = [],
32
+ metaSuppositionNodes = metaSuppositionsNodeQuery(metatheoremNode),
33
+ metaSuppositionsVerified = verifyMetaSuppositions(metaSuppositionNodes, metaSuppositions, localMetaContext);
34
+
35
+ if (metaSuppositionsVerified) {
36
+ const metaConsequents = [],
37
+ metaConsequentNode = metaConsequentNodeQuery(metatheoremNode),
38
+ metaConsequentVerified = verifyMetaConsequent(metaConsequentNode, metaConsequents, localMetaContext);
39
+
40
+ if (metaConsequentVerified) {
41
+ const metaproofNode = metaproofNodeQuery(metatheoremNode),
42
+ firstMetaConsequent = first(metaConsequents),
43
+ metaConsequent = firstMetaConsequent, ///
44
+ metaproofVerified = verifyMetaproof(metaproofNode, metaConsequent, localMetaContext);
45
+
46
+ if (metaproofVerified) {
47
+ const metatheorem = Metatheorem.fromLabelsMetaSuppositionsMetaConsequentAndLocalMetaContext(labels, metaSuppositions, metaConsequent, localMetaContext);
48
+
49
+ fileContext.addMetatheorem(metatheorem);
50
+
51
+ metatheoremVerified = true;
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ if (metatheoremVerified) {
58
+ fileContext.debug(`...verified the '${labelsString}' metatheorem.`, metatheoremNode);
59
+ }
60
+
61
+ return metatheoremVerified;
62
+ }
@@ -2,8 +2,12 @@
2
2
 
3
3
  import Metavariable from "../metavariable";
4
4
  import MetavariableAssignment from "../assignment/metavariable";
5
+ import verifyGivenMetavariable from "../verify/givenMetavariable";
5
6
 
6
- import { metaTypeNameFromMetaTypeNode } from "../utilities/query";
7
+ import { nodeQuery } from "../utilities/query";
8
+
9
+ const typeNodeQuery = nodeQuery("/argument/type"),
10
+ argumentNodeQuery = nodeQuery("/metavariable/argument!");
7
11
 
8
12
  export default function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
9
13
  let metavariableVerified = false;
@@ -17,14 +21,18 @@ export default function verifyMetavariable(metavariableNode, metaTypeNode, fileC
17
21
  if (metavariablePresent) {
18
22
  fileContext.debug(`The metavariable '${metavariableString}' is already present.`, metavariableNode);
19
23
  } else {
20
- const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
21
- metaType = fileContext.findMetaTypeByMetaTypeName(metaTypeName),
22
- metavariable = Metavariable.fromMetavariableNodeAndMetaType(metavariableNode, metaType),
23
- metavariableAssignment = MetavariableAssignment.fromMetavariable(metavariable),
24
- metavariableAssigned = metavariableAssignment.assign(fileContext);
25
-
26
- if (metavariableAssigned) {
27
- metavariableVerified = true;
24
+ const argumentNode = argumentNodeQuery(metavariableNode),
25
+ argumentVerified = verifyArgument(metavariableNode, argumentNode, fileContext);
26
+
27
+ if (argumentVerified) {
28
+ const metaType = fileContext.findMetaTypeByMetaTypeNode(metaTypeNode),
29
+ metavariable = Metavariable.fromMetavariableNodeAndMetaType(metavariableNode, metaType),
30
+ metavariableAssignment = MetavariableAssignment.fromMetavariable(metavariable),
31
+ metavariableAssigned = metavariableAssignment.assign(fileContext);
32
+
33
+ if (metavariableAssigned) {
34
+ metavariableVerified = true;
35
+ }
28
36
  }
29
37
  }
30
38
 
@@ -36,19 +44,16 @@ export default function verifyMetavariable(metavariableNode, metaTypeNode, fileC
36
44
  }
37
45
 
38
46
  export function verifyStandaloneMetavariable(metavariableNode, localMetaContext, verifyAhead) {
39
- let standaloneMetavariableVerified = false;
47
+ let standaloneMetavariableVerified;
40
48
 
41
49
  const metavariableString = localMetaContext.nodeAsString(metavariableNode);
42
50
 
43
51
  localMetaContext.trace(`Verifying the '${metavariableString}' standalone metavariable...`, metavariableNode);
44
52
 
45
- const metavariablePresent = localMetaContext.isMetavariablePresentByMetavariableNode(metavariableNode);
46
-
47
- if (metavariablePresent) {
48
- const verifiedAhead = verifyAhead();
53
+ const metavariables = [],
54
+ givenMetavariableVerified = verifyGivenMetavariable(metavariableNode, metavariables, localMetaContext, verifyAhead);
49
55
 
50
- standaloneMetavariableVerified = verifiedAhead; ///
51
- }
56
+ standaloneMetavariableVerified = givenMetavariableVerified; ///
52
57
 
53
58
  if (standaloneMetavariableVerified) {
54
59
  localMetaContext.debug(`...verified the '${metavariableString}' standalone metavariable.`, metavariableNode);
@@ -56,3 +61,28 @@ export function verifyStandaloneMetavariable(metavariableNode, localMetaContext,
56
61
 
57
62
  return standaloneMetavariableVerified;
58
63
  }
64
+
65
+ function verifyArgument(metavariableNode, argumentNode, fileContext) {
66
+ let argumentVerified = false;
67
+
68
+ if (argumentNode === null) {
69
+ argumentVerified = true;
70
+ } else {
71
+ const typeNode = typeNodeQuery(argumentNode);
72
+
73
+ if (typeNode !== null) {
74
+ const type = fileContext.findTypeByTypeNode(typeNode);
75
+
76
+ if (type !== null) {
77
+ argumentVerified = true;
78
+ } else {
79
+ const typeString = fileContext.nodeAsString(typeNode),
80
+ metavariableString = fileContext.nodeAsString(metavariableNode);
81
+
82
+ fileContext.debug(`The '${metavariableString}' metavariable's '${typeString}' type is not present.`, metavariableNode);
83
+ }
84
+ }
85
+ }
86
+
87
+ return argumentVerified;
88
+ }
@@ -22,9 +22,9 @@ export default function verifyProof(proofNode, conclusion, localContext) {
22
22
  const proofStep = lastProofStep, ///
23
23
  statementNode = proofStep.getStatementNode(),
24
24
  conclusionStatementNode = conclusion.getStatementNode(),
25
- statementNodeMatchConclusionStatementNode = statementNode.match(conclusionStatementNode);
25
+ statementNodeMatchesConclusionStatementNode = statementNode.match(conclusionStatementNode);
26
26
 
27
- proofVerified = statementNodeMatchConclusionStatementNode; ///
27
+ proofVerified = statementNodeMatchesConclusionStatementNode; ///
28
28
  }
29
29
  }
30
30
 
@@ -3,7 +3,7 @@
3
3
  import verifyEquality from "../equality";
4
4
  import verifyTypeAssertion from "../typeAssertion";
5
5
 
6
- import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
6
+ import { nodeQuery } from "../../utilities/query";
7
7
 
8
8
  const equalityNodeQuery = nodeQuery("/qualifiedStatement/statement/equality!"),
9
9
  referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!"),
@@ -21,7 +21,6 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
21
21
  localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement...`, qualifiedStatementNode);
22
22
 
23
23
  const referenceNode = referenceNodeQuery(qualifiedStatementNode),
24
- referenceName = referenceNameFromReferenceNode(referenceNode),
25
24
  verifyQualifiedStatementFunctions = [
26
25
  verifyQualifiedStatementAAgainstRule,
27
26
  verifyQualifiedStatementAAgainstAxiom,
@@ -31,7 +30,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
31
30
  ];
32
31
 
33
32
  qualifiedStatementVerified = verifyQualifiedStatementFunctions.some((verifyQualifiedStatementFunction) => { ///
34
- const qualifiedStatementVerified = verifyQualifiedStatementFunction(qualifiedStatementNode, referenceName, localContext);
33
+ const qualifiedStatementVerified = verifyQualifiedStatementFunction(qualifiedStatementNode, referenceNode, localContext);
35
34
 
36
35
  if (qualifiedStatementVerified) {
37
36
  return true;
@@ -67,120 +66,125 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
67
66
  return qualifiedStatementVerified;
68
67
  }
69
68
 
70
- function verifyQualifiedStatementAAgainstRule(qualifiedStatementNode, referenceName, localContext) {
69
+ function verifyQualifiedStatementAAgainstRule(qualifiedStatementNode, referenceNode, localContext) {
71
70
  let qualifiedStatementVerifiedAgainstRule = false;
72
71
 
73
- const rule = localContext.findRuleByReferenceName(referenceName);
72
+ const rule = localContext.findRuleByReferenceNode(referenceNode);
74
73
 
75
74
  if (rule !== null) {
76
75
  const statementNode = statementNodeQuery(qualifiedStatementNode),
76
+ referenceString = localContext.nodeAsString(referenceNode),
77
77
  statementLocalContext = localContext, ///
78
78
  qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
79
79
 
80
- localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' rule...`, statementNode);
80
+ localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceString}' rule...`, statementNode);
81
81
 
82
82
  const ruleMatchesStatement = rule.matchStatement(statementNode, statementLocalContext);
83
83
 
84
84
  qualifiedStatementVerifiedAgainstRule = ruleMatchesStatement; ///
85
85
 
86
86
  if (qualifiedStatementVerifiedAgainstRule) {
87
- localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' rule.`, statementNode);
87
+ localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceString}' rule.`, statementNode);
88
88
  }
89
89
  }
90
90
 
91
91
  return qualifiedStatementVerifiedAgainstRule;
92
92
  }
93
93
 
94
- function verifyQualifiedStatementAAgainstAxiom(qualifiedStatementNode, referenceName, localContext) {
94
+ function verifyQualifiedStatementAAgainstAxiom(qualifiedStatementNode, referenceNode, localContext) {
95
95
  let qualifiedStatementVerifiedAgainstAxiom = false;
96
96
 
97
- const axiom = localContext.findAxiomByReferenceName(referenceName);
97
+ const axiom = localContext.findAxiomByReferenceNode(referenceNode);
98
98
 
99
99
  if (axiom !== null) {
100
100
  const statementNode = statementNodeQuery(qualifiedStatementNode),
101
+ referenceString = localContext.nodeAsString(referenceNode),
101
102
  statementLocalContext = localContext, ///
102
103
  qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
103
104
 
104
- localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' axiom...`, statementNode);
105
+ localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceString}' axiom...`, statementNode);
105
106
 
106
107
  const axiomMatchesStatement = axiom.matchStatement(statementNode, statementLocalContext);
107
108
 
108
109
  qualifiedStatementVerifiedAgainstAxiom = axiomMatchesStatement; ///
109
110
 
110
111
  if (qualifiedStatementVerifiedAgainstAxiom) {
111
- localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' axiom.`, statementNode);
112
+ localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceString}' axiom.`, statementNode);
112
113
  }
113
114
  }
114
115
 
115
116
  return qualifiedStatementVerifiedAgainstAxiom;
116
117
  }
117
118
 
118
- function verifyQualifiedStatementAAgainstLemma(qualifiedStatementNode, referenceName, localContext) {
119
+ function verifyQualifiedStatementAAgainstLemma(qualifiedStatementNode, referenceNode, localContext) {
119
120
  let qualifiedStatementVerifiedAgainstLemma = false;
120
121
 
121
- const lemma = localContext.findLemmaByReferenceName(referenceName);
122
+ const lemma = localContext.findLemmaByReferenceNode(referenceNode);
122
123
 
123
124
  if (lemma !== null) {
124
125
  const statementNode = statementNodeQuery(qualifiedStatementNode),
126
+ referenceString = localContext.nodeAsString(referenceNode),
125
127
  statementLocalContext = localContext, ///
126
128
  qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
127
129
 
128
- localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' lemma...`, statementNode);
130
+ localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceString}' lemma...`, statementNode);
129
131
 
130
132
  const lemmaMatchesStatement = lemma.matchStatement(statementNode, statementLocalContext);
131
133
 
132
134
  qualifiedStatementVerifiedAgainstLemma = lemmaMatchesStatement; ///
133
135
 
134
136
  if (qualifiedStatementVerifiedAgainstLemma) {
135
- localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' lemma.`, statementNode);
137
+ localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceString}' lemma.`, statementNode);
136
138
  }
137
139
  }
138
140
 
139
141
  return qualifiedStatementVerifiedAgainstLemma;
140
142
  }
141
143
 
142
- function verifyQualifiedStatementAAgainstTheorem(qualifiedStatementNode, referenceName, localContext) {
144
+ function verifyQualifiedStatementAAgainstTheorem(qualifiedStatementNode, referenceNode, localContext) {
143
145
  let qualifiedStatementVerifiedAgainstTheorem = false;
144
146
 
145
- const theorem = localContext.findTheoremByReferenceName(referenceName);
147
+ const theorem = localContext.findTheoremByReferenceNode(referenceNode);
146
148
 
147
149
  if (theorem !== null) {
148
150
  const statementNode = statementNodeQuery(qualifiedStatementNode),
151
+ referenceString = localContext.nodeAsString(referenceNode),
149
152
  statementLocalContext = localContext, ///
150
153
  qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
151
154
 
152
- localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' theorem...`, statementNode);
155
+ localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceString}' theorem...`, statementNode);
153
156
 
154
157
  const theoremMatchesStatement = theorem.matchStatement(statementNode, statementLocalContext);
155
158
 
156
159
  qualifiedStatementVerifiedAgainstTheorem = theoremMatchesStatement; ///
157
160
 
158
161
  if (qualifiedStatementVerifiedAgainstTheorem) {
159
- localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' theorem.`, statementNode);
162
+ localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceString}' theorem.`, statementNode);
160
163
  }
161
164
  }
162
165
 
163
166
  return qualifiedStatementVerifiedAgainstTheorem;
164
167
  }
165
168
 
166
- function verifyQualifiedStatementAAgainstConjecture(qualifiedStatementNode, referenceName, localContext) {
169
+ function verifyQualifiedStatementAAgainstConjecture(qualifiedStatementNode, referenceNode, localContext) {
167
170
  let qualifiedStatementVerifiedAgainstConjecture = false;
168
171
 
169
- const conjecture = localContext.findConjectureByReferenceName(referenceName);
172
+ const conjecture = localContext.findConjectureByReferenceNode(referenceNode);
170
173
 
171
174
  if (conjecture !== null) {
172
175
  const statementNode = statementNodeQuery(qualifiedStatementNode),
176
+ referenceString = localContext.nodeAsString(referenceNode),
173
177
  statementLocalContext = localContext, ///
174
178
  qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
175
179
 
176
- localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' conjecture...`, statementNode);
180
+ localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceString}' conjecture...`, statementNode);
177
181
 
178
182
  const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementLocalContext);
179
183
 
180
184
  qualifiedStatementVerifiedAgainstConjecture = conjectureMatchesStatement; ///
181
185
 
182
186
  if (qualifiedStatementVerifiedAgainstConjecture) {
183
- localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' conjecture.`, statementNode);
187
+ localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceString}' conjecture.`, statementNode);
184
188
  }
185
189
  }
186
190
 
@@ -4,8 +4,6 @@ import Constructor from "../constructor";
4
4
  import LocalContext from "../context/local";
5
5
  import termAsConstructorNodeVerifier from "../verifier/node/termAsConstructor";
6
6
 
7
- import { typeNameFromTypeNode } from "../utilities/query";
8
-
9
7
  export default function verifyTermAsConstructor(termNode, typeNode, fileContext) {
10
8
  let termVerifiedAsConstructor = false;
11
9
 
@@ -28,14 +26,14 @@ export default function verifyTermAsConstructor(termNode, typeNode, fileContext)
28
26
  if (typeNode === null) {
29
27
  termVerifiedAsConstructor = true;
30
28
  } else {
31
- const typeName = typeNameFromTypeNode(typeNode);
32
-
33
- type = fileContext.findTypeByTypeName(typeName);
29
+ type = fileContext.findTypeByTypeNode(typeNode);
34
30
 
35
31
  if (type !== null) {
36
32
  termVerifiedAsConstructor = true;
37
33
  } else {
38
- fileContext.debug(`The '${termString}' constructor's '${typeName}' type is not present.`, termNode);
34
+ const typeString = fileContext.nodeAsString(typeNode);
35
+
36
+ fileContext.debug(`The '${termString}' constructor's '${typeString}' type is not present.`, termNode);
39
37
  }
40
38
  }
41
39
 
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  import Type from "../type";
4
+ import verifyGivenType from "../verify/givenType";
4
5
 
5
- import { typeNameFromTypeNode } from "../utilities/query";
6
+ import { typeNameFromTypeNode } from "../utilities/name";
6
7
 
7
8
  export default function verifyType(typeNode, superTypeNode, fileContext) {
8
9
  let typeVerified = false;
@@ -11,23 +12,26 @@ export default function verifyType(typeNode, superTypeNode, fileContext) {
11
12
 
12
13
  fileContext.trace(`Verifying the '${typeString}' type...`, typeNode);
13
14
 
14
- const typeName = typeNameFromTypeNode(typeNode),
15
- typePresent = fileContext.isTypePresentByTypeName(typeName);
15
+ const typePresent = fileContext.isTypePresentByTypeNode(typeNode);
16
16
 
17
17
  if (typePresent) {
18
- fileContext.debug(`The type '${typeName}' is already present.`, typeNode);
18
+ const typeString = fileContext.nodeAsString(typeNode);
19
+
20
+ fileContext.debug(`The type '${typeString}' is already present.`, typeNode);
19
21
  } else {
20
22
  let type;
21
23
 
22
- const superTypeName = typeNameFromTypeNode(superTypeNode);
24
+ const typeName = typeNameFromTypeNode(typeNode);
23
25
 
24
- if (superTypeName === null) {
26
+ if (superTypeNode === null) {
25
27
  type = Type.fromTypeName(typeName);
26
28
  } else {
27
- const superType = fileContext.findTypeByTypeName(superTypeName);
29
+ const superType = fileContext.findTypeByTypeNode(superTypeNode);
28
30
 
29
31
  if (superType === null) {
30
- fileContext.debug(`The super-type '${superTypeName}' is not present.`, typeNode);
32
+ const superTypeString = fileContext.nodeAsString(superTypeNode);
33
+
34
+ fileContext.debug(`The super-type '${superTypeString}' is not present.`, typeNode);
31
35
  } else {
32
36
  type = Type.fromTypeNameAndSuperType(typeName, superType);
33
37
  }
@@ -47,26 +51,20 @@ export default function verifyType(typeNode, superTypeNode, fileContext) {
47
51
  return typeVerified;
48
52
  }
49
53
 
50
- export function verifyStandaloneType(typeNode, fileContext, verifyAhead) {
51
- let standaloneTypeVerified = false;
52
-
53
- const typeString = fileContext.nodeAsString(typeNode);
54
+ export function verifyStandaloneType(typeNode, localContext, verifyAhead) {
55
+ let standaloneTypeVerified;
54
56
 
55
- fileContext.trace(`Verifying the '${typeString}' standalone type...`, typeNode);
57
+ const typeString = localContext.nodeAsString(typeNode);
56
58
 
57
- const typeName = typeNameFromTypeNode(typeNode),
58
- typePresent = fileContext.isTypePresentByTypeName(typeName);
59
+ localContext.trace(`Verifying the '${typeString}' standalone type...`, typeNode);
59
60
 
60
- if (!typePresent) {
61
- fileContext.debug(`The type '${typeName}' is not present.`, typeNode);
62
- } else {
63
- const verifiedAhead = verifyAhead();
61
+ const types = [],
62
+ givenTypeVerified = verifyGivenType(typeNode, types, localContext, verifyAhead);
64
63
 
65
- standaloneTypeVerified = verifiedAhead; ///
66
- }
64
+ standaloneTypeVerified = givenTypeVerified; ///
67
65
 
68
66
  if (standaloneTypeVerified) {
69
- fileContext.debug(`...verified the '${typeString}' standalone type.`, typeNode);
67
+ localContext.debug(`...verified the '${typeString}' standalone type.`, typeNode);
70
68
  }
71
69
 
72
70
  return standaloneTypeVerified;
@@ -2,9 +2,9 @@
2
2
 
3
3
  import Variable from "../variable";
4
4
  import VariableAssignment from "../assignment/variable";
5
+ import verifyGivenVariable from "../verify/givenVariable";
5
6
 
6
7
  import { objectType } from "../type";
7
- import { typeNameFromTypeNode } from "../utilities/query";
8
8
 
9
9
  export default function verifyVariable(variableNode, typeNode, fileContext) {
10
10
  let variableVerified = false;
@@ -20,17 +20,17 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
20
20
  } else {
21
21
  let variable;
22
22
 
23
- const typeName = typeNameFromTypeNode(typeNode);
24
-
25
- if (typeName === null) {
23
+ if (typeNode === null) {
26
24
  const type = objectType;
27
25
 
28
26
  variable = Variable.fromVariableNodeAndType(variableNode, type);
29
27
  } else {
30
- const type = fileContext.findTypeByTypeName(typeName);
28
+ const type = fileContext.findTypeByTypeNode(typeNode);
31
29
 
32
30
  if (type === null) {
33
- fileContext.debug(`The '${variableString}' variable's '${typeName}' type is not present.`, variableNode);
31
+ const typeString = fileContext.nodeAsString(typeNode);
32
+
33
+ fileContext.debug(`The '${variableString}' variable's '${typeString}' type is not present.`, variableNode);
34
34
  } else {
35
35
  variable = Variable.fromVariableNodeAndType(variableNode, type);
36
36
  }
@@ -53,23 +53,20 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
53
53
  return variableVerified;
54
54
  }
55
55
 
56
- export function verifyStandaloneVariable(variableNode, localMetaContext, verifyAhead) {
57
- let standaloneVariableVerified = false;
58
-
59
- const variableString = localMetaContext.nodeAsString(variableNode);
56
+ export function verifyStandaloneVariable(variableNode, localContext, verifyAhead) {
57
+ let standaloneVariableVerified;
60
58
 
61
- localMetaContext.trace(`Verifying the '${variableString}' standalone variable...`, variableNode);
59
+ const variableString = localContext.nodeAsString(variableNode);
62
60
 
63
- const variablePresent = localMetaContext.isVariablePresentByVariableNode(variableNode);
61
+ localContext.trace(`Verifying the '${variableString}' standalone variable...`, variableNode);
64
62
 
65
- if (variablePresent) {
66
- const verifiedAhead = verifyAhead();
63
+ const variables = [],
64
+ givenVariableVerified = verifyGivenVariable(variableNode, variables, localContext, verifyAhead);
67
65
 
68
- standaloneVariableVerified = verifiedAhead; ///
69
- }
66
+ standaloneVariableVerified = givenVariableVerified; ///
70
67
 
71
68
  if (standaloneVariableVerified) {
72
- localMetaContext.debug(`...verified the '${variableString}' standalone variable.`, variableNode);
69
+ localContext.debug(`...verified the '${variableString}' standalone variable.`, variableNode);
73
70
  }
74
71
 
75
72
  return standaloneVariableVerified;