occam-verify-cli 1.0.638 → 1.0.641
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/context.js +8 -1
- package/lib/element/assumption.js +3 -3
- package/lib/element/combinator.js +4 -4
- package/lib/element/declaration/combinator.js +15 -2
- package/lib/element/declaration/constructor.js +129 -60
- package/lib/element/equality.js +18 -17
- package/lib/element/frame.js +1 -1
- package/lib/element/judgement.js +3 -3
- package/lib/element/reference.js +3 -3
- package/lib/element/statement.js +3 -3
- package/lib/element/term.js +7 -4
- package/lib/utilities/element.js +124 -46
- package/package.json +7 -7
- package/src/context.js +7 -0
- package/src/element/assumption.js +1 -1
- package/src/element/combinator.js +3 -4
- package/src/element/declaration/combinator.js +19 -1
- package/src/element/declaration/constructor.js +123 -60
- package/src/element/equality.js +18 -20
- package/src/element/frame.js +0 -1
- package/src/element/judgement.js +1 -1
- package/src/element/reference.js +1 -1
- package/src/element/statement.js +1 -1
- package/src/element/term.js +7 -3
- package/src/utilities/element.js +187 -76
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "occam-verify-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.641",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/occam-verify-cli",
|
|
7
7
|
"description": "Occam's Verifier",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"argumentative": "^2.0.36",
|
|
14
14
|
"necessary": "^17.0.9",
|
|
15
15
|
"occam-file-system": "^6.0.505",
|
|
16
|
-
"occam-furtle": "^3.0.
|
|
17
|
-
"occam-grammars": "^1.3.
|
|
18
|
-
"occam-languages": "^0.0.
|
|
16
|
+
"occam-furtle": "^3.0.119",
|
|
17
|
+
"occam-grammars": "^1.3.512",
|
|
18
|
+
"occam-languages": "^0.0.90",
|
|
19
19
|
"occam-lexers": "^23.1.34",
|
|
20
|
-
"occam-model": "^1.0.
|
|
21
|
-
"occam-nominal": "^1.0.
|
|
22
|
-
"occam-parsers": "^23.1.
|
|
20
|
+
"occam-model": "^1.0.496",
|
|
21
|
+
"occam-nominal": "^1.0.44",
|
|
22
|
+
"occam-parsers": "^23.1.42"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@swc/core": "1.13.20",
|
package/src/context.js
CHANGED
|
@@ -179,6 +179,13 @@ export default class Context extends ContextBase {
|
|
|
179
179
|
return reference;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
findSubstitutionBySubstitutionNode(substitutionNode) {
|
|
183
|
+
const context = this.getContext(),
|
|
184
|
+
substitution = context.findSubstitutionBySubstitutionNode(substitutionNode);
|
|
185
|
+
|
|
186
|
+
return substitution;
|
|
187
|
+
}
|
|
188
|
+
|
|
182
189
|
findVariableByVariableIdentifier(variableIdentifier) {
|
|
183
190
|
const context = this.getContext(),
|
|
184
191
|
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
@@ -25,16 +25,15 @@ export default define(class Combinator extends Element {
|
|
|
25
25
|
return combinatorNode;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
verify() {
|
|
28
|
+
verify(context) {
|
|
29
29
|
let verifies;
|
|
30
30
|
|
|
31
|
-
const
|
|
32
|
-
combinatorString = this.getString(); ///
|
|
31
|
+
const combinatorString = this.getString(); ///
|
|
33
32
|
|
|
34
33
|
context.trace(`Verifying the '${combinatorString}' combinator...`);
|
|
35
34
|
|
|
36
35
|
const combinator = this, ///
|
|
37
|
-
combinatorVerifies = verifyCombinator(combinator
|
|
36
|
+
combinatorVerifies = verifyCombinator(combinator);
|
|
38
37
|
|
|
39
38
|
if (combinatorVerifies) {
|
|
40
39
|
verifies = true;
|
|
@@ -30,7 +30,7 @@ export default define(class CombinatorDeclaration extends Declaration {
|
|
|
30
30
|
|
|
31
31
|
context.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration...`);
|
|
32
32
|
|
|
33
|
-
const combinatorVerifies = this.
|
|
33
|
+
const combinatorVerifies = this.verifyCombinator();
|
|
34
34
|
|
|
35
35
|
if (combinatorVerifies) {
|
|
36
36
|
context.addCombinator(this.combinator);
|
|
@@ -45,5 +45,23 @@ export default define(class CombinatorDeclaration extends Declaration {
|
|
|
45
45
|
return verifies;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
verifyCombinator() {
|
|
49
|
+
let combinatorVerifies;
|
|
50
|
+
|
|
51
|
+
const context = this.getContext(),
|
|
52
|
+
combinatorString = this.combinator.getString(),
|
|
53
|
+
combinatorDeclarationString = this.getString(); ///
|
|
54
|
+
|
|
55
|
+
context.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration's '${combinatorString}' combinator...`);
|
|
56
|
+
|
|
57
|
+
combinatorVerifies = this.combinator.verify(context);
|
|
58
|
+
|
|
59
|
+
if (combinatorVerifies) {
|
|
60
|
+
context.debug(`...verified the '${combinatorDeclarationString}' combinator declaration's '${combinatorString}' combinator.`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return combinatorVerifies;
|
|
64
|
+
}
|
|
65
|
+
|
|
48
66
|
static name = "CombinatorDeclaration";
|
|
49
67
|
});
|
|
@@ -3,77 +3,81 @@
|
|
|
3
3
|
import Declaration from "../declaration";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import { validateTerm } from "../../process/validate";
|
|
7
6
|
|
|
8
7
|
export default define(class ConstructorDeclaration extends Declaration {
|
|
9
|
-
constructor(context, string, node, constructor) {
|
|
8
|
+
constructor(context, string, node, type, provisional, constructor) {
|
|
10
9
|
super(context, string, node);
|
|
11
10
|
|
|
11
|
+
this.type = type;
|
|
12
|
+
this.provisional = provisional;
|
|
12
13
|
this.constructor = constructor;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
getType() {
|
|
17
|
+
return this.type;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
isProvisinal() {
|
|
21
|
+
return this.provisional;
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
getConstructor() {
|
|
16
25
|
return this.constructor;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
getConstructorDeclarationNode() {
|
|
20
29
|
const node = this.getNode(),
|
|
21
|
-
constructorDeclarationNode = node;
|
|
30
|
+
constructorDeclarationNode = node; ///
|
|
22
31
|
|
|
23
32
|
return constructorDeclarationNode;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
let
|
|
35
|
+
async verify() {
|
|
36
|
+
let verifies = false;
|
|
28
37
|
|
|
29
38
|
const context = this.getContext(),
|
|
30
|
-
|
|
39
|
+
constructorDeclarationString = this.getString(); ///
|
|
40
|
+
|
|
41
|
+
context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration...`);
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
const typeVerified = this.verifyType();
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
termValidates = validateTerm(termNode, context, () => {
|
|
37
|
-
const validatesFormards = true;
|
|
45
|
+
if (typeVerified) {
|
|
46
|
+
const constructorVerifies = this.verifyConstructor();
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
if (constructorVerifies) {
|
|
49
|
+
const constructorTypeVerifies = this.verifyConstructorType();
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
if (constructorTypeVerifies) {
|
|
52
|
+
context.addConstructor(this.constructor);
|
|
53
|
+
|
|
54
|
+
verifies = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
|
|
46
|
-
if (
|
|
47
|
-
context.debug(`...verified the '${
|
|
59
|
+
if (verifies) {
|
|
60
|
+
context.debug(`...verified the '${constructorDeclarationString}' constructor declaration.`);
|
|
48
61
|
}
|
|
49
62
|
|
|
50
|
-
return
|
|
63
|
+
return verifies;
|
|
51
64
|
}
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
const context = this.getContext();
|
|
57
|
-
|
|
58
|
-
let type;
|
|
66
|
+
verifyType() {
|
|
67
|
+
let typeVerifies = false;
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
context.trace(`Verifying the '${typeString}' type...`);
|
|
65
|
-
|
|
66
|
-
const nominalTypeName = type.getNominalTypeName();
|
|
69
|
+
const context = this.getContext(),
|
|
70
|
+
typeString = this.type.getString(),
|
|
71
|
+
constructorDeclarationString = this.getString(); ///
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration's '${typeString}' type...`);
|
|
69
74
|
|
|
70
|
-
const
|
|
75
|
+
const nominalTypeName = this.type.getNominalTypeName(),
|
|
76
|
+
type = context.findTypeByNominalTypeName(nominalTypeName);
|
|
71
77
|
|
|
72
|
-
if (
|
|
73
|
-
context.debug(`The '${typeString}' type is not present.`);
|
|
74
|
-
} else {
|
|
78
|
+
if (type !== null) {
|
|
75
79
|
const includeSupertypes = false,
|
|
76
|
-
provisional =
|
|
80
|
+
provisional = this.isProvisional(includeSupertypes),
|
|
77
81
|
typeComparesToProvisional = type.compareProvisional(provisional);
|
|
78
82
|
|
|
79
83
|
if (!typeComparesToProvisional) {
|
|
@@ -81,45 +85,104 @@ export default define(class ConstructorDeclaration extends Declaration {
|
|
|
81
85
|
context.debug(`The '${typeString}' type is present but not provisional.`) :
|
|
82
86
|
context.debug(`The '${typeString}' type is present but provisional.`);
|
|
83
87
|
} else {
|
|
84
|
-
this.
|
|
88
|
+
this.type = type;
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
typeVerifies = true;
|
|
87
91
|
}
|
|
92
|
+
} else {
|
|
93
|
+
context.debug(`The '${typeString}' type is not present.`);
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
if (
|
|
91
|
-
context.debug(`...verified the '${typeString}' type.`);
|
|
96
|
+
if (typeVerifies) {
|
|
97
|
+
context.debug(`...verified the '${constructorDeclarationString}' constructor declaration's '${typeString}' type.`);
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
return
|
|
100
|
+
return typeVerifies;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
|
|
98
|
-
let
|
|
103
|
+
verifyConstructor() {
|
|
104
|
+
let constructorVerifies;
|
|
99
105
|
|
|
100
106
|
const context = this.getContext(),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration...`);
|
|
104
|
-
|
|
105
|
-
const constructorTypeVerifies = this.verifyConstructorType();
|
|
107
|
+
constructorString = this.constructor.getString(),
|
|
108
|
+
constructorDeclarationString = this.getString(); ///
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
const constructorValidates = this.verifyConstructor();
|
|
110
|
+
context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration's '${constructorString}' constructor...`);
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
context.addConstructor(this.constructor);
|
|
112
|
+
constructorVerifies = this.constructor.verify(context);
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (verifies) {
|
|
118
|
-
context.debug(`...verified the '${constructorDeclarationString}' constructor declaration.`);
|
|
114
|
+
if (constructorVerifies) {
|
|
115
|
+
context.debug(`...verified the '${constructorDeclarationString}' constructor declaration's '${constructorString}' constructor.`);
|
|
119
116
|
}
|
|
120
117
|
|
|
121
|
-
return
|
|
118
|
+
return constructorVerifies;
|
|
122
119
|
}
|
|
123
120
|
|
|
121
|
+
// verifyConstructorType() {
|
|
122
|
+
// let constructorTypeVerifies = false;
|
|
123
|
+
//
|
|
124
|
+
// const context = this.getContext(),
|
|
125
|
+
// constructorType = this,
|
|
126
|
+
// constructorTypeString = constructorType.getString(),
|
|
127
|
+
// constructorDeclarationString = this.getString(); ///
|
|
128
|
+
//
|
|
129
|
+
// context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration's '${constructorTypeString}' type...`);
|
|
130
|
+
//
|
|
131
|
+
// const nominalTypeName = this.type.getNominalTypeName(),
|
|
132
|
+
// typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
133
|
+
//
|
|
134
|
+
// if (!typePresent) {
|
|
135
|
+
// context.debug(`The '${typeString}' type is not present.`);
|
|
136
|
+
// } else {
|
|
137
|
+
// const includeSupertypes = false,
|
|
138
|
+
// provisional = type.isProvisional(includeSupertypes),
|
|
139
|
+
// typeComparesToProvisional = type.compareProvisional(provisional);
|
|
140
|
+
//
|
|
141
|
+
// if (!typeComparesToProvisional) {
|
|
142
|
+
// provisional ?
|
|
143
|
+
// context.debug(`The '${typeString}' type is present but not provisional.`) :
|
|
144
|
+
// context.debug(`The '${typeString}' type is present but provisional.`);
|
|
145
|
+
// } else {
|
|
146
|
+
// this.constructor.setType(type);
|
|
147
|
+
//
|
|
148
|
+
// constructorTypeVerifies = true;
|
|
149
|
+
// }
|
|
150
|
+
// }
|
|
151
|
+
//
|
|
152
|
+
// if (constructorTypeVerifies) {
|
|
153
|
+
// context.debug(`...verified the '${constructorDeclarationString}' constructor declaration's '${typeString}' type.`);
|
|
154
|
+
// }
|
|
155
|
+
//
|
|
156
|
+
// return constructorTypeVerifies;
|
|
157
|
+
// }
|
|
158
|
+
|
|
124
159
|
static name = "ConstructorDeclaration";
|
|
125
160
|
});
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
// verifyConstructor() {
|
|
164
|
+
// let constructorValidates = false;
|
|
165
|
+
//
|
|
166
|
+
// const context = this.getContext(),
|
|
167
|
+
// constructorString = this.constructor.getString();
|
|
168
|
+
//
|
|
169
|
+
// context.trace(`Verifying the '${constructorString}' constructor...`);
|
|
170
|
+
//
|
|
171
|
+
// const term = this.constructor.getTerm(),
|
|
172
|
+
// termNode = term.getNode(),
|
|
173
|
+
// termValidates = validateTerm(termNode, context, () => {
|
|
174
|
+
// const validatesFormards = true;
|
|
175
|
+
//
|
|
176
|
+
// return validatesFormards;
|
|
177
|
+
// });
|
|
178
|
+
//
|
|
179
|
+
// if (termValidates) {
|
|
180
|
+
// constructorValidates = true;
|
|
181
|
+
// }
|
|
182
|
+
//
|
|
183
|
+
// if (constructorValidates) {
|
|
184
|
+
// context.debug(`...verified the '${constructorString}' constructor.`);
|
|
185
|
+
// }
|
|
186
|
+
//
|
|
187
|
+
// return constructorValidates;
|
|
188
|
+
// }
|
package/src/element/equality.js
CHANGED
|
@@ -120,13 +120,13 @@ export default define(class Equality extends Element {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
validate(stated, context) {
|
|
123
|
-
let equality =
|
|
123
|
+
let equality = null;
|
|
124
124
|
|
|
125
125
|
const equalityString = this.getString(); ///
|
|
126
126
|
|
|
127
127
|
context.trace(`Validating the '${equalityString}' equality...`);
|
|
128
128
|
|
|
129
|
-
const validEquality = this.
|
|
129
|
+
const validEquality = this.findValidEquality(context);
|
|
130
130
|
|
|
131
131
|
if (validEquality !== null) {
|
|
132
132
|
equality = validEquality; ///
|
|
@@ -153,7 +153,7 @@ export default define(class Equality extends Element {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
if (validates) {
|
|
156
|
-
|
|
156
|
+
equality = this; ///
|
|
157
157
|
|
|
158
158
|
this.assign(stated, context);
|
|
159
159
|
|
|
@@ -174,38 +174,36 @@ export default define(class Equality extends Element {
|
|
|
174
174
|
context.trace(`Validating the '${equalityString}' equality's terms...`);
|
|
175
175
|
|
|
176
176
|
let leftTerm,
|
|
177
|
-
rightTerm
|
|
177
|
+
rightTerm;
|
|
178
178
|
|
|
179
179
|
leftTerm = this.leftTerm.validate(context, () => {
|
|
180
|
-
let validatesForwards;
|
|
180
|
+
let validatesForwards = false;
|
|
181
181
|
|
|
182
182
|
rightTerm = this.rightTerm.validate(context, () => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const leftTermType = this.leftTerm.getType(),
|
|
186
|
-
rightTermType = this.rightTerm.getType(),
|
|
187
|
-
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
188
|
-
|
|
189
|
-
validatesForwards = leftTermTypeComparableToRightTermType; ///
|
|
183
|
+
const validatesForwards = true;
|
|
190
184
|
|
|
191
185
|
return validatesForwards;
|
|
192
186
|
});
|
|
193
187
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
188
|
+
if (rightTerm !== null) {
|
|
189
|
+
validatesForwards = true;
|
|
190
|
+
}
|
|
197
191
|
|
|
198
192
|
return validatesForwards;
|
|
199
193
|
});
|
|
200
194
|
|
|
201
|
-
|
|
195
|
+
if (leftTerm !== null) {
|
|
196
|
+
const leftTermType = leftTerm.getType(),
|
|
197
|
+
rightTermType = rightTerm.getType(),
|
|
198
|
+
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
202
199
|
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
if (leftTermTypeComparableToRightTermType) {
|
|
201
|
+
this.leftTerm = leftTerm;
|
|
205
202
|
|
|
206
|
-
|
|
203
|
+
this.rightTerm = rightTerm;
|
|
207
204
|
|
|
208
|
-
|
|
205
|
+
termsValidate = true;
|
|
206
|
+
}
|
|
209
207
|
}
|
|
210
208
|
|
|
211
209
|
if (termsValidate) {
|
package/src/element/frame.js
CHANGED
package/src/element/judgement.js
CHANGED
package/src/element/reference.js
CHANGED
package/src/element/statement.js
CHANGED
package/src/element/term.js
CHANGED
|
@@ -159,9 +159,13 @@ export default define(class Term extends Element {
|
|
|
159
159
|
valid = (validTerm !== null);
|
|
160
160
|
|
|
161
161
|
if (valid) {
|
|
162
|
-
|
|
162
|
+
const validatesForward = validateForwards();
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
if (validatesForward) {
|
|
165
|
+
term = validTerm; ///
|
|
166
|
+
|
|
167
|
+
context.debug(`...the '${termString}' term is already valid.`);
|
|
168
|
+
}
|
|
165
169
|
} else {
|
|
166
170
|
const validates = validateTerms.some((validateTerm) => { ///
|
|
167
171
|
const term = this, ///
|
|
@@ -173,7 +177,7 @@ export default define(class Term extends Element {
|
|
|
173
177
|
});
|
|
174
178
|
|
|
175
179
|
if (validates) {
|
|
176
|
-
term =
|
|
180
|
+
term = this; ///
|
|
177
181
|
|
|
178
182
|
context.addTerm(term);
|
|
179
183
|
|