occam-verify-cli 0.0.317 → 0.0.319

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 (94) hide show
  1. package/bin/callbacks.js +27 -0
  2. package/bin/main.js +2 -5
  3. package/bin/messages.js +11 -0
  4. package/bin/utilities/logging.js +2 -10
  5. package/bin/utilities/release.js +47 -46
  6. package/lib/callbacks.js +68 -0
  7. package/lib/context/file.js +58 -81
  8. package/lib/context/metaproof.js +30 -118
  9. package/lib/context/proof.js +73 -137
  10. package/lib/context/release.js +81 -15
  11. package/lib/index.js +9 -1
  12. package/lib/mixins/callbacks.js +27 -0
  13. package/lib/mixins/file.js +23 -0
  14. package/lib/mixins/logging.js +39 -0
  15. package/lib/rule.js +3 -3
  16. package/lib/utilities/verification.js +45 -0
  17. package/lib/verify/IndicativeConditional.js +9 -5
  18. package/lib/verify/assertion/type.js +12 -10
  19. package/lib/verify/axiom.js +10 -14
  20. package/lib/verify/conclusion.js +5 -3
  21. package/lib/verify/conditinalInference.js +7 -5
  22. package/lib/verify/declaration/combinator.js +7 -3
  23. package/lib/verify/declaration/constructor.js +7 -3
  24. package/lib/verify/declaration/topLevel.js +11 -9
  25. package/lib/verify/declaration/type.js +8 -3
  26. package/lib/verify/declaration/variable.js +7 -3
  27. package/lib/verify/equality.js +8 -6
  28. package/lib/verify/file.js +7 -9
  29. package/lib/verify/label.js +6 -4
  30. package/lib/verify/labels.js +5 -4
  31. package/lib/verify/metaDerivation.js +21 -18
  32. package/lib/verify/metaproof.js +6 -4
  33. package/lib/verify/metastatement/qualified.js +7 -5
  34. package/lib/verify/metastatement/unqualified.js +7 -5
  35. package/lib/verify/premiseOrPremises.js +11 -12
  36. package/lib/verify/release.js +28 -18
  37. package/lib/verify/rule.js +11 -14
  38. package/lib/verify/statement/qualified.js +7 -3
  39. package/lib/verify/statement/unqualified.js +6 -4
  40. package/lib/verify/statement.js +8 -10
  41. package/lib/verify/statementAsCombinator.js +33 -36
  42. package/lib/verify/term.js +4 -2
  43. package/lib/verify/termAsConstructor.js +38 -39
  44. package/lib/verify/termAsVariable.js +4 -2
  45. package/lib/verify/type.js +18 -14
  46. package/lib/verify/unconditionalInference.js +5 -3
  47. package/lib/verify/variable.js +13 -10
  48. package/package.json +1 -1
  49. package/src/callbacks.js +27 -0
  50. package/src/context/file.js +62 -61
  51. package/src/context/metaproof.js +29 -44
  52. package/src/context/proof.js +51 -64
  53. package/src/context/release.js +33 -11
  54. package/src/index.js +3 -0
  55. package/src/mixins/callbacks.js +15 -0
  56. package/src/mixins/file.js +12 -0
  57. package/src/mixins/logging.js +24 -0
  58. package/src/rule.js +2 -2
  59. package/src/utilities/verification.js +41 -0
  60. package/src/verify/IndicativeConditional.js +18 -9
  61. package/src/verify/assertion/type.js +15 -8
  62. package/src/verify/axiom.js +15 -17
  63. package/src/verify/conclusion.js +8 -2
  64. package/src/verify/conditinalInference.js +10 -4
  65. package/src/verify/declaration/combinator.js +12 -3
  66. package/src/verify/declaration/constructor.js +12 -3
  67. package/src/verify/declaration/topLevel.js +15 -9
  68. package/src/verify/declaration/type.js +14 -4
  69. package/src/verify/declaration/variable.js +12 -3
  70. package/src/verify/equality.js +11 -4
  71. package/src/verify/file.js +6 -8
  72. package/src/verify/label.js +9 -3
  73. package/src/verify/labels.js +5 -3
  74. package/src/verify/metaDerivation.js +26 -19
  75. package/src/verify/metaproof.js +9 -3
  76. package/src/verify/metastatement/qualified.js +10 -4
  77. package/src/verify/metastatement/unqualified.js +10 -4
  78. package/src/verify/premiseOrPremises.js +18 -14
  79. package/src/verify/release.js +45 -27
  80. package/src/verify/rule.js +15 -16
  81. package/src/verify/statement/qualified.js +12 -3
  82. package/src/verify/statement/unqualified.js +9 -3
  83. package/src/verify/statement.js +10 -9
  84. package/src/verify/statementAsCombinator.js +45 -46
  85. package/src/verify/term.js +7 -1
  86. package/src/verify/termAsConstructor.js +48 -45
  87. package/src/verify/termAsVariable.js +7 -1
  88. package/src/verify/type.js +25 -21
  89. package/src/verify/unconditionalInference.js +8 -2
  90. package/src/verify/variable.js +18 -11
  91. package/lib/mixins/log.js +0 -41
  92. package/lib/verify/supposition.js +0 -29
  93. package/src/mixins/log.js +0 -28
  94. package/src/verify/supposition.js +0 -22
@@ -16,20 +16,19 @@ const labelNodesQuery = nodesQuery("/rule/label"),
16
16
  conditionalInferenceNodeQuery = nodeQuery("/rule/conditionalInference!"),
17
17
  unconditionalInferenceNodeQuery = nodeQuery("/rule/unconditionalInference!");
18
18
 
19
- export default function verifyRule(ruleNode, context) {
19
+ export default function verifyRule(ruleNode, fileContext) {
20
20
  let ruleVerified = false;
21
21
 
22
- const labelNodes = labelNodesQuery(ruleNode),
23
- labelsString = nodesAsString(labelNodes);
24
-
25
- const metaproofContext = MetaproofContext.fromContext(context);
22
+ fileContext.begin(ruleNode);
26
23
 
27
- context = metaproofContext; ///
24
+ const labelNodes = labelNodesQuery(ruleNode),
25
+ labelsString = nodesAsString(labelNodes),
26
+ metaproofContext = MetaproofContext.fromFileContext(fileContext);
28
27
 
29
- context.debug(`Verifying the '${labelsString}' rule...`, ruleNode);
28
+ fileContext.debug(`Verifying the '${labelsString}' rule...`);
30
29
 
31
30
  const labels = [],
32
- labelsVerified = verifyLabels(labelNodes, labels, context);
31
+ labelsVerified = verifyLabels(labelNodes, labels, fileContext);
33
32
 
34
33
  if (labelsVerified) {
35
34
  const premises = [],
@@ -41,11 +40,11 @@ export default function verifyRule(ruleNode, context) {
41
40
  unconditionalInferenceVerified = false;
42
41
 
43
42
  if (conditionalInferenceNode !== null) {
44
- conditionalInferenceVerified = verifyConditionalInference(conditionalInferenceNode, premises, conclusions, context);
43
+ conditionalInferenceVerified = verifyConditionalInference(conditionalInferenceNode, premises, conclusions, metaproofContext);
45
44
  }
46
45
 
47
46
  if (unconditionalInferenceNode !== null) {
48
- unconditionalInferenceVerified = verifyUnconditionalInference(unconditionalInferenceNode, premises, conclusions, context);
47
+ unconditionalInferenceVerified = verifyUnconditionalInference(unconditionalInferenceNode, premises, conclusions, metaproofContext);
49
48
  }
50
49
 
51
50
  if (conditionalInferenceVerified || unconditionalInferenceVerified) {
@@ -56,22 +55,22 @@ export default function verifyRule(ruleNode, context) {
56
55
  let metaproofVerified = true;
57
56
 
58
57
  if (metaproofNode !== null) {
59
- metaproofVerified = verifyMetaproof(metaproofNode, conclusion, context);
58
+ metaproofVerified = verifyMetaproof(metaproofNode, conclusion, metaproofContext);
60
59
  }
61
60
 
62
61
  if (metaproofVerified) {
63
62
  const rule = Rule.fromPremisesConclusionAndLabels(premises, conclusion, labels);
64
63
 
65
- context.addRule(rule);
64
+ fileContext.addRule(rule);
66
65
 
67
66
  ruleVerified = true;
68
67
  }
69
68
  }
70
-
71
- if (ruleVerified) {
72
- context.info(`Verified the '${labelsString}' rule.`, ruleNode);
73
- }
74
69
  }
75
70
 
71
+ ruleVerified ?
72
+ fileContext.complete(ruleNode) :
73
+ fileContext.complete(ruleNode);
74
+
76
75
  return ruleVerified;
77
76
  }
@@ -6,10 +6,19 @@ import { nodeQuery } from "../../utilities/query";
6
6
 
7
7
  const statementNodeQuery = nodeQuery("/qualifiedStatement/statement!");
8
8
 
9
- export default function verifyQualifiedStatement(qualifiedStatementNode, context) {
9
+ export default function verifyQualifiedStatement(qualifiedStatementNode, proofContext) {
10
+ let qualifiedStatementVerified;
11
+
12
+ proofContext.begin(qualifiedStatementNode);
13
+
10
14
  const statementNode = statementNodeQuery(qualifiedStatementNode),
11
- statementVerified = verifyStatement(statementNode, context),
12
- qualifiedStatementVerified = statementVerified; ///
15
+ statementVerified = verifyStatement(statementNode, proofContext);
16
+
17
+ qualifiedStatementVerified = statementVerified; ///
18
+
19
+ qualifiedStatementVerified ?
20
+ proofContext.complete(qualifiedStatementNode) :
21
+ proofContext.halt(qualifiedStatementNode);
13
22
 
14
23
  return qualifiedStatementVerified;
15
24
  }
@@ -6,20 +6,26 @@ import { nodeQuery } from "../../utilities/query";
6
6
 
7
7
  const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!");
8
8
 
9
- export default function verifyUnqualifiedStatement(unqualifiedStatementNode, context) {
9
+ export default function verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext) {
10
10
  let unqualifiedStatementVerified = false;
11
11
 
12
+ proofContext.begin(unqualifiedStatementNode);
13
+
12
14
  const statementNode = statementNodeQuery(unqualifiedStatementNode);
13
15
 
14
16
  if (statementNode !== null) {
15
- const statementVerified = verifyStatement(statementNode, context);
17
+ const statementVerified = verifyStatement(statementNode, proofContext);
16
18
 
17
19
  if (statementVerified) {
18
- context.addStatementNode(statementNode);
20
+ debugger
19
21
 
20
22
  unqualifiedStatementVerified = true;
21
23
  }
22
24
  }
23
25
 
26
+ unqualifiedStatementVerified ?
27
+ proofContext.complete(unqualifiedStatementNode) :
28
+ proofContext.halt(unqualifiedStatementNode);
29
+
24
30
  return unqualifiedStatementVerified;
25
31
  }
@@ -9,33 +9,34 @@ import { nodeAsString } from "../utilities/string";
9
9
  const equalityNodeQuery = nodeQuery("/statement/equality!"),
10
10
  typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
11
11
 
12
- export default function verifyStatement(statementNode, context) {
12
+ export default function verifyStatement(statementNode, proofContext) {
13
13
  let statementVerified = false;
14
14
 
15
- const statementString = nodeAsString(statementNode);
16
-
17
- context.debug(`Verifying the '${statementString}' statement...`, statementNode);
15
+ proofContext.begin(statementNode);
18
16
 
19
17
  const equalityNode = equalityNodeQuery(statementNode),
18
+ statementString = nodeAsString(statementNode),
20
19
  typeAssertionNode = typeAssertionNodeQuery(statementNode);
21
20
 
21
+ proofContext.debug(`Verifying the '${statementString}' statement...`);
22
+
22
23
  if (false) {
23
24
  ///
24
25
  } else if (equalityNode !== null) {
25
- const equalityVerified = verifyEquality(equalityNode, context);
26
+ const equalityVerified = verifyEquality(equalityNode, proofContext);
26
27
 
27
28
  statementVerified = equalityVerified; ///
28
29
  } else if (typeAssertionNode !== null) {
29
- const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, context);
30
+ const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, proofContext);
30
31
 
31
32
  statementVerified = typeAssertionVerified; ///
32
33
  } else {
33
34
  debugger
34
35
  }
35
36
 
36
- if (statementVerified) {
37
- context.info(`Verified the '${statementString}' statement.`, statementNode);
38
- }
37
+ statementVerified ?
38
+ proofContext.complete(statementNode) :
39
+ proofContext.halt(statementNode);
39
40
 
40
41
  return statementVerified;
41
42
  }
@@ -6,47 +6,46 @@ import { nodeAsString } from "../utilities/string";
6
6
  import { typeNameFromTypeNode } from "../utilities/query";
7
7
  import { TERM_RULE_NAME, TYPE_RULE_NAME } from "../ruleNames";
8
8
 
9
- export default function verifyStatementAsCombinator(statementNode, context) {
9
+ export default function verifyStatementAsCombinator(statementNode, fileContext) {
10
10
  let statementVerifiedAsCombinator = false;
11
11
 
12
- const statementString = nodeAsString(statementNode);
13
-
14
- context.debug(`Verifying the ${statementString} statement as a combinator...`, statementNode);
12
+ fileContext.begin(statementNode);
15
13
 
16
14
  const nonTerminalNode = statementNode, ///
17
15
  childNodes = nonTerminalNode.getChildNodes(),
18
- childNodesVerified = verifyChildNodes(childNodes, context);
16
+ childNodesVerified = verifyChildNodes(childNodes, fileContext);
19
17
 
20
18
  if (childNodesVerified) {
21
- statementVerifiedAsCombinator = true;
22
- }
19
+ const combinator = Combinator.fromStatementNode(statementNode),
20
+ statementString = nodeAsString(statementNode);
23
21
 
24
- if (statementVerifiedAsCombinator) {
25
- const combinator = Combinator.fromStatementNode(statementNode);
22
+ fileContext.info(`Verified the '${statementString}' combinator.`);
26
23
 
27
- context.addCombinator(combinator);
24
+ fileContext.addCombinator(combinator);
28
25
 
29
- const statementString = nodeAsString(statementNode);
30
-
31
- context.info(`Verified the '${statementString}' combinator.`, statementNode);
26
+ statementVerifiedAsCombinator = true;
32
27
  }
33
28
 
29
+ statementVerifiedAsCombinator ?
30
+ fileContext.complete(statementNode) :
31
+ fileContext.halt(statementNode);
32
+
34
33
  return statementVerifiedAsCombinator;
35
34
  }
36
35
 
37
- function verifyNode(node, context) {
36
+ function verifyNode(node, fileContext) {
38
37
  let nodeVerified;
39
38
 
40
39
  const nodeTerminalNode = node.isTerminalNode();
41
40
 
42
41
  if (nodeTerminalNode) {
43
42
  const terminalNode = node, ///
44
- terminalNodeVerified = verifyTerminalNode(terminalNode, context);
43
+ terminalNodeVerified = verifyTerminalNode(terminalNode, fileContext);
45
44
 
46
45
  nodeVerified = terminalNodeVerified; ///
47
46
  } else {
48
47
  const nonTerminalNode = node, ///
49
- nonTerminalNodeVerified = verifyNonTerminalNode(nonTerminalNode, context);
48
+ nonTerminalNodeVerified = verifyNonTerminalNode(nonTerminalNode, fileContext);
50
49
 
51
50
  nodeVerified = nonTerminalNodeVerified; ///
52
51
  }
@@ -54,10 +53,33 @@ function verifyNode(node, context) {
54
53
  return nodeVerified;
55
54
  }
56
55
 
57
- function verifyChildNodes(childNodes, context) {
56
+ function verifyTypeNode(typeNode, fileContext) {
57
+ let typeNodeVerified = false;
58
+
59
+ const typeName = typeNameFromTypeNode(typeNode),
60
+ typePresent = fileContext.isTypePresentByTypeName(typeName);
61
+
62
+ if (!typePresent) {
63
+ fileContext.error(`The type '${typeName}' is missing.`);
64
+ } else {
65
+ typeNodeVerified = true;
66
+ }
67
+
68
+ return typeNodeVerified;
69
+ }
70
+
71
+ function verifyTermNode(termNode, fileContext) {
72
+ let termNodeVerified = false;
73
+
74
+ debugger
75
+
76
+ return termNodeVerified;
77
+ }
78
+
79
+ function verifyChildNodes(childNodes, fileContext) {
58
80
  const childNodesVerified = childNodes.every((childNode) => {
59
81
  const node = childNode, ///
60
- nodeVerified = verifyNode(node, context);
82
+ nodeVerified = verifyNode(node, fileContext);
61
83
 
62
84
  if (nodeVerified) {
63
85
  return true;
@@ -67,13 +89,13 @@ function verifyChildNodes(childNodes, context) {
67
89
  return childNodesVerified;
68
90
  }
69
91
 
70
- function verifyTerminalNode(terminalNode, context) {
92
+ function verifyTerminalNode(terminalNode, fileContext) {
71
93
  const terminalNodeVerified = true;
72
94
 
73
95
  return terminalNodeVerified;
74
96
  }
75
97
 
76
- function verifyNonTerminalNode(nonTerminalNode, context) {
98
+ function verifyNonTerminalNode(nonTerminalNode, fileContext) {
77
99
  let nonTerminalNodeVerified;
78
100
 
79
101
  const ruleName = nonTerminalNode.getRuleName();
@@ -81,7 +103,7 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
81
103
  switch (ruleName) {
82
104
  case TYPE_RULE_NAME: {
83
105
  const typeNode = nonTerminalNode, ///
84
- typeNodeVerified = verifyTypeNode(typeNode, context);
106
+ typeNodeVerified = verifyTypeNode(typeNode, fileContext);
85
107
 
86
108
  nonTerminalNodeVerified = typeNodeVerified; ///
87
109
 
@@ -90,7 +112,7 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
90
112
 
91
113
  case TERM_RULE_NAME: {
92
114
  const termNode = nonTerminalNode, ///
93
- termNodeVerified = verifyTermNode(termNode, context);
115
+ termNodeVerified = verifyTermNode(termNode, fileContext);
94
116
 
95
117
  nonTerminalNodeVerified = termNodeVerified; ///
96
118
 
@@ -99,7 +121,7 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
99
121
 
100
122
  default: {
101
123
  const childNodes = nonTerminalNode.getChildNodes(),
102
- childNodesVerified = verifyChildNodes(childNodes, context);
124
+ childNodesVerified = verifyChildNodes(childNodes, fileContext);
103
125
 
104
126
  nonTerminalNodeVerified = childNodesVerified; ///
105
127
 
@@ -109,26 +131,3 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
109
131
 
110
132
  return nonTerminalNodeVerified;
111
133
  }
112
-
113
- function verifyTypeNode(typeNode, context) {
114
- let typeNodeVerified = false;
115
-
116
- const typeName = typeNameFromTypeNode(typeNode),
117
- typePresent = context.isTypePresentByTypeName(typeName);
118
-
119
- if (!typePresent) {
120
- context.error(`The type '${typeName}' is missing.`, typeNode);
121
- } else {
122
- typeNodeVerified = true;
123
- }
124
-
125
- return typeNodeVerified;
126
- }
127
-
128
- function verifyTermNode(termNode, context) {
129
- let termNodeVerified = false;
130
-
131
- debugger
132
-
133
- return termNodeVerified;
134
- }
@@ -13,6 +13,8 @@ const termNodeQuery = nodeQuery("/argument/term!"),
13
13
  export default function verifyTerm(termNode, types, values, context) {
14
14
  let termVerified = false;
15
15
 
16
+ context.begin(termNode);
17
+
16
18
  const names = [],
17
19
  termVerifiedAsVariable = verifyTermAsVariable(termNode, types, names, values, context);
18
20
 
@@ -40,6 +42,10 @@ export default function verifyTerm(termNode, types, values, context) {
40
42
  }
41
43
  }
42
44
 
45
+ termVerified ?
46
+ context.complete(termNode) :
47
+ context.halt(termNode);
48
+
43
49
  return termVerified;
44
50
  }
45
51
 
@@ -153,7 +159,7 @@ function verifyArgumentNode(argumentNode, constructorArgumentNode, context) {
153
159
  if (termNode === null) {
154
160
  const argumentString = nodeAsString(argumentNode);
155
161
 
156
- context.error(`The ${argumentString} argument should be a term, not a type`, argumentNode);
162
+ context.error(`The ${argumentString} argument should be a term, not a type`);
157
163
  } else {
158
164
  const types = [],
159
165
  values = [],
@@ -10,18 +10,16 @@ import { TERM_RULE_NAME, ARGUMENT_RULE_NAME } from "../ruleNames";
10
10
 
11
11
  const typeNodeQuery = nodeQuery("/argument/type");
12
12
 
13
- export default function verifyTermAsConstructor(termNode, typeNode, context) {
13
+ export default function verifyTermAsConstructor(termNode, typeNode, fileContext) {
14
14
  let termVerifiedAsConstructor = false;
15
15
 
16
- const termString = nodeAsString(termNode);
16
+ fileContext.begin(termNode);
17
17
 
18
- context.debug(`Verifying the '${termString}' term as a constructor...`, termNode);
18
+ let type = null;
19
19
 
20
20
  const nonTerminalNode = termNode, ///
21
21
  childNodes = nonTerminalNode.getChildNodes(),
22
- childNodesVerified = verifyChildNodes(childNodes, context);
23
-
24
- let type = null;
22
+ childNodesVerified = verifyChildNodes(childNodes, fileContext);
25
23
 
26
24
  if (childNodesVerified) {
27
25
  if (typeNode === null) {
@@ -29,44 +27,47 @@ export default function verifyTermAsConstructor(termNode, typeNode, context) {
29
27
  } else {
30
28
  const typeName = typeNameFromTypeNode(typeNode);
31
29
 
32
- type = context.findTypeByTypeName(typeName);
30
+ type = fileContext.findTypeByTypeName(typeName);
33
31
 
34
32
  if (type !== null) {
35
33
  termVerifiedAsConstructor = true;
36
34
  } else {
37
35
  const termString = nodeAsString(termNode);
38
36
 
39
- context.error(`The '${termString}' constructor's '${typeName}' type is missing.`, termNode);
37
+ fileContext.error(`The '${termString}' constructor's '${typeName}' type is missing.`);
40
38
  }
41
39
  }
42
40
  }
43
41
 
44
42
  if (termVerifiedAsConstructor) {
45
- const constructor = Constructor.fromTermNodeAndType(termNode, type);
43
+ const termString = nodeAsString(termNode),
44
+ constructor = Constructor.fromTermNodeAndType(termNode, type);
46
45
 
47
- context.addConstructor(constructor);
46
+ fileContext.addConstructor(constructor);
48
47
 
49
- const termString = nodeAsString(termNode);
50
-
51
- context.info(`Verified the '${termString}' constructor.`, termNode);
48
+ fileContext.info(`Verified the '${termString}' constructor.`);
52
49
  }
53
50
 
51
+ termVerifiedAsConstructor ?
52
+ fileContext.complete(termNode) :
53
+ fileContext.halt(termNode);
54
+
54
55
  return termVerifiedAsConstructor;
55
56
  }
56
57
 
57
- function verifyNode(node, context) {
58
+ function verifyNode(node, fileContext) {
58
59
  let nodeVerified;
59
60
 
60
61
  const nodeTerminalNode = node.isTerminalNode();
61
62
 
62
63
  if (nodeTerminalNode) {
63
64
  const terminalNode = node, ///
64
- terminalNodeVerified = verifyTerminalNode(terminalNode, context);
65
+ terminalNodeVerified = verifyTerminalNode(terminalNode, fileContext);
65
66
 
66
67
  nodeVerified = terminalNodeVerified; ///
67
68
  } else {
68
69
  const nonTerminalNode = node, ///
69
- nonTerminalNodeVerified = verifyNonTerminalNode(nonTerminalNode, context);
70
+ nonTerminalNodeVerified = verifyNonTerminalNode(nonTerminalNode, fileContext);
70
71
 
71
72
  nodeVerified = nonTerminalNodeVerified; ///
72
73
  }
@@ -74,10 +75,10 @@ function verifyNode(node, context) {
74
75
  return nodeVerified;
75
76
  }
76
77
 
77
- function verifyChildNodes(childNodes, context) {
78
+ function verifyChildNodes(childNodes, fileContext) {
78
79
  const childNodesVerified = childNodes.every((childNode) => {
79
80
  const node = childNode, ///
80
- nodeVerified = verifyNode(node, context);
81
+ nodeVerified = verifyNode(node, fileContext);
81
82
 
82
83
  if (nodeVerified) {
83
84
  return true;
@@ -87,13 +88,36 @@ function verifyChildNodes(childNodes, context) {
87
88
  return childNodesVerified;
88
89
  }
89
90
 
90
- function verifyTerminalNode(terminalNode, context) {
91
+ function verifyTerminalNode(terminalNode, fileContext) {
91
92
  const terminalNodeVerified = true;
92
93
 
93
94
  return terminalNodeVerified;
94
95
  }
95
96
 
96
- function verifyNonTerminalNode(nonTerminalNode, context) {
97
+ function verifyArgumentNode(argumentNode, fileContext) {
98
+ let typeNodeVerified = false;
99
+
100
+ const typeNode = typeNodeQuery(argumentNode);
101
+
102
+ if (typeNode === null) {
103
+ const argumentString = nodeAsString(argumentNode);
104
+
105
+ fileContext.error(`The ${argumentString} argument should be a type.`);
106
+ } else {
107
+ const typeName = typeNameFromTypeNode(typeNode),
108
+ typePresent = fileContext.isTypePresentByTypeName(typeName);
109
+
110
+ if (!typePresent) {
111
+ fileContext.error(`The type '${typeName}' is missing.`);
112
+ } else {
113
+ typeNodeVerified = true;
114
+ }
115
+ }
116
+
117
+ return typeNodeVerified;
118
+ }
119
+
120
+ function verifyNonTerminalNode(nonTerminalNode, fileContext) {
97
121
  let nonTerminalNodeVerified;
98
122
 
99
123
  const ruleName = nonTerminalNode.getRuleName();
@@ -101,7 +125,7 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
101
125
  switch (ruleName) {
102
126
  case ARGUMENT_RULE_NAME: {
103
127
  const argumentNode = nonTerminalNode, ///
104
- argumentNodeVerified = verifyArgumentNode(argumentNode, context);
128
+ argumentNodeVerified = verifyArgumentNode(argumentNode, fileContext);
105
129
 
106
130
  nonTerminalNodeVerified = argumentNodeVerified; ///
107
131
 
@@ -112,6 +136,7 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
112
136
  const termNode = nonTerminalNode, ///
113
137
  types = [],
114
138
  values = [],
139
+ context = fileContext, ///
115
140
  termVerified = verifyTerm(termNode, types, values, context);
116
141
 
117
142
  if (termVerified) {
@@ -121,7 +146,7 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
121
146
  if (type !== null) {
122
147
  const termString = nodeAsString(termNode);
123
148
 
124
- context.error(`The type of the constructor's compound '${termString}' term node is not null.`, termNode);
149
+ fileContext.error(`The type of the constructor's compound '${termString}' term node is not null.`);
125
150
  } else {
126
151
  nonTerminalNodeVerified = true; ///
127
152
  }
@@ -132,7 +157,7 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
132
157
 
133
158
  default: {
134
159
  const childNodes = nonTerminalNode.getChildNodes(),
135
- childNodesVerified = verifyChildNodes(childNodes, context);
160
+ childNodesVerified = verifyChildNodes(childNodes, fileContext);
136
161
 
137
162
  nonTerminalNodeVerified = childNodesVerified; ///
138
163
 
@@ -143,25 +168,3 @@ function verifyNonTerminalNode(nonTerminalNode, context) {
143
168
  return nonTerminalNodeVerified;
144
169
  }
145
170
 
146
- function verifyArgumentNode(argumentNode, context) {
147
- let typeNodeVerified = false;
148
-
149
- const typeNode = typeNodeQuery(argumentNode);
150
-
151
- if (typeNode === null) {
152
- const argumentString = nodeAsString(argumentNode);
153
-
154
- context.error(`The ${argumentString} argument should be a type.`, argumentNode);
155
- } else {
156
- const typeName = typeNameFromTypeNode(typeNode),
157
- typePresent = context.isTypePresentByTypeName(typeName);
158
-
159
- if (!typePresent) {
160
- context.error(`The type '${typeName}' is missing.`, typeNode);
161
- } else {
162
- typeNodeVerified = true;
163
- }
164
- }
165
-
166
- return typeNodeVerified;
167
- }
@@ -7,6 +7,8 @@ const variableNodeQuery = nodeQuery("/term/variable!");
7
7
  export default function verifyTermAsVariable(termNode, types, names, values, context) {
8
8
  let termVerifiedAsVariable = false;
9
9
 
10
+ context.begin(termNode);
11
+
10
12
  const variableNode = variableNodeQuery(termNode);
11
13
 
12
14
  if (variableNode !== null) {
@@ -14,7 +16,7 @@ export default function verifyTermAsVariable(termNode, types, names, values, con
14
16
  variablePresent = context.isVariablePresentByVariableName(variableName);
15
17
 
16
18
  if (!variablePresent) {
17
- context.error(`The ${variableName} variable is not present.`, variableNode)
19
+ context.error(`The ${variableName} variable is not present.`)
18
20
  } else {
19
21
  const variable = context.findVariableByVariableName(variableName),
20
22
  type = variable.getType(),
@@ -31,5 +33,9 @@ export default function verifyTermAsVariable(termNode, types, names, values, con
31
33
  }
32
34
  }
33
35
 
36
+ termVerifiedAsVariable ?
37
+ context.complete(termNode) :
38
+ context.halt(termNode);
39
+
34
40
  return termVerifiedAsVariable;
35
41
  }
@@ -2,46 +2,50 @@
2
2
 
3
3
  import Type from "../type";
4
4
 
5
+ import { nodeAsString } from "../utilities/string";
5
6
  import { typeNameFromTypeNode } from "../utilities/query";
6
7
 
7
- export default function verifyType(typeNode, superTypeNode, context) {
8
+ export default function verifyType(typeNode, superTypeNode, fileContext) {
8
9
  let typeVerified = false;
9
10
 
11
+ fileContext.begin(typeNode);
12
+
13
+ let type = null;
14
+
10
15
  const typeName = typeNameFromTypeNode(typeNode),
11
- typePresent = context.isTypePresentByTypeName(typeName);
16
+ typePresent = fileContext.isTypePresentByTypeName(typeName);
12
17
 
13
18
  if (typePresent) {
14
- context.error(`The type '${typeName}' is already present.`, typeNode);
19
+ fileContext.error(`The type '${typeName}' is already present.`);
15
20
  } else {
16
21
  const superTypeName = typeNameFromTypeNode(superTypeNode);
17
22
 
18
23
  if (superTypeName === null) {
19
- const type = Type.fromTypeName(typeName),
20
- typeString = type.asString();
21
-
22
- context.addType(type);
23
-
24
- typeVerified = true;
25
-
26
- context.info(`Verified the '${typeString}' type.`, typeNode);
24
+ type = Type.fromTypeName(typeName);
27
25
  } else {
28
- const superType = context.findTypeByTypeName(superTypeName);
26
+ const superType = fileContext.findTypeByTypeName(superTypeName);
29
27
 
30
28
  if (superType === null) {
31
- context.error(`The super-type '${superTypeName}' is missing.`, typeNode);
29
+ fileContext.error(`The super-type '${superTypeName}' is missing.`);
32
30
  } else {
33
- const type = Type.fromTypeNameAndSuperType(typeName, superType),
34
- typeString = type.asString();
31
+ type = Type.fromTypeNameAndSuperType(typeName, superType);
32
+ }
33
+ }
34
+ }
35
35
 
36
- context.addType(type);
36
+ if (type !== null) {
37
+ const typeString = nodeAsString(typeNode);
37
38
 
38
- typeVerified = true;
39
+ fileContext.info(`Verified the '${typeString}' type.`);
39
40
 
40
- context.info(`Verified the '${typeString}' type.`, typeNode);
41
- }
42
- }
41
+ fileContext.addType(type);
42
+
43
+ typeVerified = true;
43
44
  }
44
45
 
46
+ typeVerified ?
47
+ fileContext.complete(typeNode):
48
+ fileContext.halt(typeNode);
49
+
45
50
  return typeVerified;
46
51
  }
47
-