occam-verify-cli 1.0.165 → 1.0.168
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.
- package/lib/assignment/variable.js +3 -3
- package/lib/context/file.js +6 -4
- package/lib/context/release.js +32 -3
- package/lib/dom/assertion/type.js +10 -15
- package/lib/dom/combinator/bracketed.js +25 -4
- package/lib/dom/constructor.js +6 -29
- package/lib/dom/declaration/complexType.js +26 -60
- package/lib/dom/declaration/constructor.js +10 -15
- package/lib/dom/declaration/metavariable.js +10 -15
- package/lib/dom/declaration/type.js +20 -46
- package/lib/dom/declaration/variable.js +19 -19
- package/lib/dom/property.js +3 -3
- package/lib/dom/propertyRelation.js +3 -3
- package/lib/dom/term.js +4 -4
- package/lib/dom/type.js +80 -68
- package/lib/dom/variable.js +24 -52
- package/lib/equivalence.js +3 -3
- package/lib/node/assertion/contained.js +131 -0
- package/lib/node/assertion/defined.js +131 -0
- package/lib/node/assertion/property.js +131 -0
- package/lib/node/assertion/satisfies.js +131 -0
- package/lib/node/assertion/subproof.js +131 -0
- package/lib/node/assertion/type.js +131 -0
- package/lib/node/axiom.js +131 -0
- package/lib/node/combinator.js +131 -0
- package/lib/node/conclusion.js +131 -0
- package/lib/node/conjecture.js +131 -0
- package/lib/node/constructor.js +131 -0
- package/lib/node/declaration/combinator.js +131 -0
- package/lib/node/declaration/complexType.js +131 -0
- package/lib/node/declaration/constructor.js +131 -0
- package/lib/node/declaration/metavariable.js +131 -0
- package/lib/node/declaration/type.js +131 -0
- package/lib/node/declaration/variable.js +131 -0
- package/lib/node/declaration.js +131 -0
- package/lib/node/deduction.js +131 -0
- package/lib/node/derivation.js +131 -0
- package/lib/node/equality.js +131 -0
- package/lib/node/error.js +131 -0
- package/lib/node/frame.js +131 -0
- package/lib/node/judgement.js +131 -0
- package/lib/node/label.js +131 -0
- package/lib/node/lemma.js +131 -0
- package/lib/node/metaLemma.js +131 -0
- package/lib/node/metaType.js +131 -0
- package/lib/node/metatheorem.js +131 -0
- package/lib/node/metavariable.js +131 -0
- package/lib/node/parameter.js +131 -0
- package/lib/node/premise.js +131 -0
- package/lib/node/procedureCall.js +131 -0
- package/lib/node/proof.js +131 -0
- package/lib/node/property.js +131 -0
- package/lib/node/propertyRelation.js +131 -0
- package/lib/node/reference.js +131 -0
- package/lib/node/rule.js +131 -0
- package/lib/node/statement.js +131 -0
- package/lib/node/step.js +131 -0
- package/lib/node/subDerivation.js +131 -0
- package/lib/node/subproof.js +131 -0
- package/lib/node/supposition.js +131 -0
- package/lib/node/term.js +131 -0
- package/lib/node/theorem.js +131 -0
- package/lib/node/topLevelAssertion.js +131 -0
- package/lib/node/topLevelMetaAssertion.js +131 -0
- package/lib/node/type.js +131 -0
- package/lib/node/variable.js +131 -0
- package/lib/node.js +80 -0
- package/lib/nodeMap.js +80 -0
- package/lib/nominal/lexer.js +114 -0
- package/lib/nominal/parser.js +128 -0
- package/lib/ruleNames.js +198 -0
- package/lib/utilities/parser.js +21 -0
- package/lib/utilities/type.js +23 -0
- package/package.json +7 -6
- package/src/assignment/variable.js +4 -4
- package/src/context/file.js +10 -7
- package/src/context/release.js +8 -3
- package/src/dom/assertion/type.js +11 -16
- package/src/dom/combinator/bracketed.js +1 -6
- package/src/dom/constructor.js +5 -36
- package/src/dom/declaration/complexType.js +41 -52
- package/src/dom/declaration/constructor.js +11 -15
- package/src/dom/declaration/metavariable.js +11 -15
- package/src/dom/declaration/type.js +19 -44
- package/src/dom/declaration/variable.js +29 -21
- package/src/dom/property.js +2 -2
- package/src/dom/propertyRelation.js +2 -2
- package/src/dom/term.js +3 -3
- package/src/dom/type.js +120 -89
- package/src/dom/variable.js +27 -64
- package/src/equivalence.js +2 -2
- package/src/node/assertion/contained.js +5 -0
- package/src/node/assertion/defined.js +5 -0
- package/src/node/assertion/property.js +5 -0
- package/src/node/assertion/satisfies.js +5 -0
- package/src/node/assertion/subproof.js +5 -0
- package/src/node/assertion/type.js +5 -0
- package/src/node/axiom.js +5 -0
- package/src/node/combinator.js +5 -0
- package/src/node/conclusion.js +5 -0
- package/src/node/conjecture.js +5 -0
- package/src/node/constructor.js +5 -0
- package/src/node/declaration/combinator.js +5 -0
- package/src/node/declaration/complexType.js +5 -0
- package/src/node/declaration/constructor.js +5 -0
- package/src/node/declaration/metavariable.js +5 -0
- package/src/node/declaration/type.js +5 -0
- package/src/node/declaration/variable.js +5 -0
- package/src/node/declaration.js +5 -0
- package/src/node/deduction.js +5 -0
- package/src/node/derivation.js +5 -0
- package/src/node/equality.js +5 -0
- package/src/node/error.js +5 -0
- package/src/node/frame.js +5 -0
- package/src/node/judgement.js +5 -0
- package/src/node/label.js +5 -0
- package/src/node/lemma.js +5 -0
- package/src/node/metaLemma.js +5 -0
- package/src/node/metaType.js +5 -0
- package/src/node/metatheorem.js +5 -0
- package/src/node/metavariable.js +5 -0
- package/src/node/parameter.js +5 -0
- package/src/node/premise.js +5 -0
- package/src/node/procedureCall.js +5 -0
- package/src/node/proof.js +5 -0
- package/src/node/property.js +5 -0
- package/src/node/propertyRelation.js +5 -0
- package/src/node/reference.js +5 -0
- package/src/node/rule.js +5 -0
- package/src/node/statement.js +5 -0
- package/src/node/step.js +5 -0
- package/src/node/subDerivation.js +5 -0
- package/src/node/subproof.js +5 -0
- package/src/node/supposition.js +5 -0
- package/src/node/term.js +5 -0
- package/src/node/theorem.js +5 -0
- package/src/node/topLevelAssertion.js +5 -0
- package/src/node/topLevelMetaAssertion.js +5 -0
- package/src/node/type.js +5 -0
- package/src/node/variable.js +5 -0
- package/src/node.js +5 -0
- package/src/nodeMap.js +146 -0
- package/src/nominal/lexer.js +11 -0
- package/src/nominal/parser.js +37 -0
- package/src/ruleNames.js +48 -0
- package/src/utilities/parser.js +18 -0
- package/src/utilities/type.js +19 -0
package/src/dom/type.js
CHANGED
|
@@ -4,11 +4,12 @@ import { arrayUtilities } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import dom from "../dom";
|
|
6
6
|
|
|
7
|
-
import { PROVISIONAL } from "../constants";
|
|
8
7
|
import { domAssigned } from "../dom";
|
|
9
8
|
import { OBJECT_TYPE_NAME } from "../typeNames";
|
|
10
9
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
11
10
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
|
+
import { PROVISIONAL, PROVISIONALLY } from "../constants";
|
|
12
|
+
import { superTypesStringFromSuperTypes } from "../utilities/type";
|
|
12
13
|
import { superTypesFromJSON, propertiesFromJSON, superTypesToSuperTypesJSON, propertiesToPropertiesJSON } from "../utilities/json";
|
|
13
14
|
|
|
14
15
|
const { push, first } = arrayUtilities;
|
|
@@ -17,10 +18,11 @@ const typeAssertionTypeNodeQuery = nodeQuery("/typeAssertion/type"),
|
|
|
17
18
|
typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/type"),
|
|
18
19
|
propertyDeclarationNodesQuery = nodesQuery("/complexTypeDeclaration/propertyDeclaration"),
|
|
19
20
|
propertyDeclarationTypeNodeQuery = nodeQuery("/propertyDeclaration/type"),
|
|
21
|
+
variableDeclarationTypeNodeQuery = nodeQuery("/variableDeclaration/type"),
|
|
20
22
|
typeDeclarationSuperTypeNodesQuery = nodesQuery("/typeDeclaration|complexTypeDeclaration/types/type"),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
constructorDeclarationSuperTypeNodeQuery = nodeQuery("/constructorDeclaration/type"),
|
|
24
|
+
firstTypeDeclarationPrimaryKeywordTerminalNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/@primary-keyword[0]"),
|
|
25
|
+
lastVariableDeclarationSecondaryKeywordTerminalNodeQuery = nodeQuery("/variableDeclaration/@secondary-keyword[-1]");
|
|
24
26
|
|
|
25
27
|
class Type {
|
|
26
28
|
constructor(string, name, superTypes, properties, provisional) {
|
|
@@ -77,20 +79,6 @@ class Type {
|
|
|
77
79
|
return provisional;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
getSoleSuperType() {
|
|
81
|
-
let soleSuperType = null;
|
|
82
|
-
|
|
83
|
-
const superTypesLength = this.superTypes.length;
|
|
84
|
-
|
|
85
|
-
if (superTypesLength === 1) {
|
|
86
|
-
const firstSuperType = first(this.superTypes);
|
|
87
|
-
|
|
88
|
-
soleSuperType = firstSuperType; ///
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return soleSuperType;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
82
|
setString(string) {
|
|
95
83
|
this.string = string;
|
|
96
84
|
}
|
|
@@ -111,36 +99,22 @@ class Type {
|
|
|
111
99
|
this.provisional = provisional;
|
|
112
100
|
}
|
|
113
101
|
|
|
114
|
-
isRefined() {
|
|
115
|
-
let refined = false;
|
|
116
|
-
|
|
117
|
-
const soleSuperType = this.getSoleSuperType();
|
|
118
|
-
|
|
119
|
-
if (soleSuperType !== null) {
|
|
120
|
-
const soleSuperTypeNameMatchesName = soleSuperType.matchName(this.name);
|
|
121
|
-
|
|
122
|
-
refined = soleSuperTypeNameMatchesName; ///
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return refined;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
102
|
isBasic() {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const soleSuperType = this.getSoleSuperType();
|
|
132
|
-
|
|
133
|
-
if (soleSuperType !== null) {
|
|
134
|
-
const soleSuperTypeObjectType = (soleSuperType === objectType);
|
|
135
|
-
|
|
136
|
-
basic = soleSuperTypeObjectType; ///
|
|
137
|
-
}
|
|
103
|
+
const basic = basicFromSuperTypes(this.superTypes);
|
|
138
104
|
|
|
139
105
|
return basic;
|
|
140
106
|
}
|
|
141
107
|
|
|
142
108
|
isEqualTo(type) {
|
|
143
|
-
|
|
109
|
+
let equalTo = false;
|
|
110
|
+
|
|
111
|
+
if (this.type === type) {
|
|
112
|
+
equalTo = true;
|
|
113
|
+
} else {
|
|
114
|
+
if (type.name === null) {
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
}
|
|
144
118
|
|
|
145
119
|
return equalTo;
|
|
146
120
|
}
|
|
@@ -211,6 +185,20 @@ class Type {
|
|
|
211
185
|
return typeNameMatches;
|
|
212
186
|
}
|
|
213
187
|
|
|
188
|
+
matchProvisional(provisional) {
|
|
189
|
+
let provisionalMatches;
|
|
190
|
+
|
|
191
|
+
const provisionalA = provisional; ///
|
|
192
|
+
|
|
193
|
+
provisional = this.isProvisional();
|
|
194
|
+
|
|
195
|
+
const provisionalB = provisional; ///
|
|
196
|
+
|
|
197
|
+
provisionalMatches = (provisionalA === provisionalB);
|
|
198
|
+
|
|
199
|
+
return provisionalMatches;
|
|
200
|
+
}
|
|
201
|
+
|
|
214
202
|
toJSON() {
|
|
215
203
|
const propertiesJSON = propertiesToPropertiesJSON(this.properties),
|
|
216
204
|
superTypesJSON = superTypesToSuperTypesJSON(this.superTypes),
|
|
@@ -269,11 +257,11 @@ class Type {
|
|
|
269
257
|
}
|
|
270
258
|
|
|
271
259
|
static fromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
272
|
-
const
|
|
260
|
+
const properties = [],
|
|
261
|
+
provisional = provisionalFromTypeDeclarationNode(typeDeclarationNode, fileContext),
|
|
273
262
|
superTypes = superTypesFromTypeDeclarationNode(typeDeclarationNode, fileContext),
|
|
274
263
|
name = nameFromTypeDeclarationNode(typeDeclarationNode, fileContext),
|
|
275
264
|
string = stringFromNameAndSuperTypes(name, superTypes),
|
|
276
|
-
properties = [],
|
|
277
265
|
type = new Type(string, name, superTypes, properties, provisional);
|
|
278
266
|
|
|
279
267
|
return type;
|
|
@@ -288,9 +276,12 @@ class Type {
|
|
|
288
276
|
}
|
|
289
277
|
|
|
290
278
|
static fromVariableDeclarationNode(variableDeclarationNode, fileContext) {
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
279
|
+
const properties = null,
|
|
280
|
+
superTypes = null,
|
|
281
|
+
provisional = provisionalFromVariableDeclarationNode(variableDeclarationNode, fileContext),
|
|
282
|
+
name = nameFromVariableDeclarationNode(variableDeclarationNode, fileContext),
|
|
283
|
+
string = stringFromName(name),
|
|
284
|
+
type = new Type(string, name, superTypes, properties, provisional);
|
|
294
285
|
|
|
295
286
|
return type;
|
|
296
287
|
}
|
|
@@ -304,10 +295,10 @@ class Type {
|
|
|
304
295
|
}
|
|
305
296
|
|
|
306
297
|
static fromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
307
|
-
const
|
|
308
|
-
|
|
298
|
+
const properties = propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext),
|
|
299
|
+
provisional = provisionalFromTypeDeclarationNode(complexTypeDeclarationNode, fileContext),
|
|
309
300
|
superTypes = superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext),
|
|
310
|
-
name =
|
|
301
|
+
name = nameFromComplexTypeDeclaration(complexTypeDeclarationNode, fileContext),
|
|
311
302
|
string = stringFromNameAndSuperTypes(name, superTypes),
|
|
312
303
|
type = new Type(string, name, superTypes, properties, provisional);
|
|
313
304
|
|
|
@@ -317,6 +308,14 @@ class Type {
|
|
|
317
308
|
|
|
318
309
|
export default domAssigned(Type);
|
|
319
310
|
|
|
311
|
+
function stringFromName(name) {
|
|
312
|
+
const string = (name !== null) ?
|
|
313
|
+
name :
|
|
314
|
+
OBJECT_TYPE_NAME;
|
|
315
|
+
|
|
316
|
+
return string;
|
|
317
|
+
}
|
|
318
|
+
|
|
320
319
|
function typeFromTypeNode(typeNode, fileContext) {
|
|
321
320
|
let type;
|
|
322
321
|
|
|
@@ -337,13 +336,34 @@ function typeFromTypeNode(typeNode, fileContext) {
|
|
|
337
336
|
return type;
|
|
338
337
|
}
|
|
339
338
|
|
|
339
|
+
function basicFromSuperTypes(superTypes) {
|
|
340
|
+
let basic = false;
|
|
341
|
+
|
|
342
|
+
const superTypesLength = superTypes.length;
|
|
343
|
+
|
|
344
|
+
if (superTypesLength === 1) {
|
|
345
|
+
const firstSuperType = first(superTypes),
|
|
346
|
+
superType = firstSuperType; ///
|
|
347
|
+
|
|
348
|
+
if (superType === objectType) {
|
|
349
|
+
basic = true;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return basic;
|
|
354
|
+
}
|
|
355
|
+
|
|
340
356
|
function stringFromNameAndSuperTypes(name, superTypes) {
|
|
341
|
-
let string
|
|
357
|
+
let string;
|
|
342
358
|
|
|
343
|
-
|
|
359
|
+
if (name === null) {
|
|
360
|
+
string = OBJECT_TYPE_NAME; ///
|
|
361
|
+
} else {
|
|
362
|
+
const superTypesString = superTypesStringFromSuperTypes(superTypes);
|
|
344
363
|
|
|
345
|
-
|
|
346
|
-
|
|
364
|
+
string = (superTypesString !== null) ?
|
|
365
|
+
`${name}:${superTypesString}` :
|
|
366
|
+
name; ///
|
|
347
367
|
}
|
|
348
368
|
|
|
349
369
|
return string;
|
|
@@ -358,20 +378,28 @@ function nameFromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
|
358
378
|
return name;
|
|
359
379
|
}
|
|
360
380
|
|
|
361
|
-
function
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
381
|
+
function nameFromComplexTypeDeclaration(complexTypeDeclarationNode, fileContext) {
|
|
382
|
+
const typeDeclarationTypeNode = typeDeclarationTypeNodeQuery(complexTypeDeclarationNode),
|
|
383
|
+
typeNode = typeDeclarationTypeNode, ///
|
|
384
|
+
typeName = typeNameFromTypeNode(typeNode),
|
|
385
|
+
name = typeName; ///
|
|
386
|
+
|
|
387
|
+
return name;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function nameFromVariableDeclarationNode(variableDeclarationNode, fileContext) {
|
|
391
|
+
let name = null;
|
|
365
392
|
|
|
366
|
-
|
|
367
|
-
superTypeName :
|
|
368
|
-
`${superTypesString}, ${superTypeName}`;
|
|
369
|
-
}
|
|
393
|
+
const variableDeclarationTypeNode = variableDeclarationTypeNodeQuery(variableDeclarationNode);
|
|
370
394
|
|
|
371
|
-
|
|
372
|
-
|
|
395
|
+
if (variableDeclarationTypeNode !== null) {
|
|
396
|
+
const typeNode = variableDeclarationTypeNode, ///
|
|
397
|
+
typeName = typeNameFromTypeNode(typeNode);
|
|
373
398
|
|
|
374
|
-
|
|
399
|
+
name = typeName; ///
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return name;
|
|
375
403
|
}
|
|
376
404
|
|
|
377
405
|
function superTypesFromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
@@ -392,21 +420,27 @@ function superTypesFromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
|
392
420
|
}
|
|
393
421
|
|
|
394
422
|
function provisionalFromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
395
|
-
const
|
|
396
|
-
content =
|
|
423
|
+
const firstTypeDeclarationPrimaryKeywordTerminalNode = firstTypeDeclarationPrimaryKeywordTerminalNodeQuery(typeDeclarationNode),
|
|
424
|
+
content = firstTypeDeclarationPrimaryKeywordTerminalNode.getContent(),
|
|
397
425
|
contentProvisional = (content === PROVISIONAL),
|
|
398
426
|
provisional = contentProvisional; ///
|
|
399
427
|
|
|
400
428
|
return provisional;
|
|
401
429
|
}
|
|
402
430
|
|
|
403
|
-
function
|
|
404
|
-
|
|
405
|
-
typeNode = typeDeclarationTypeNode, ///
|
|
406
|
-
typeName = typeNameFromTypeNode(typeNode),
|
|
407
|
-
name = typeName; ///
|
|
431
|
+
function provisionalFromVariableDeclarationNode(variableDeclarationNode, fileContext) {
|
|
432
|
+
let provisional = false;
|
|
408
433
|
|
|
409
|
-
|
|
434
|
+
const lastVariableDeclarationSecondaryKeywordTerminalNode = lastVariableDeclarationSecondaryKeywordTerminalNodeQuery(variableDeclarationNode);
|
|
435
|
+
|
|
436
|
+
if (lastVariableDeclarationSecondaryKeywordTerminalNode !== null) {
|
|
437
|
+
const content = lastVariableDeclarationSecondaryKeywordTerminalNode.getContent(),
|
|
438
|
+
contentProvisional = (content === PROVISIONALLY);
|
|
439
|
+
|
|
440
|
+
provisional = contentProvisional; ///
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return provisional;
|
|
410
444
|
}
|
|
411
445
|
|
|
412
446
|
function superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
@@ -445,24 +479,21 @@ class ObjectType extends Type {
|
|
|
445
479
|
return properties;
|
|
446
480
|
}
|
|
447
481
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
return json;
|
|
461
|
-
}
|
|
482
|
+
// matchName(name) {
|
|
483
|
+
// const nameMatches = ((name === null) || (name === OBJECT_TYPE_NAME));
|
|
484
|
+
//
|
|
485
|
+
// return nameMatches;
|
|
486
|
+
// }
|
|
487
|
+
//
|
|
488
|
+
// matchTypeName(typeName) {
|
|
489
|
+
// const typeNameMatches = ((typeName === null) || (typeName === OBJECT_TYPE_NAME));
|
|
490
|
+
//
|
|
491
|
+
// return typeNameMatches;
|
|
492
|
+
// }
|
|
462
493
|
|
|
463
494
|
static fromNothing() {
|
|
464
|
-
const name =
|
|
465
|
-
string =
|
|
495
|
+
const name = null,
|
|
496
|
+
string = OBJECT_TYPE_NAME, ///
|
|
466
497
|
superTypes = [],
|
|
467
498
|
properties = [],
|
|
468
499
|
provisional = false,
|
package/src/dom/variable.js
CHANGED
|
@@ -7,22 +7,20 @@ 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
|
|
10
|
+
import { EMPTY_STRING } 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
|
-
variableDeclarationVariableNodeQuery = nodeQuery("/variableDeclaration/variable")
|
|
17
|
-
lastSecondaryKeywordTerminalNodeQuery = nodeQuery("/variableDeclaration/@secondary-keyword[-1]");
|
|
16
|
+
variableDeclarationVariableNodeQuery = nodeQuery("/variableDeclaration/variable");
|
|
18
17
|
|
|
19
18
|
export default domAssigned(class Variable {
|
|
20
|
-
constructor(string, node, name, type,
|
|
19
|
+
constructor(string, node, name, type, propertyRelations) {
|
|
21
20
|
this.string = string;
|
|
22
21
|
this.node = node;
|
|
23
22
|
this.name = name;
|
|
24
23
|
this.type = type;
|
|
25
|
-
this.provisional = provisional;
|
|
26
24
|
this.propertyRelations = propertyRelations;
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -42,10 +40,6 @@ export default domAssigned(class Variable {
|
|
|
42
40
|
return this.type;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
isProvisional() {
|
|
46
|
-
return this.provisional;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
getPropertyRelations() {
|
|
50
44
|
return this.propertyRelations;
|
|
51
45
|
}
|
|
@@ -54,10 +48,6 @@ export default domAssigned(class Variable {
|
|
|
54
48
|
this.type = type;
|
|
55
49
|
}
|
|
56
50
|
|
|
57
|
-
setProvisional(provisional) {
|
|
58
|
-
this.provisional = provisional;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
51
|
isEqualTo(variable) {
|
|
62
52
|
const variableString = variable.getString(),
|
|
63
53
|
equalTo = (variableString === this.string);
|
|
@@ -124,26 +114,22 @@ export default domAssigned(class Variable {
|
|
|
124
114
|
verifyType(fileContext) {
|
|
125
115
|
let typeVerified = false;
|
|
126
116
|
|
|
127
|
-
|
|
128
|
-
typeVerified = true;
|
|
129
|
-
} else {
|
|
130
|
-
const typeName = this.type.getName();
|
|
117
|
+
const typeString = this.type.getString();
|
|
131
118
|
|
|
132
|
-
|
|
119
|
+
fileContext.trace(`Verifying the '${typeString}' type...`);
|
|
133
120
|
|
|
134
|
-
|
|
121
|
+
const type = fileContext.findTypeByTypeName(typeString);
|
|
135
122
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
123
|
+
if (type === null) {
|
|
124
|
+
fileContext.debug(`The '${typeString}' type is not present.`);
|
|
125
|
+
} else {
|
|
126
|
+
this.type = type; ///
|
|
140
127
|
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
typeVerified = true;
|
|
129
|
+
}
|
|
143
130
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
131
|
+
if (typeVerified) {
|
|
132
|
+
fileContext.debug(`...verified the '${typeString}' type.`);
|
|
147
133
|
}
|
|
148
134
|
|
|
149
135
|
return typeVerified;
|
|
@@ -215,9 +201,8 @@ export default domAssigned(class Variable {
|
|
|
215
201
|
node = variableNode,
|
|
216
202
|
name = variableName, ///
|
|
217
203
|
type = typeFromJSON(json, fileContext),
|
|
218
|
-
provisional = null,
|
|
219
204
|
propertyRelations = [],
|
|
220
|
-
variable = new Variable(string, node, name, type,
|
|
205
|
+
variable = new Variable(string, node, name, type, propertyRelations);
|
|
221
206
|
|
|
222
207
|
return variable;
|
|
223
208
|
}
|
|
@@ -228,9 +213,10 @@ export default domAssigned(class Variable {
|
|
|
228
213
|
const termVariableNode = termVariableNodeQuery(termNode);
|
|
229
214
|
|
|
230
215
|
if (termVariableNode !== null) {
|
|
231
|
-
const variableNode = termVariableNode
|
|
216
|
+
const variableNode = termVariableNode, ///
|
|
217
|
+
type = null;
|
|
232
218
|
|
|
233
|
-
variable =
|
|
219
|
+
variable = variableFromVariableNodeAndType(variableNode, type, context);
|
|
234
220
|
}
|
|
235
221
|
|
|
236
222
|
return variable;
|
|
@@ -240,7 +226,9 @@ export default domAssigned(class Variable {
|
|
|
240
226
|
let variable = null;
|
|
241
227
|
|
|
242
228
|
if (variableNode !== null) {
|
|
243
|
-
|
|
229
|
+
const type = null;
|
|
230
|
+
|
|
231
|
+
variable = variableFromVariableNodeAndType(variableNode, type, context);
|
|
244
232
|
}
|
|
245
233
|
|
|
246
234
|
return variable;
|
|
@@ -250,9 +238,7 @@ export default domAssigned(class Variable {
|
|
|
250
238
|
let variable = null;
|
|
251
239
|
|
|
252
240
|
if (variableNode !== null) {
|
|
253
|
-
variable =
|
|
254
|
-
|
|
255
|
-
variable.setType(type);
|
|
241
|
+
variable = variableFromVariableNodeAndType(variableNode, type, context);
|
|
256
242
|
}
|
|
257
243
|
|
|
258
244
|
return variable;
|
|
@@ -264,13 +250,8 @@ export default domAssigned(class Variable {
|
|
|
264
250
|
variableNode = variableDeclarationVariableNode, ///
|
|
265
251
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
266
252
|
context = localContext, ///
|
|
267
|
-
variable = variableFromVariableNode(variableNode, context),
|
|
268
253
|
type = Type.fromVariableDeclarationNode(variableDeclarationNode, fileContext),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
variable.setType(type);
|
|
272
|
-
|
|
273
|
-
variable.setProvisional(provisional);
|
|
254
|
+
variable = variableFromVariableNodeAndType(variableNode, type, context);
|
|
274
255
|
|
|
275
256
|
return variable;
|
|
276
257
|
}
|
|
@@ -280,8 +261,7 @@ export default domAssigned(class Variable {
|
|
|
280
261
|
|
|
281
262
|
const node = variable.getNode(),
|
|
282
263
|
name = variable.getName(),
|
|
283
|
-
type = variable.getType()
|
|
284
|
-
provisional = variable.isProvisional();
|
|
264
|
+
type = variable.getType();
|
|
285
265
|
|
|
286
266
|
propertyRelations = variable.getPropertyRelations();
|
|
287
267
|
|
|
@@ -292,22 +272,20 @@ export default domAssigned(class Variable {
|
|
|
292
272
|
|
|
293
273
|
const string = stringFromNameAndPropertyRelations(name, propertyRelations);
|
|
294
274
|
|
|
295
|
-
variable = new Variable(string, node, name, type,
|
|
275
|
+
variable = new Variable(string, node, name, type, propertyRelations);
|
|
296
276
|
|
|
297
277
|
return variable;
|
|
298
278
|
}
|
|
299
279
|
});
|
|
300
280
|
|
|
301
|
-
function
|
|
281
|
+
function variableFromVariableNodeAndType(variableNode, type, context) {
|
|
302
282
|
const { Variable } = dom,
|
|
303
283
|
node = variableNode, ///
|
|
304
284
|
variableName = variableNameFromVariableNode(variableNode),
|
|
305
285
|
string = context.nodeAsString(node),
|
|
306
286
|
name = variableName, ///
|
|
307
|
-
type = null,
|
|
308
|
-
provisional = null,
|
|
309
287
|
propertyRelations = [],
|
|
310
|
-
variable = new Variable(string, node, name, type,
|
|
288
|
+
variable = new Variable(string, node, name, type, propertyRelations);
|
|
311
289
|
|
|
312
290
|
return variable;
|
|
313
291
|
}
|
|
@@ -324,18 +302,3 @@ function stringFromNameAndPropertyRelations(name, propertyRelations) {
|
|
|
324
302
|
|
|
325
303
|
return string;
|
|
326
304
|
}
|
|
327
|
-
|
|
328
|
-
function provisionalFromVariableDeclarationNode(variableDeclarationNode, fileContext) {
|
|
329
|
-
let provisional = false;
|
|
330
|
-
|
|
331
|
-
const lastSecondaryKeywordTerminalNode = lastSecondaryKeywordTerminalNodeQuery(variableDeclarationNode);
|
|
332
|
-
|
|
333
|
-
if (lastSecondaryKeywordTerminalNode !== null) {
|
|
334
|
-
const content = lastSecondaryKeywordTerminalNode.getContent(),
|
|
335
|
-
contentProvisionally = (content === PROVISIONALLY);
|
|
336
|
-
|
|
337
|
-
provisional = contentProvisionally; ///
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return provisional;
|
|
341
|
-
}
|
package/src/equivalence.js
CHANGED
|
@@ -217,9 +217,9 @@ export default class Equivalence {
|
|
|
217
217
|
}, null);
|
|
218
218
|
|
|
219
219
|
const type = this.getType(),
|
|
220
|
-
|
|
220
|
+
typeString = type.getString();
|
|
221
221
|
|
|
222
|
-
string = `${string}:${
|
|
222
|
+
string = `${string}:${typeString}`;
|
|
223
223
|
|
|
224
224
|
return string;
|
|
225
225
|
}
|