occam-verify-cli 1.0.890 → 1.0.892
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/element/declaration/complexType.js +92 -133
- package/lib/element/declaration/property.js +79 -0
- package/lib/element/declaration/simpleType.js +7 -8
- package/lib/element/declaration/typePrefix.js +2 -27
- package/lib/element/metavariable.js +4 -4
- package/lib/element/property.js +72 -1
- package/lib/element/statement.js +2 -2
- package/lib/element/substitution/statement.js +2 -2
- package/lib/element/typePrefix.js +26 -1
- package/lib/preamble.js +2 -1
- package/lib/utilities/element.js +37 -8
- package/lib/utilities/string.js +20 -2
- package/package.json +1 -1
- package/src/element/declaration/complexType.js +109 -166
- package/src/element/declaration/property.js +96 -0
- package/src/element/declaration/simpleType.js +7 -13
- package/src/element/declaration/typePrefix.js +1 -38
- package/src/element/metavariable.js +3 -3
- package/src/element/property.js +103 -0
- package/src/element/statement.js +1 -1
- package/src/element/substitution/statement.js +1 -1
- package/src/element/typePrefix.js +36 -0
- package/src/preamble.js +1 -0
- package/src/utilities/element.js +56 -16
- package/src/utilities/string.js +37 -12
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Declaration from "../declaration";
|
|
4
|
+
|
|
5
|
+
import { define } from "../../elements";
|
|
6
|
+
|
|
7
|
+
export default define(class PropertyDeclaration extends Declaration {
|
|
8
|
+
constructor(context, string, node, lineIndex, property, type) {
|
|
9
|
+
super(context, string, node, lineIndex);
|
|
10
|
+
|
|
11
|
+
this.property = property;
|
|
12
|
+
this.type = type;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getProperty() {
|
|
16
|
+
return this.property;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getType() {
|
|
20
|
+
return this.type;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async verify(properties, context) {
|
|
24
|
+
let verifies = false;
|
|
25
|
+
|
|
26
|
+
await this.break(context);
|
|
27
|
+
|
|
28
|
+
const propertyDeclarationString = this.getString(); ///
|
|
29
|
+
|
|
30
|
+
context.trace(`Verifying the '${propertyDeclarationString}' property declaration...`);
|
|
31
|
+
|
|
32
|
+
if (this.property !== null) {
|
|
33
|
+
const typeVerifies = this.verifyType(context);
|
|
34
|
+
|
|
35
|
+
if (typeVerifies) {
|
|
36
|
+
const propertyVerifies = this.verifyProperty(properties, context);
|
|
37
|
+
|
|
38
|
+
if (propertyVerifies) {
|
|
39
|
+
verifies = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
context.debug(`Unable to verify the '${propertyDeclarationString}' property declaration because it is nonsense.`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (verifies) {
|
|
47
|
+
context.debug(`...verified the '${propertyDeclarationString}' property declaration.`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return verifies;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
verifyType(context) {
|
|
54
|
+
let typeVerifies = false;
|
|
55
|
+
|
|
56
|
+
const typeString = this.type.getString(),
|
|
57
|
+
propertyDeclarationString = this.getString(); ///
|
|
58
|
+
|
|
59
|
+
context.trace(`Verifying the '${propertyDeclarationString}' property declaration's '${typeString}' type...`);
|
|
60
|
+
|
|
61
|
+
const typeName = this.type.getName(),
|
|
62
|
+
includeRelease = true,
|
|
63
|
+
typePresent = context.isTypePresentByTypeName(typeName, includeRelease);
|
|
64
|
+
|
|
65
|
+
if (typePresent) {
|
|
66
|
+
typeVerifies = true;
|
|
67
|
+
} else {
|
|
68
|
+
context.debug(`The '${typeString}' type is not present.`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (typeVerifies) {
|
|
72
|
+
context.debug(`...verified the '${propertyDeclarationString}' property declaration's '${typeString}' type`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return typeVerifies;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
verifyProperty(properties, context) {
|
|
79
|
+
let propertyVerifies;
|
|
80
|
+
|
|
81
|
+
const propertyString = this.property.getString(),
|
|
82
|
+
propertyDeclarationString = this.getString(); ///
|
|
83
|
+
|
|
84
|
+
context.trace(`Verifying the '${propertyDeclarationString}' property declaration's '${propertyString}' property...`);
|
|
85
|
+
|
|
86
|
+
propertyVerifies = this.property.verify(properties, context);
|
|
87
|
+
|
|
88
|
+
if (propertyVerifies) {
|
|
89
|
+
context.debug(`...verified the '${propertyDeclarationString}' property declaration's '${propertyString}' type`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return propertyVerifies;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static name = "PropertyDeclaration";
|
|
96
|
+
});
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import Declaration from "../declaration";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import {
|
|
7
|
-
import {baseTypeFromNothing} from "../../utilities/type";
|
|
6
|
+
import { baseTypeFromNothing } from "../../utilities/type";
|
|
8
7
|
|
|
9
8
|
export default define(class SimpleTypeDeclaration extends Declaration {
|
|
10
9
|
constructor(context, string, node, lineIndex, type, superTypes, provisional) {
|
|
@@ -108,7 +107,7 @@ export default define(class SimpleTypeDeclaration extends Declaration {
|
|
|
108
107
|
let superTypeVerifies = false;
|
|
109
108
|
|
|
110
109
|
const superTypeString = superType.getString(),
|
|
111
|
-
simpleTypeDeclarationString = this.getString();
|
|
110
|
+
simpleTypeDeclarationString = this.getString(); ///
|
|
112
111
|
|
|
113
112
|
context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's '${superTypeString}' super-type...`);
|
|
114
113
|
|
|
@@ -141,12 +140,9 @@ export default define(class SimpleTypeDeclaration extends Declaration {
|
|
|
141
140
|
let superTypesVerify;
|
|
142
141
|
|
|
143
142
|
const superTypes = [],
|
|
144
|
-
|
|
145
|
-
simpleTypeDeclarationString = this.getString(); ///;
|
|
143
|
+
simpleTypeDeclarationString = this.getString(); ///
|
|
146
144
|
|
|
147
|
-
(
|
|
148
|
-
context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's '${superTypesString}' super-types...`) :
|
|
149
|
-
context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's super-types...`);
|
|
145
|
+
context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's super-types...`);
|
|
150
146
|
|
|
151
147
|
superTypesVerify = this.superTypes.every((superType) => {
|
|
152
148
|
const superTypeVerifies = this.verifySuperType(context, superType, superTypes);
|
|
@@ -168,9 +164,7 @@ export default define(class SimpleTypeDeclaration extends Declaration {
|
|
|
168
164
|
|
|
169
165
|
this.type.setSuperTypes(superTypes);
|
|
170
166
|
|
|
171
|
-
(
|
|
172
|
-
context.debug(`...verified the '${simpleTypeDeclarationString}' simple type declaration's '${superTypesString}' super-types.`) :
|
|
173
|
-
context.debug(`...verified the '${simpleTypeDeclarationString}' simple type declaration's super-types.`);
|
|
167
|
+
context.debug(`...verified the '${simpleTypeDeclarationString}' simple type declaration's super-types.`);
|
|
174
168
|
}
|
|
175
169
|
|
|
176
170
|
return superTypesVerify;
|
|
@@ -180,7 +174,7 @@ export default define(class SimpleTypeDeclaration extends Declaration {
|
|
|
180
174
|
let typePrefixVerifies = false;
|
|
181
175
|
|
|
182
176
|
const typeString = this.type.getString(),
|
|
183
|
-
simpleTypeDeclarationString = this.getString();
|
|
177
|
+
simpleTypeDeclarationString = this.getString(); ///
|
|
184
178
|
|
|
185
179
|
context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's '${typeString}' type's prefix...`);
|
|
186
180
|
|
|
@@ -203,7 +197,7 @@ export default define(class SimpleTypeDeclaration extends Declaration {
|
|
|
203
197
|
let propertiesVerify = true; ///
|
|
204
198
|
|
|
205
199
|
const typeString = this.type.getString(),
|
|
206
|
-
simpleTypeDeclarationString = this.getString();
|
|
200
|
+
simpleTypeDeclarationString = this.getString(); ///
|
|
207
201
|
|
|
208
202
|
context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's '${typeString}' type's properties...`);
|
|
209
203
|
|
|
@@ -35,7 +35,7 @@ export default define(class TypePrefixDeclaration extends Declaration {
|
|
|
35
35
|
typesLength = types.length;
|
|
36
36
|
|
|
37
37
|
if (typesLength === 0) {
|
|
38
|
-
const typePrefixVerifies = this.
|
|
38
|
+
const typePrefixVerifies = this.typePrefix.verify(context);
|
|
39
39
|
|
|
40
40
|
if (typePrefixVerifies) {
|
|
41
41
|
context.addTypePrefix(this.typePrefix);
|
|
@@ -53,42 +53,5 @@ export default define(class TypePrefixDeclaration extends Declaration {
|
|
|
53
53
|
return verifies;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
verifyTypePrefix(context) {
|
|
57
|
-
let typePrefixVerifies = false;
|
|
58
|
-
|
|
59
|
-
const typePrefixString = this.typePrefix.getString();
|
|
60
|
-
|
|
61
|
-
context.trace(`Verifying the '${typePrefixString}' type prefix...`);
|
|
62
|
-
|
|
63
|
-
const typePrefix = context.getTypePrefix();
|
|
64
|
-
|
|
65
|
-
if (typePrefix !== null) {
|
|
66
|
-
context.trace(`The package already has a '${typePrefixString}' type prefix.`);
|
|
67
|
-
} else {
|
|
68
|
-
|
|
69
|
-
const typePrefixName = this.typePrefix.getName(),
|
|
70
|
-
typePrefixPresent = context.isTypePrefixPresentByTypePrefixName(typePrefixName);
|
|
71
|
-
|
|
72
|
-
if (typePrefixPresent) {
|
|
73
|
-
context.debug(`The '${typePrefixString}' type prefix is already present.`);
|
|
74
|
-
} else {
|
|
75
|
-
const nominalTypeName = typePrefixName, ///
|
|
76
|
-
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
77
|
-
|
|
78
|
-
if (typePresent) {
|
|
79
|
-
context.debug(`The '${typePrefixString}' type is already present.`);
|
|
80
|
-
} else {
|
|
81
|
-
typePrefixVerifies = true;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (typePrefixVerifies) {
|
|
87
|
-
context.debug(`...verified the '${typePrefixString}' type prefix.`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return typePrefixVerifies;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
56
|
static name = "TypePrefixDeclaration";
|
|
94
57
|
});
|
|
@@ -108,7 +108,7 @@ export default define(class Metavariable extends Element {
|
|
|
108
108
|
verify(context) {
|
|
109
109
|
let verifies = false;
|
|
110
110
|
|
|
111
|
-
const metavariableString = this.getString();
|
|
111
|
+
const metavariableString = this.getString(); ///
|
|
112
112
|
|
|
113
113
|
context.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
114
114
|
|
|
@@ -148,7 +148,7 @@ export default define(class Metavariable extends Element {
|
|
|
148
148
|
let typeVerifies = true; ///
|
|
149
149
|
|
|
150
150
|
if (this.type !== null) {
|
|
151
|
-
const metavariableString = this.getString();
|
|
151
|
+
const metavariableString = this.getString(); ///
|
|
152
152
|
|
|
153
153
|
context.trace(`Verifying the '${metavariableString}' metavariable's type...`);
|
|
154
154
|
|
|
@@ -258,7 +258,7 @@ export default define(class Metavariable extends Element {
|
|
|
258
258
|
if (this.term === null) {
|
|
259
259
|
termValidates = true;
|
|
260
260
|
} else {
|
|
261
|
-
const metavariableString = this.getString();
|
|
261
|
+
const metavariableString = this.getString(); ///
|
|
262
262
|
|
|
263
263
|
context.trace(`Validating the '${metavariableString}' metavariable's term...`);
|
|
264
264
|
|
package/src/element/property.js
CHANGED
|
@@ -43,6 +43,109 @@ export default define(class Property extends Element {
|
|
|
43
43
|
return comparesToNominalTypeName;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
verify(properties, context) {
|
|
47
|
+
let verifies = false;
|
|
48
|
+
|
|
49
|
+
const propertyString = this.getString(); ///
|
|
50
|
+
|
|
51
|
+
context.trace(`Verifying the '${propertyString}' property...`);
|
|
52
|
+
|
|
53
|
+
const naemVerifies = this.verifyName(properties, context);
|
|
54
|
+
|
|
55
|
+
if (naemVerifies) {
|
|
56
|
+
const nominalTypeNameVerifies = this.verifyNominalTypeName(context);
|
|
57
|
+
|
|
58
|
+
if (nominalTypeNameVerifies) {
|
|
59
|
+
verifies = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (verifies) {
|
|
64
|
+
context.debug(`...verified the '${propertyString}' property.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return verifies;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
verifyName(properties, context) {
|
|
71
|
+
let naemVerifies = false;
|
|
72
|
+
|
|
73
|
+
const propertyString = this.getString();
|
|
74
|
+
|
|
75
|
+
context.trace(`Verifying the '${propertyString}' property's name...`);
|
|
76
|
+
|
|
77
|
+
const propertyName = this.name, ///
|
|
78
|
+
count = properties.reduce((count, property) => {
|
|
79
|
+
const propertyComparesToPropertyName = property.comparePropertyName(propertyName);
|
|
80
|
+
|
|
81
|
+
if (propertyComparesToPropertyName) {
|
|
82
|
+
count++;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return count;
|
|
86
|
+
}, 0);
|
|
87
|
+
|
|
88
|
+
if (count > 1) {
|
|
89
|
+
context.debug(`The '${propertyString}' property appears more than once.`);
|
|
90
|
+
} else {
|
|
91
|
+
const superTypes = this.type.getSuperTypes(),
|
|
92
|
+
superType = superTypes.find((superType) => {
|
|
93
|
+
const superTypeProperties = superType.getProperties(),
|
|
94
|
+
superTypePropertyComparesToPropertyName = superTypeProperties.some((superTypeProperty) => {
|
|
95
|
+
const superTypePropertyComparesToPropertyName = superTypeProperty.comparePropertyName(propertyName);
|
|
96
|
+
|
|
97
|
+
if (superTypePropertyComparesToPropertyName) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (superTypePropertyComparesToPropertyName) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}) || null;
|
|
106
|
+
|
|
107
|
+
if (superType !== null) {
|
|
108
|
+
const superTypeString = superType.getString();
|
|
109
|
+
|
|
110
|
+
context.debug(`The '${superTypeString}' super-type has the same property.`);
|
|
111
|
+
} else {
|
|
112
|
+
naemVerifies = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (naemVerifies) {
|
|
117
|
+
context.debug(`...verified the '${propertyString}' property's name.`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return naemVerifies;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
verifyNominalTypeName(context) {
|
|
124
|
+
let nominalTypeNameVerifies = false;
|
|
125
|
+
|
|
126
|
+
const propertyString = this.getString(); ///
|
|
127
|
+
|
|
128
|
+
context.trace(`Verifying the '${propertyString}' property's nominal type name...`);
|
|
129
|
+
|
|
130
|
+
const typeComparesToNominalTypeName = this.type.compareNominalTypeName(this.nominalTypeName);
|
|
131
|
+
|
|
132
|
+
if (typeComparesToNominalTypeName) {
|
|
133
|
+
nominalTypeNameVerifies = true;
|
|
134
|
+
} else {
|
|
135
|
+
const typePresent = context.isTypePresentByNominalTypeName(this.nominalTypeName);
|
|
136
|
+
|
|
137
|
+
if (typePresent) {
|
|
138
|
+
nominalTypeNameVerifies = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (nominalTypeNameVerifies) {
|
|
143
|
+
context.debug(`...verifies the '${propertyString}' property's nominal type name.`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return nominalTypeNameVerifies;
|
|
147
|
+
}
|
|
148
|
+
|
|
46
149
|
toJSON() {
|
|
47
150
|
const nominalTypeNameJSON = nominalTypeNameToNominalTypeNameJSON(this.nominalTypeName),
|
|
48
151
|
nominalTypeName = nominalTypeNameJSON, ///
|
package/src/element/statement.js
CHANGED
|
@@ -229,7 +229,7 @@ export default define(class Statement extends Element {
|
|
|
229
229
|
if (subproofAssertionNode !== null) {
|
|
230
230
|
const context = generalContext, ///
|
|
231
231
|
subproofString = subproof.getString(),
|
|
232
|
-
statementString = this.getString();
|
|
232
|
+
statementString = this.getString(); ///
|
|
233
233
|
|
|
234
234
|
context.trace(`Unifying the '${subproofString}' subproof with the '${statementString}' statement...`);
|
|
235
235
|
|
|
@@ -141,7 +141,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
141
141
|
|
|
142
142
|
if (substitution !== null) {
|
|
143
143
|
const context = generalContext, ///
|
|
144
|
-
statementSubstitutionString = this.getString();
|
|
144
|
+
statementSubstitutionString = this.getString(); ///
|
|
145
145
|
|
|
146
146
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's substitution...`);
|
|
147
147
|
|
|
@@ -31,6 +31,42 @@ export default define(class TypePrefix extends Element {
|
|
|
31
31
|
return comparesToTypePrefixName;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
verify(context) {
|
|
35
|
+
let verifies = false;
|
|
36
|
+
|
|
37
|
+
const typePrefixString = this.getString(); ///
|
|
38
|
+
|
|
39
|
+
context.trace(`Verifying the '${typePrefixString}' type prefix...`);
|
|
40
|
+
|
|
41
|
+
const typePrefix = context.getTypePrefix();
|
|
42
|
+
|
|
43
|
+
if (typePrefix === null) {
|
|
44
|
+
const typePrefixName = this.name, ///
|
|
45
|
+
typePrefixPresent = context.isTypePrefixPresentByTypePrefixName(typePrefixName);
|
|
46
|
+
|
|
47
|
+
if (!typePrefixPresent) {
|
|
48
|
+
const nominalTypeName = typePrefixName, ///
|
|
49
|
+
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
50
|
+
|
|
51
|
+
if (!typePresent) {
|
|
52
|
+
verifies = true;
|
|
53
|
+
} else {
|
|
54
|
+
context.debug(`The '${typePrefixString}' type is already present.`);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
context.debug(`The '${typePrefixString}' type prefix is already present.`);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
context.trace(`The package already has a '${typePrefixString}' type prefix.`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (verifies) {
|
|
64
|
+
context.debug(`...verified the '${typePrefixString}' type prefix.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return verifies;
|
|
68
|
+
}
|
|
69
|
+
|
|
34
70
|
static name = "TypePrefix";
|
|
35
71
|
|
|
36
72
|
toJSON() {
|
package/src/preamble.js
CHANGED
|
@@ -50,6 +50,7 @@ import ProcedureReference from "./element/procedureReference";
|
|
|
50
50
|
import ContainedAssertion from "./element/assertion/contained";
|
|
51
51
|
import SatisfiesAssertion from "./element/assertion/satisfies";
|
|
52
52
|
import MetaLevelAssumption from "./element/assumption/metaLevel";
|
|
53
|
+
import PropertyDeclaration from "./element/declaration/property";
|
|
53
54
|
import VariableDeclaration from "./element/declaration/variable";
|
|
54
55
|
import BracketedCombinator from "./element/combinator/bracketed";
|
|
55
56
|
import BracketedConstructor from "./element/constructor/bracketed";
|
package/src/utilities/element.js
CHANGED
|
@@ -10,7 +10,8 @@ import { equivalenceStringFromTerms,
|
|
|
10
10
|
subproofStringFromSuppositionsAndSubDerivation,
|
|
11
11
|
procedureCallStringFromProcedureReferenceAndParameters,
|
|
12
12
|
topLevelAssertionStringFromLabelsSuppositionsAndDeduction,
|
|
13
|
-
topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction
|
|
13
|
+
topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction,
|
|
14
|
+
complexTypeDeclarationStringFromTypeSuperTypesAndProvisional } from "../utilities/string";
|
|
14
15
|
|
|
15
16
|
export function typeFromTypeNode(typeNode, context) {
|
|
16
17
|
let type;
|
|
@@ -233,17 +234,21 @@ export function theoremFromTheoremNode(theoremNode, context) {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
export function propertyFromPropertyNode(propertyNode, context) {
|
|
236
|
-
|
|
237
|
-
node = propertyNode, ///
|
|
238
|
-
string = context.nodeAsString(node),
|
|
239
|
-
lineIndex = null,
|
|
240
|
-
propertyName = propertyNode.getPropertyName(),
|
|
241
|
-
nominalTypeName = null,
|
|
242
|
-
name = propertyName; ///
|
|
237
|
+
let property = null;
|
|
243
238
|
|
|
244
|
-
|
|
239
|
+
if (propertyNode != null) {
|
|
240
|
+
const { Property } = elements,
|
|
241
|
+
node = propertyNode, ///
|
|
242
|
+
string = context.nodeAsString(node),
|
|
243
|
+
lineIndex = null,
|
|
244
|
+
propertyName = propertyNode.getPropertyName(),
|
|
245
|
+
nominalTypeName = null,
|
|
246
|
+
name = propertyName; ///
|
|
245
247
|
|
|
246
|
-
|
|
248
|
+
context = null;
|
|
249
|
+
|
|
250
|
+
property = new Property(context, string, node, lineIndex, name, nominalTypeName);
|
|
251
|
+
}
|
|
247
252
|
|
|
248
253
|
return property;
|
|
249
254
|
}
|
|
@@ -488,12 +493,11 @@ export function typePrefixFromTypePrefixNode(typePrefixNode, context) {
|
|
|
488
493
|
node = typePrefixNode, ///
|
|
489
494
|
string = context.nodeAsString(node),
|
|
490
495
|
lineIndex = null,
|
|
491
|
-
|
|
492
|
-
type = typeFromTypePrefixNode(typePrefixNode, context);
|
|
496
|
+
name = nameFromTypePrefixNode(typePrefixNode, context);
|
|
493
497
|
|
|
494
498
|
context = null;
|
|
495
499
|
|
|
496
|
-
const typePrefix = new TypePrefix(context, string, node, lineIndex,
|
|
500
|
+
const typePrefix = new TypePrefix(context, string, node, lineIndex, name);
|
|
497
501
|
|
|
498
502
|
return typePrefix;
|
|
499
503
|
}
|
|
@@ -783,6 +787,23 @@ export function procedureReferenceFromProcedureReferenceNode(procedureReferenceN
|
|
|
783
787
|
return procedureRefereence;
|
|
784
788
|
}
|
|
785
789
|
|
|
790
|
+
export function propertyDeclarationFromPropertyDeclarationNode(propertyDeclarationNode, context) {
|
|
791
|
+
const { PropertyDeclaration } = elements,
|
|
792
|
+
node = propertyDeclarationNode, ///
|
|
793
|
+
string = context.nodeAsString(node),
|
|
794
|
+
lineIndex = null,
|
|
795
|
+
typeNode = propertyDeclarationNode.getTypeNode(),
|
|
796
|
+
propertyNode = propertyDeclarationNode.getPropertyNode(),
|
|
797
|
+
type = typeFromTypeNode(typeNode, context),
|
|
798
|
+
property = propertyFromPropertyNode(propertyNode, context);
|
|
799
|
+
|
|
800
|
+
context = null;
|
|
801
|
+
|
|
802
|
+
const propertyDeclaration = new PropertyDeclaration(context, string, node, lineIndex, property, type);
|
|
803
|
+
|
|
804
|
+
return propertyDeclaration;
|
|
805
|
+
}
|
|
806
|
+
|
|
786
807
|
export function variableDeclarationFromVariableDeclarationNode(variableDeclarationNode, context) {
|
|
787
808
|
const { VariableDeclaration } = elements,
|
|
788
809
|
node = variableDeclarationNode, ///
|
|
@@ -938,15 +959,17 @@ export function constructorDeclarationFromConstructorDeclarationNode(constructor
|
|
|
938
959
|
export function complexTypeDeclarationFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
|
|
939
960
|
const { ComplexTypeDeclaration } = elements,
|
|
940
961
|
node = complexTypeDeclarationNode, ///
|
|
941
|
-
string = context.nodeAsString(node),
|
|
942
962
|
lineIndex = null,
|
|
943
963
|
type = typeFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
|
|
944
964
|
superTypes = superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
|
|
945
|
-
provisional = provisionalFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context)
|
|
965
|
+
provisional = provisionalFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
|
|
966
|
+
propertyDeclarations = propertyDeclarationsFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
|
|
967
|
+
complexTypeDeclarationString = complexTypeDeclarationStringFromTypeSuperTypesAndProvisional(type, superTypes, provisional),
|
|
968
|
+
string = complexTypeDeclarationString; ///
|
|
946
969
|
|
|
947
970
|
context = null;
|
|
948
971
|
|
|
949
|
-
const complexTypeDeclaration = new ComplexTypeDeclaration(context, string, node, lineIndex, type, superTypes, provisional);
|
|
972
|
+
const complexTypeDeclaration = new ComplexTypeDeclaration(context, string, node, lineIndex, type, superTypes, provisional, propertyDeclarations);
|
|
950
973
|
|
|
951
974
|
return complexTypeDeclaration;
|
|
952
975
|
}
|
|
@@ -2090,6 +2113,13 @@ export function replacementStatementFromStatementSubstitutionNode(statementSubst
|
|
|
2090
2113
|
return replacementStatement;
|
|
2091
2114
|
}
|
|
2092
2115
|
|
|
2116
|
+
export function propertyDeclarationsFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
|
|
2117
|
+
const propertyDeclarationnNodes = complexTypeDeclarationNode.getPropertyDeclarationNodes(),
|
|
2118
|
+
propertyDeclarations = propertyDeclarationsFromPropertyDeclarationNodes(propertyDeclarationnNodes, context);
|
|
2119
|
+
|
|
2120
|
+
return propertyDeclarations;
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2093
2123
|
export function termsFromTermNodes(termNodes, context) {
|
|
2094
2124
|
const terms = termNodes.map((termNode) => {
|
|
2095
2125
|
const term = termFromTermNode(termNode, context);
|
|
@@ -2204,3 +2234,13 @@ export function stepsOrSubproofsFromSubDerivationNode(subDerivationNode, context
|
|
|
2204
2234
|
|
|
2205
2235
|
return stepsOrSubproofs;
|
|
2206
2236
|
}
|
|
2237
|
+
|
|
2238
|
+
export function propertyDeclarationsFromPropertyDeclarationNodes(propertyDeclarationnNodes, context) {
|
|
2239
|
+
const propertyDeclrations = propertyDeclarationnNodes.map((propertyDeclarationNode) => {
|
|
2240
|
+
const propertyDeclcaration = propertyDeclarationFromPropertyDeclarationNode(propertyDeclarationNode, context);
|
|
2241
|
+
|
|
2242
|
+
return propertyDeclcaration;
|
|
2243
|
+
});
|
|
2244
|
+
|
|
2245
|
+
return propertyDeclrations;
|
|
2246
|
+
}
|
package/src/utilities/string.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { baseTypeFromNothing } from "../utilities/type";
|
|
4
|
+
import { EMPTY_STRING, PROVISIONALLY } from "../constants";
|
|
4
5
|
|
|
5
6
|
export function termsStringFromTerms(terms) {
|
|
6
7
|
const termsString = terms.reduce((termsString, term) => {
|
|
@@ -59,18 +60,25 @@ export function hypothesesStringFromHypotheses(hypotheses) {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export function superTypesStringFromSuperTypes(superTypes) {
|
|
62
|
-
|
|
63
|
-
superTypesString = superTypes.reduce((superTypesString, superType) => {
|
|
64
|
-
if (superType !== baseType) {
|
|
65
|
-
const superTypeString = superType.getString();
|
|
63
|
+
let superTypesString;
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
`'${superTypeString}'` :
|
|
69
|
-
`${superTypesString}, '${superTypeString}'`;
|
|
70
|
-
}
|
|
65
|
+
const baseType = baseTypeFromNothing();
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
superTypesString = superTypes.reduce((superTypesString, superType) => {
|
|
68
|
+
if (superType !== baseType) {
|
|
69
|
+
const superTypeString = superType.getString();
|
|
70
|
+
|
|
71
|
+
superTypesString = (superTypesString === null) ?
|
|
72
|
+
`'${superTypeString}'` :
|
|
73
|
+
`${superTypesString}, '${superTypeString}'`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return superTypesString;
|
|
77
|
+
}, null);
|
|
78
|
+
|
|
79
|
+
superTypesString = (superTypesString !== null) ?
|
|
80
|
+
`:${superTypesString}` :
|
|
81
|
+
EMPTY_STRING;
|
|
74
82
|
|
|
75
83
|
return superTypesString;
|
|
76
84
|
}
|
|
@@ -89,13 +97,21 @@ export function parametersStringFromParameters(parameters) {
|
|
|
89
97
|
return parametersString;
|
|
90
98
|
}
|
|
91
99
|
|
|
100
|
+
export function provisinalStringFromProvisional(provisional) {
|
|
101
|
+
const provisionString = provisional ?
|
|
102
|
+
PROVISIONALLY :
|
|
103
|
+
EMPTY_STRING;
|
|
104
|
+
|
|
105
|
+
return provisionString;
|
|
106
|
+
}
|
|
107
|
+
|
|
92
108
|
export function suppositionsStringFromSuppositions(suppositions) {
|
|
93
109
|
const suppositionsString = suppositions.reduce((suppositionsString, supposition) => {
|
|
94
110
|
const suppositionString = supposition.getString();
|
|
95
111
|
|
|
96
112
|
suppositionsString = (suppositionsString === null) ?
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
suppositionString: ///
|
|
114
|
+
`${suppositionsString}, ${suppositionString}`;
|
|
99
115
|
|
|
100
116
|
return suppositionsString;
|
|
101
117
|
}, null);
|
|
@@ -230,6 +246,15 @@ export function topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels
|
|
|
230
246
|
return topLevelAssertionString;
|
|
231
247
|
}
|
|
232
248
|
|
|
249
|
+
export function complexTypeDeclarationStringFromTypeSuperTypesAndProvisional(type, superTypes, provisional) {
|
|
250
|
+
const typeString = type.getString(),
|
|
251
|
+
superTypesString = superTypesStringFromSuperTypes(superTypes),
|
|
252
|
+
provisionalString = provisinalStringFromProvisional(provisional),
|
|
253
|
+
complexTypeDeclarationString = `${provisionalString}${typeString}${superTypesString}`;
|
|
254
|
+
|
|
255
|
+
return complexTypeDeclarationString;
|
|
256
|
+
}
|
|
257
|
+
|
|
233
258
|
export function topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction(label, suppositions, deduction) {
|
|
234
259
|
const labelString = label.getString(),
|
|
235
260
|
deductionString = deduction.getString(),
|