occam-verify-cli 1.0.32 → 1.0.34

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.
@@ -7,21 +7,22 @@ import TermSubstitution from "../substitution/term";
7
7
  import { nodeQuery } from "../utilities/query";
8
8
  import { objectType } from "./type";
9
9
  import { domAssigned } from "../dom";
10
- import { EMPTY_STRING } from "../constants";
10
+ import { EMPTY_STRING, PROVISIONALLY } from "../constants";
11
11
  import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
12
12
  import { variableNameFromVariableNode } from "../utilities/name";
13
13
  import { variableNodeFromVariableString } from "../context/partial/variable";
14
14
 
15
15
  const termVariableNodeQuery = nodeQuery("/term/variable!"),
16
- variableDeclarationTypeNodeQuery = nodeQuery("/variableDeclaration/type"),
17
- variableDeclarationVariableNodeQuery = nodeQuery("/variableDeclaration/variable");
16
+ variableDeclarationVariableNodeQuery = nodeQuery("/variableDeclaration/variable"),
17
+ lastSecondaryKeywordTerminalNodeQuery = nodeQuery("/variableDeclaration/@secondary-keyword[-1]")
18
18
 
19
19
  export default domAssigned(class Variable {
20
- constructor(string, node, name, type, propertyRelations) {
20
+ constructor(string, node, name, type, provisional, propertyRelations) {
21
21
  this.string = string;
22
22
  this.node = node;
23
23
  this.name = name;
24
24
  this.type = type;
25
+ this.provisional = provisional;
25
26
  this.propertyRelations = propertyRelations;
26
27
  }
27
28
 
@@ -41,6 +42,10 @@ export default domAssigned(class Variable {
41
42
  return this.type;
42
43
  }
43
44
 
45
+ isProvisional() {
46
+ return this.provisional;
47
+ }
48
+
44
49
  getPropertyRelations() {
45
50
  return this.propertyRelations;
46
51
  }
@@ -206,8 +211,9 @@ export default domAssigned(class Variable {
206
211
  node = variableNode,
207
212
  name = variableName, ///
208
213
  type = typeFromJSON(json, fileContext),
214
+ provisional = null,
209
215
  propertyRelations = [],
210
- variable = new Variable(string, node, name, type, propertyRelations);
216
+ variable = new Variable(string, node, name, type, provisional, propertyRelations);
211
217
 
212
218
  return variable;
213
219
  }
@@ -224,9 +230,10 @@ export default domAssigned(class Variable {
224
230
  string = context.nodeAsString(node),
225
231
  name = variableName, ///
226
232
  type = null,
233
+ provisional = null,
227
234
  propertyRelations = [];
228
235
 
229
- variable = new Variable(string, node, name, type, propertyRelations);
236
+ variable = new Variable(string, node, name, type, provisional, propertyRelations);
230
237
  }
231
238
 
232
239
  return variable;
@@ -241,9 +248,10 @@ export default domAssigned(class Variable {
241
248
  string = context.nodeAsString(node),
242
249
  name = variableName, ///
243
250
  type = null,
251
+ provisional = null,
244
252
  propertyRelations = [];
245
253
 
246
- variable = new Variable(string, node, name, type, propertyRelations);
254
+ variable = new Variable(string, node, name, type, provisional, propertyRelations);
247
255
  }
248
256
 
249
257
  return variable;
@@ -257,25 +265,28 @@ export default domAssigned(class Variable {
257
265
  variableName = variableNameFromVariableNode(variableNode),
258
266
  string = context.nodeAsString(node),
259
267
  name = variableName, ///
268
+ provisional = null,
260
269
  propertyRelations = [];
261
270
 
262
- variable = new Variable(string, node, name, type, propertyRelations);
271
+ variable = new Variable(string, node, name, type, provisional, propertyRelations);
263
272
  }
264
273
 
265
274
  return variable;
266
275
  }
267
276
 
268
277
  static fromVariableDeclarationNode(variableDeclarationNode, fileContext) {
269
- const variableDeclarationVariableNode = variableDeclarationVariableNodeQuery(variableDeclarationNode),
278
+ const { Type } = dom,
279
+ variableDeclarationVariableNode = variableDeclarationVariableNodeQuery(variableDeclarationNode),
270
280
  variableNode = variableDeclarationVariableNode, ///
271
281
  variableName = variableNameFromVariableNode(variableNode),
272
282
  variableString = fileContext.nodeAsString(variableNode),
273
283
  string = variableString, ///
274
284
  node = variableNode, ///
275
285
  name = variableName, ///
276
- type = typeFromVariableDeclarationNode(variableDeclarationNode, fileContext),
286
+ type = Type.fromVariableDeclarationNode(variableDeclarationNode, fileContext),
287
+ provisional = provisionalFromVariableDeclarationNode(variableDeclarationNode, fileContext),
277
288
  propertyRelations = [],
278
- variable = new Variable(string, node, name, type, propertyRelations);
289
+ variable = new Variable(string, node, name, type, provisional, propertyRelations);
279
290
 
280
291
  return variable;
281
292
  }
@@ -285,7 +296,8 @@ export default domAssigned(class Variable {
285
296
 
286
297
  const node = variable.getNode(),
287
298
  name = variable.getName(),
288
- type = variable.getType();
299
+ type = variable.getType(),
300
+ provisional = variable.isProvisional();
289
301
 
290
302
  propertyRelations = variable.getPropertyRelations();
291
303
 
@@ -296,22 +308,12 @@ export default domAssigned(class Variable {
296
308
 
297
309
  const string = stringFromNameAndPropertyRelations(name, propertyRelations);
298
310
 
299
- variable = new Variable(string, node, name, type, propertyRelations);
311
+ variable = new Variable(string, node, name, type, provisional, propertyRelations);
300
312
 
301
313
  return variable;
302
314
  }
303
315
  });
304
316
 
305
- function typeFromVariableDeclarationNode(variableDeclarationNode, fileContext) {
306
- const { Type } = dom,
307
- variableDeclarationTypeNode = variableDeclarationTypeNodeQuery(variableDeclarationNode),
308
- typeNode = variableDeclarationTypeNode, ///
309
- context = LocalContext.fromFileContext(fileContext),
310
- type = Type.fromTypeNode(typeNode, context);
311
-
312
- return type;
313
- }
314
-
315
317
  function stringFromNameAndPropertyRelations(name, propertyRelations) {
316
318
  const propertyRelationsString = propertyRelations.reduce((propertyRelationsString, propertyRelation) => {
317
319
  const propertyRelationString = propertyRelation.getString();
@@ -323,4 +325,19 @@ function stringFromNameAndPropertyRelations(name, propertyRelations) {
323
325
  string = `${name}${propertyRelationsString}`;
324
326
 
325
327
  return string;
326
- }
328
+ }
329
+
330
+ function provisionalFromVariableDeclarationNode(variableDeclarationNode, fileContext) {
331
+ let provisional = false;
332
+
333
+ const lastSecondaryKeywordTerminalNode = lastSecondaryKeywordTerminalNodeQuery(variableDeclarationNode);
334
+
335
+ if (lastSecondaryKeywordTerminalNode !== null) {
336
+ const content = lastSecondaryKeywordTerminalNode.getContent(),
337
+ contentProvisionally = (content === PROVISIONALLY);
338
+
339
+ provisional = contentProvisionally; ///
340
+ }
341
+
342
+ return provisional;
343
+ }