occam-verify-cli 0.0.1264 → 0.0.1266
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/dom/assertion/type.js +3 -3
- package/lib/dom/combinator.js +1 -15
- package/lib/dom/constructor.js +2 -17
- package/lib/dom/declaration/combinator.js +24 -4
- package/lib/dom/declaration/complexType.js +32 -3
- package/lib/dom/declaration/constructor.js +55 -5
- package/lib/dom/declaration/metavariable.js +55 -4
- package/lib/dom/declaration/type.js +32 -3
- package/lib/dom/declaration/variable.js +70 -6
- package/lib/dom/metavariable.js +2 -58
- package/lib/dom/property.js +10 -18
- package/lib/dom/statement.js +1 -15
- package/lib/dom/term.js +1 -43
- package/lib/dom/type.js +85 -30
- package/lib/dom/variable.js +2 -26
- package/lib/index.js +2 -1
- package/lib/utilities/customGrammar.js +2 -2
- package/lib/utilities/json.js +12 -1
- package/package.json +9 -9
- package/src/dom/assertion/type.js +2 -2
- package/src/dom/combinator.js +0 -18
- package/src/dom/constructor.js +1 -20
- package/src/dom/declaration/combinator.js +24 -3
- package/src/dom/declaration/complexType.js +43 -2
- package/src/dom/declaration/constructor.js +64 -4
- package/src/dom/declaration/metavariable.js +68 -3
- package/src/dom/declaration/type.js +43 -2
- package/src/dom/declaration/variable.js +86 -5
- package/src/dom/metavariable.js +1 -73
- package/src/dom/property.js +21 -22
- package/src/dom/statement.js +0 -18
- package/src/dom/term.js +0 -53
- package/src/dom/type.js +51 -37
- package/src/dom/variable.js +1 -33
- package/src/index.js +1 -0
- package/src/utilities/customGrammar.js +1 -2
- package/src/utilities/json.js +12 -0
package/src/dom/type.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
|
|
4
5
|
import { domAssigned } from "../dom";
|
|
5
6
|
import { OBJECT_TYPE_NAME } from "../typeNames";
|
|
6
7
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
7
|
-
import {
|
|
8
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
9
|
+
import { superTypeFromJSON, superTypeToSuperTypeJSON, propertiesToPropertiesJSON } from "../utilities/json";
|
|
8
10
|
|
|
9
|
-
const typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
|
|
10
|
-
|
|
11
|
+
const typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/type[0]"),
|
|
12
|
+
propertyDeclarationNodesQuery = nodesQuery("/complexTypeDeclaration/propertyDeclaration"),
|
|
13
|
+
typeDeclarationSuperTypeNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/type[1]");
|
|
11
14
|
|
|
12
15
|
class Type {
|
|
13
16
|
constructor(string, name, superType, properties) {
|
|
@@ -33,6 +36,22 @@ class Type {
|
|
|
33
36
|
return this.properties;
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
setString(string) {
|
|
40
|
+
this.string = string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setName(name) {
|
|
44
|
+
this.name = name;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setSuperType(superType) {
|
|
48
|
+
this.superType = superType;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setProperties(properties) {
|
|
52
|
+
this.properties = properties;
|
|
53
|
+
}
|
|
54
|
+
|
|
36
55
|
isEqualTo(type) {
|
|
37
56
|
const equalTo = (this === type);
|
|
38
57
|
|
|
@@ -107,39 +126,6 @@ class Type {
|
|
|
107
126
|
return typeNodeMatches;
|
|
108
127
|
}
|
|
109
128
|
|
|
110
|
-
verifyWhenDeclared(fileContext) {
|
|
111
|
-
let verifiedWhenDeclared = false;
|
|
112
|
-
|
|
113
|
-
const typeString = this.string; ///
|
|
114
|
-
|
|
115
|
-
fileContext.trace(`Verifying the '${typeString}' type when declared...`);
|
|
116
|
-
|
|
117
|
-
const typePresent = fileContext.isTypePresentByTypeName(this.name);
|
|
118
|
-
|
|
119
|
-
if (typePresent) {
|
|
120
|
-
fileContext.debug(`The type '${typeString}' has already been declared.`);
|
|
121
|
-
} else {
|
|
122
|
-
const superTypeName = this.superType.getName(),
|
|
123
|
-
superType = fileContext.findTypeByTypeName(superTypeName);
|
|
124
|
-
|
|
125
|
-
if (superType === null) {
|
|
126
|
-
const superTypeString = this.superType.getString();
|
|
127
|
-
|
|
128
|
-
fileContext.debug(`The super-type '${superTypeString}' is not present.`);
|
|
129
|
-
} else {
|
|
130
|
-
this.superType = superType;
|
|
131
|
-
|
|
132
|
-
verifiedWhenDeclared = true;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (verifiedWhenDeclared) {
|
|
137
|
-
fileContext.debug(`...verified the '${typeString}' type when declared.`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return verifiedWhenDeclared;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
129
|
toJSON() {
|
|
144
130
|
const propertiesJSON = propertiesToPropertiesJSON(this.properties),
|
|
145
131
|
superTypeJSON = superTypeToSuperTypeJSON(this.superType),
|
|
@@ -240,6 +226,34 @@ function superTypeFromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
|
240
226
|
return superType;
|
|
241
227
|
}
|
|
242
228
|
|
|
229
|
+
function typeNameFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
230
|
+
const typeDeclarationTypeNode = typeDeclarationTypeNodeQuery(complexTypeDeclarationNode),
|
|
231
|
+
typeNode = typeDeclarationTypeNode, ///
|
|
232
|
+
typeName = typeNameFromTypeNode(typeNode);
|
|
233
|
+
|
|
234
|
+
return typeName;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function superTypeFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
238
|
+
const typeDeclarationSuperTypeNode = typeDeclarationSuperTypeNodeQuery(complexTypeDeclarationNode),
|
|
239
|
+
superTypeNode = typeDeclarationSuperTypeNode, ///
|
|
240
|
+
superType = Type.fromTypeNode(superTypeNode);
|
|
241
|
+
|
|
242
|
+
return superType;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
246
|
+
const propertyDeclarationNodes = propertyDeclarationNodesQuery(complexTypeDeclarationNode),
|
|
247
|
+
properties = propertyDeclarationNodes.map((propertyDeclarationNode) => {
|
|
248
|
+
const { Property } = dom,
|
|
249
|
+
property = Property.fromPropertyDeclarationNode(propertyDeclarationNode, fileContext);
|
|
250
|
+
|
|
251
|
+
return property;
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return properties;
|
|
255
|
+
}
|
|
256
|
+
|
|
243
257
|
class ObjectType extends Type {
|
|
244
258
|
toJSON() {
|
|
245
259
|
const superType = null,
|
package/src/dom/variable.js
CHANGED
|
@@ -119,7 +119,7 @@ export default domAssigned(class Variable {
|
|
|
119
119
|
const type = fileContext.findTypeByTypeName(typeName);
|
|
120
120
|
|
|
121
121
|
if (type === null) {
|
|
122
|
-
fileContext.debug(`The '${typeName}' type is
|
|
122
|
+
fileContext.debug(`The '${typeName}' type is not present.`);
|
|
123
123
|
} else {
|
|
124
124
|
this.type = type; ///
|
|
125
125
|
|
|
@@ -134,38 +134,6 @@ export default domAssigned(class Variable {
|
|
|
134
134
|
return typeVerified;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
verifyWhenDeclared(fileContext) {
|
|
138
|
-
let verifiedWhenDeclared;
|
|
139
|
-
|
|
140
|
-
const variableString = this.string; ///
|
|
141
|
-
|
|
142
|
-
fileContext.trace(`Verifying the '${variableString}' variable when declared...`);
|
|
143
|
-
|
|
144
|
-
const variableName = this.name, ///
|
|
145
|
-
variablePresent = fileContext.isVariablePresentByVariableName(variableName);
|
|
146
|
-
|
|
147
|
-
if (variablePresent) {
|
|
148
|
-
fileContext.debug(`The '${variableName}' variable has already been declared.`);
|
|
149
|
-
} else {
|
|
150
|
-
const metavariableName = this.name, ///
|
|
151
|
-
metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
152
|
-
|
|
153
|
-
if (metavariablePresent) {
|
|
154
|
-
fileContext.debug(`A '${metavariableName}' variable has already been declared.`);
|
|
155
|
-
} else {
|
|
156
|
-
const typeVerified = this.verifyType(fileContext);
|
|
157
|
-
|
|
158
|
-
verifiedWhenDeclared = typeVerified; ///
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (verifiedWhenDeclared) {
|
|
163
|
-
fileContext.debug(`...verified the '${variableString}' variable when declared.`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return verifiedWhenDeclared;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
137
|
unifyTerm(term, substitutions, generalContext, specificContext) {
|
|
170
138
|
let termUnified = false;
|
|
171
139
|
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import Equality from "./dom/equality";
|
|
|
15
15
|
import MetaType from "./dom/metaType";
|
|
16
16
|
import Subproof from "./dom/subproof";
|
|
17
17
|
import Variable from "./dom/variable";
|
|
18
|
+
import Property from "./dom/property";
|
|
18
19
|
import Parameter from "./dom/parameter";
|
|
19
20
|
import ProofStep from "./dom/proofStep";
|
|
20
21
|
import Reference from "./dom/reference";
|
|
@@ -7,9 +7,8 @@ export function customGrammarFromNameAndEntries(name, entries) {
|
|
|
7
7
|
statementBNF = entries.getStatementBNF(),
|
|
8
8
|
typePattern = entries.getTypePattern(),
|
|
9
9
|
symbolPattern = entries.getSymbolPattern(),
|
|
10
|
-
propertyPattern = entries.getPropertyPattern(),
|
|
11
10
|
operatorPattern = entries.getOperatorPattern(),
|
|
12
|
-
customGrammar = CustomGrammar.
|
|
11
|
+
customGrammar = CustomGrammar.fromNameTermBNFStatementBNFTypePatternSymbolPatternAndOperatorPattern(name, termBNF, statementBNF, typePattern, symbolPattern, operatorPattern);
|
|
13
12
|
|
|
14
13
|
return customGrammar;
|
|
15
14
|
}
|
package/src/utilities/json.js
CHANGED
|
@@ -547,6 +547,18 @@ export function parametersToParametersJSON(parameters) {
|
|
|
547
547
|
return parametersJSON;
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
+
export function propertiesToPropertiesJSON(properties) {
|
|
551
|
+
const propertiesJSON = properties.map((property) => {
|
|
552
|
+
const propertyJSON = property.toJSON();
|
|
553
|
+
|
|
554
|
+
property = propertyJSON; ///
|
|
555
|
+
|
|
556
|
+
return property;
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
return propertiesJSON;
|
|
560
|
+
}
|
|
561
|
+
|
|
550
562
|
export function conjecturesToConjecturesJSON(conjectures) {
|
|
551
563
|
const conjecturesJSON = conjectures.map((conjecture) => {
|
|
552
564
|
const conjectureJSON = conjecture.toJSON();
|