occam-verify-cli 0.0.676 → 0.0.677

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 (41) hide show
  1. package/lib/combinator.js +15 -12
  2. package/lib/constructor.js +26 -21
  3. package/lib/context/metaproof.js +7 -7
  4. package/lib/log.js +3 -3
  5. package/lib/node/statement/combinator/bracketed.js +8 -4
  6. package/lib/node/statement/combinator/equality.js +8 -4
  7. package/lib/ocmbinator/bracketed.js +4 -2
  8. package/lib/ocmbinator/equality.js +4 -2
  9. package/lib/tokens/statement/combinator/bracketed.js +17 -0
  10. package/lib/tokens/statement/combinator/equality.js +17 -0
  11. package/lib/utilities/lineIndex.js +52 -0
  12. package/lib/utilities/node.js +121 -15
  13. package/lib/utilities/string.js +1 -1
  14. package/lib/utilities/tokens.js +49 -36
  15. package/lib/verify/assertion/type.js +2 -2
  16. package/lib/verify/metastatement.js +6 -1
  17. package/lib/verify/statement.js +11 -2
  18. package/lib/verify/statementAsCombinator.js +2 -2
  19. package/lib/verify/term.js +14 -5
  20. package/lib/verify/termAsConstructor.js +2 -2
  21. package/package.json +1 -1
  22. package/src/combinator.js +21 -14
  23. package/src/constructor.js +33 -23
  24. package/src/context/metaproof.js +2 -2
  25. package/src/log.js +1 -1
  26. package/src/node/statement/combinator/bracketed.js +3 -4
  27. package/src/node/statement/combinator/equality.js +3 -5
  28. package/src/ocmbinator/bracketed.js +8 -3
  29. package/src/ocmbinator/equality.js +8 -3
  30. package/src/tokens/statement/combinator/bracketed.js +10 -0
  31. package/src/tokens/statement/combinator/equality.js +10 -0
  32. package/src/utilities/lineIndex.js +51 -0
  33. package/src/utilities/node.js +130 -53
  34. package/src/utilities/string.js +0 -1
  35. package/src/utilities/tokens.js +44 -32
  36. package/src/verify/assertion/type.js +1 -1
  37. package/src/verify/metastatement.js +8 -0
  38. package/src/verify/statement.js +19 -2
  39. package/src/verify/statementAsCombinator.js +2 -1
  40. package/src/verify/term.js +28 -7
  41. package/src/verify/termAsConstructor.js +2 -1
@@ -82,7 +82,7 @@ class StatementVerifier extends Verifier {
82
82
  if (termNode === null) {
83
83
  const argumentString = context.nodeAsString(argumentNode);
84
84
 
85
- context.error(`The ${argumentString} argument should be a term, not a type`, argumentNode);
85
+ context.error(`The '${argumentString}' argument should be a term, not a type`, argumentNode);
86
86
  } else {
87
87
  const types = [],
88
88
  termVerified = verifyTerm(termNode, types, context);
@@ -143,6 +143,10 @@ export const statementVerifier = new StatementVerifier();
143
143
  export default function verifyStatement(statementNode, assignments, derived, context) {
144
144
  let statementVerified = false;
145
145
 
146
+ const statementString = context.nodeAsString(statementNode);
147
+
148
+ context.debug(`Verifying the '${statementString}' statement...`, statementNode);
149
+
146
150
  if (!statementVerified) {
147
151
  const statementVerifiedAgainstCombinators = verifyStatementAgainstCombinators(statementNode, context);
148
152
 
@@ -167,12 +171,20 @@ export default function verifyStatement(statementNode, assignments, derived, con
167
171
  statementVerified = statementVerifiedAsEquality; //
168
172
  }
169
173
 
174
+ if (statementVerified) {
175
+ context.debug(`Verified the '${statementString}' statement.`, statementNode);
176
+ }
177
+
170
178
  return statementVerified;
171
179
  }
172
180
 
173
181
  export function verifyStatementAgainstCombinators(statementNode, context) {
174
182
  let statementVerifiedAgainstCombinators = false;
175
183
 
184
+ const statementString = context.nodeAsString(statementNode);
185
+
186
+ context.trace(`Verifying the '${statementString}' statement against combinators.`, statementNode);
187
+
176
188
  let combinators = context.getCombinators();
177
189
 
178
190
  combinators = [ ///
@@ -196,8 +208,13 @@ export function verifyStatementAgainstCombinators(statementNode, context) {
196
208
  }
197
209
 
198
210
  export function verifyStatementAgainstCombinator(statementNode, combinator, context) {
211
+ const statementString = context.nodeAsString(statementNode),
212
+ combinatorString = combinator.getString();
213
+
214
+ context.trace(`Verifying the '${statementString}' statement against the '${combinatorString}' combinator.`, statementNode);
215
+
199
216
  const combinatorStatementNode = combinator.getStatementNode(),
200
- nonTerminalNodeA = statementNode, ///
217
+ nonTerminalNodeA = statementNode, ///
201
218
  nonTerminalNodeB = combinatorStatementNode, ///
202
219
  nonTerminalNodeVerified = statementVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context),
203
220
  statementVerifiedAgainstCombinator = nonTerminalNodeVerified; ///
@@ -19,7 +19,8 @@ export default function verifyStatementAsCombinator(statementNode, fileContext)
19
19
  childNodesVerified = verifyChildNodes(childNodes, fileContext);
20
20
 
21
21
  if (childNodesVerified) {
22
- const combinator = Combinator.fromStatementNode(statementNode);
22
+ const tokens = fileContext.getTokens(),
23
+ combinator = Combinator.fromStatementNodeAndTokens(statementNode, tokens);
23
24
 
24
25
  fileContext.addCombinator(combinator);
25
26
 
@@ -68,7 +68,7 @@ class TermVerifier extends Verifier {
68
68
  if (typeNode !== null) {
69
69
  const argumentString = context.nodeAsString(argumentNode);
70
70
 
71
- context.error(`The ${argumentString} argument should be a term, not a type`, argumentNode);
71
+ context.error(`The '${argumentString}' argument should be a term, not a type`, argumentNode);
72
72
  } else {
73
73
  const termNode = termNodeQuery(argumentNode),
74
74
  constructorTermNode = termNodeQuery(constructorArgumentNode),
@@ -88,15 +88,19 @@ class TermVerifier extends Verifier {
88
88
 
89
89
  if (termVerified) {
90
90
  const constructorTypeName = typeNameFromTypeNode(constructorTypeNode),
91
+ firstType = first(types),
92
+ termType = firstType, ///
93
+ termTypeName = termType.getName(),
91
94
  constructorType = (constructorTypeName === OBJECT_TYPE_NAME) ?
92
95
  objectType :
93
96
  context.findTypeByTypeName(constructorTypeName),
94
- firstType = first(types),
95
- termType = firstType, ///
96
- type = constructorType, ///
97
- termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
97
+ termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(constructorType);
98
98
 
99
99
  if (termTypeEqualToOrSubTypeOfType) {
100
+ const termString = context.nodeAsString(termNode);
101
+
102
+ context.trace(`The '${termTypeName}' type of the '${termString}' term is equal to or a sub-type of the '${constructorTypeName}' type in the constructor.`, argumentNode);
103
+
100
104
  argumentNodeVerified = true;
101
105
  }
102
106
  }
@@ -114,7 +118,7 @@ export default function verifyTerm(termNode, types, context) {
114
118
 
115
119
  const termString = context.nodeAsString(termNode);
116
120
 
117
- context.trace(`Verifying the '${termString}' term...`, termNode);
121
+ context.debug(`Verifying the '${termString}' term...`, termNode);
118
122
 
119
123
  if (!termVerified) {
120
124
  const variables = [],
@@ -140,7 +144,11 @@ export default function verifyTerm(termNode, types, context) {
140
144
  }
141
145
 
142
146
  if (termVerified) {
143
- context.debug(`Verified the '${termString}' term.`, termNode);
147
+ const firstType = first(types),
148
+ type = firstType, ///
149
+ typeName = type.getName();
150
+
151
+ context.debug(`Verified the '${termString}' term, which has type '${typeName}'.`, termNode);
144
152
  }
145
153
 
146
154
  return termVerified;
@@ -149,6 +157,10 @@ export default function verifyTerm(termNode, types, context) {
149
157
  export function verifyTermAgainstConstructors(termNode, types, context) {
150
158
  let termVerifiedAgainstConstructors = false;
151
159
 
160
+ const termString = context.nodeAsString(termNode);
161
+
162
+ context.trace(`Verifying the '${termString}' term against constructors...`, termNode);
163
+
152
164
  const constructors = context.getConstructors(),
153
165
  constructor = constructors.find((constructor) => {
154
166
  const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, constructor, context);
@@ -170,6 +182,11 @@ export function verifyTermAgainstConstructors(termNode, types, context) {
170
182
  }
171
183
 
172
184
  export function verifyTermAgainstConstructor(termNode, constructor, context) {
185
+ const termString = context.nodeAsString(termNode),
186
+ constructorString = constructor.getString();
187
+
188
+ context.trace(`Verifying the '${termString}' term against the '${constructorString}' constructor.`, termNode);
189
+
173
190
  const constructorTermNode = constructor.getTermNode(),
174
191
  nonTerminalNNdeA = termNode, ///
175
192
  nonTerminalNodeB = constructorTermNode, ///
@@ -182,6 +199,10 @@ export function verifyTermAgainstConstructor(termNode, constructor, context) {
182
199
  export function verifyTermAsVariable(termNode, variables, context) {
183
200
  let termVerifiedAsVariable = false;
184
201
 
202
+ const termString = context.nodeAsString(termNode);
203
+
204
+ context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
205
+
185
206
  const variableNode = variableNodeQuery(termNode);
186
207
 
187
208
  if (variableNode !== null) {
@@ -38,7 +38,8 @@ export default function verifyTermAsConstructor(termNode, typeNode, fileContext)
38
38
  }
39
39
 
40
40
  if (termVerifiedAsConstructor) {
41
- const constructor = Constructor.fromTermNodeAndType(termNode, type);
41
+ const tokens = fileContext.getTokens(),
42
+ constructor = Constructor.fromTermNodeTypeAndTokens(termNode, type, tokens);
42
43
 
43
44
  fileContext.addConstructor(constructor);
44
45
  }