occam-verify-cli 1.0.635 → 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/file/nominal.js +1 -1
- package/lib/context/liminal.js +3 -3
- package/lib/context/scoped.js +25 -3
- package/lib/context.js +15 -1
- package/lib/element/assertion/contained.js +34 -23
- package/lib/element/assertion/defined.js +30 -21
- package/lib/element/assertion/property.js +24 -21
- package/lib/element/assertion/satisfies.js +19 -14
- package/lib/element/assertion/subproof.js +18 -13
- package/lib/element/assertion/type.js +23 -20
- package/lib/element/assertion.js +5 -5
- package/lib/element/assumption.js +30 -24
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +6 -6
- package/lib/element/conclusion.js +6 -2
- package/lib/element/constructor/bracketed.js +5 -3
- package/lib/element/declaration/combinator.js +15 -2
- package/lib/element/declaration/constructor.js +129 -60
- package/lib/element/deduction.js +6 -2
- package/lib/element/derivation.js +4 -5
- package/lib/element/equality.js +37 -31
- package/lib/element/frame.js +26 -21
- package/lib/element/hypothesis.js +8 -10
- package/lib/element/judgement.js +53 -21
- package/lib/element/metavariable.js +18 -10
- package/lib/element/proofAssertion/premise.js +8 -8
- package/lib/element/proofAssertion/step.js +16 -11
- package/lib/element/proofAssertion/supposition.js +7 -7
- package/lib/element/proofAssertion.js +7 -5
- package/lib/element/propertyRelation.js +7 -3
- package/lib/element/reference.js +28 -21
- package/lib/element/rule.js +4 -11
- package/lib/element/signature.js +10 -4
- package/lib/element/statement.js +16 -16
- package/lib/element/subDerivation.js +4 -11
- package/lib/element/subproof.js +37 -29
- package/lib/element/substitution/frame.js +18 -10
- package/lib/element/substitution/reference.js +17 -9
- package/lib/element/substitution/statement.js +16 -10
- package/lib/element/substitution/term.js +19 -9
- package/lib/element/substitution.js +5 -5
- package/lib/element/term.js +18 -15
- package/lib/element/topLevelAssertion.js +4 -11
- package/lib/element/topLevelMetaAssertion.js +4 -11
- package/lib/element/variable.js +6 -3
- package/lib/process/assign.js +1 -9
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +14 -7
- package/lib/process/verify.js +14 -7
- package/lib/utilities/element.js +124 -46
- package/lib/utilities/unification.js +6 -6
- package/lib/utilities/validation.js +68 -55
- package/package.json +7 -7
- package/src/context/file/nominal.js +2 -2
- package/src/context/liminal.js +2 -2
- package/src/context/scoped.js +20 -2
- package/src/context.js +13 -0
- package/src/element/assertion/contained.js +40 -24
- package/src/element/assertion/defined.js +38 -24
- package/src/element/assertion/property.js +28 -22
- package/src/element/assertion/satisfies.js +21 -13
- package/src/element/assertion/subproof.js +21 -13
- package/src/element/assertion/type.js +28 -22
- package/src/element/assertion.js +4 -4
- package/src/element/assumption.js +32 -24
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +5 -6
- package/src/element/conclusion.js +7 -2
- package/src/element/constructor/bracketed.js +4 -2
- package/src/element/declaration/combinator.js +19 -1
- package/src/element/declaration/constructor.js +123 -60
- package/src/element/deduction.js +7 -2
- package/src/element/derivation.js +2 -3
- package/src/element/equality.js +45 -36
- package/src/element/frame.js +30 -21
- package/src/element/hypothesis.js +9 -6
- package/src/element/judgement.js +65 -21
- package/src/element/metavariable.js +31 -16
- package/src/element/proofAssertion/premise.js +7 -7
- package/src/element/proofAssertion/step.js +16 -10
- package/src/element/proofAssertion/supposition.js +6 -6
- package/src/element/proofAssertion.js +7 -4
- package/src/element/propertyRelation.js +8 -2
- package/src/element/reference.js +31 -21
- package/src/element/rule.js +3 -6
- package/src/element/signature.js +21 -10
- package/src/element/statement.js +15 -15
- package/src/element/subDerivation.js +2 -5
- package/src/element/subproof.js +9 -3
- package/src/element/substitution/frame.js +21 -9
- package/src/element/substitution/reference.js +20 -8
- package/src/element/substitution/statement.js +17 -9
- package/src/element/substitution/term.js +24 -8
- package/src/element/substitution.js +4 -4
- package/src/element/term.js +18 -14
- package/src/element/topLevelAssertion.js +3 -6
- package/src/element/topLevelMetaAssertion.js +3 -6
- package/src/element/variable.js +8 -4
- package/src/process/assign.js +0 -6
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +23 -14
- package/src/process/verify.js +26 -17
- package/src/utilities/element.js +187 -76
- package/src/utilities/unification.js +4 -5
- package/src/utilities/validation.js +83 -75
|
@@ -28,28 +28,30 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
28
28
|
return typeAssertionNode;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
validate(
|
|
32
|
-
let
|
|
31
|
+
validate(stated, context) {
|
|
32
|
+
let typeAssertion = null;
|
|
33
33
|
|
|
34
34
|
const typeAssertionString = this.getString(); ///
|
|
35
35
|
|
|
36
36
|
context.trace(`Validating the '${typeAssertionString}' type assertion...`);
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const validAssertion = this.findValidAssertion(context);
|
|
39
39
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
40
|
+
if (validAssertion) {
|
|
41
|
+
typeAssertion = validAssertion; ///
|
|
42
42
|
|
|
43
43
|
context.debug(`...the '${typeAssertionString}' type assertion is already valid.`);
|
|
44
44
|
} else {
|
|
45
|
+
let validates = false;
|
|
46
|
+
|
|
45
47
|
const typeValidates = this.validateType(context);
|
|
46
48
|
|
|
47
49
|
if (typeValidates) {
|
|
48
50
|
let validatesWhenStated = false,
|
|
49
|
-
|
|
51
|
+
validatesWhenDerived = false;
|
|
50
52
|
|
|
51
53
|
if (stated) {
|
|
52
|
-
validatesWhenStated = this.validateWhenStated(
|
|
54
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
53
55
|
} else {
|
|
54
56
|
validatesWhenDerived = this.validateWhenDerived(context);
|
|
55
57
|
}
|
|
@@ -62,15 +64,17 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
62
64
|
if (validates) {
|
|
63
65
|
const assertion = this; ///
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
typeAssertion = assertion; ///
|
|
66
68
|
|
|
67
|
-
this.assign(
|
|
69
|
+
this.assign(stated, context);
|
|
70
|
+
|
|
71
|
+
context.addAssertion(assertion);
|
|
68
72
|
|
|
69
73
|
context.debug(`...verified the '${typeAssertionString}' type assertion.`);
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
return
|
|
77
|
+
return typeAssertion;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
validateType(context) {
|
|
@@ -98,14 +102,14 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
98
102
|
return typeValidates;
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
validateWhenStated(
|
|
105
|
+
validateWhenStated(context) {
|
|
102
106
|
let validatesWhenStated = false;
|
|
103
107
|
|
|
104
108
|
const typeAssertionString = this.getString(); ///
|
|
105
109
|
|
|
106
110
|
context.trace(`Validating the '${typeAssertionString}' stated type assertion...`);
|
|
107
111
|
|
|
108
|
-
const
|
|
112
|
+
const term = this.term.validate(context, () => {
|
|
109
113
|
let validatesForwards;
|
|
110
114
|
|
|
111
115
|
const termType = this.term.getType(),
|
|
@@ -118,7 +122,9 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
118
122
|
return validatesForwards;
|
|
119
123
|
});
|
|
120
124
|
|
|
121
|
-
if (
|
|
125
|
+
if (term !== null) {
|
|
126
|
+
this.term = term;
|
|
127
|
+
|
|
122
128
|
validatesWhenStated = true;
|
|
123
129
|
}
|
|
124
130
|
|
|
@@ -130,13 +136,13 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
validateWhenDerived(context) {
|
|
133
|
-
let validatesWhenDerived;
|
|
139
|
+
let validatesWhenDerived = false;
|
|
134
140
|
|
|
135
141
|
const typeAssertionString = this.getString(); ///
|
|
136
142
|
|
|
137
143
|
context.trace(`Validating the '${typeAssertionString}' derived type assertion...`);
|
|
138
144
|
|
|
139
|
-
const
|
|
145
|
+
const term = this.term.validate(context, () => {
|
|
140
146
|
let validatesForwards = false;
|
|
141
147
|
|
|
142
148
|
const termType = this.term.getType(),
|
|
@@ -153,7 +159,11 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
153
159
|
return validatesForwards;
|
|
154
160
|
});
|
|
155
161
|
|
|
156
|
-
|
|
162
|
+
if (term !== null) {
|
|
163
|
+
this.term = term;
|
|
164
|
+
|
|
165
|
+
validatesWhenDerived = true;
|
|
166
|
+
}
|
|
157
167
|
|
|
158
168
|
if (validatesWhenDerived) {
|
|
159
169
|
context.debug(`...verified the '${typeAssertionString}' derived type assertion.`);
|
|
@@ -162,11 +172,7 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
162
172
|
return validatesWhenDerived;
|
|
163
173
|
}
|
|
164
174
|
|
|
165
|
-
assign(
|
|
166
|
-
if (assignments === null) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
175
|
+
assign(stated, context) {
|
|
170
176
|
if (!stated) {
|
|
171
177
|
return;
|
|
172
178
|
}
|
|
@@ -175,7 +181,7 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
175
181
|
variableAssigment = variableAssignmentFromTypeAssertion(typeAssertion, context),
|
|
176
182
|
assignment = variableAssigment; ///
|
|
177
183
|
|
|
178
|
-
|
|
184
|
+
context.addAassignment(assignment);
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
static name = "TypeAssertion";
|
package/src/element/assertion.js
CHANGED
|
@@ -22,12 +22,12 @@ export default class Assertion extends Element {
|
|
|
22
22
|
return assertionNodeMatches;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
findValidAssertion(context) {
|
|
26
26
|
const assertionNode = this.getAssertionNode(),
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
assertion = context.findAssertionByAssertionNode(assertionNode),
|
|
28
|
+
validAssertion = assertion; ///
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return validAssertion;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
isEqualTo(assertion) {
|
|
@@ -67,39 +67,41 @@ export default define(class Assumption extends Element {
|
|
|
67
67
|
return comparesToSubstituion;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
findValidAssumption(context) {
|
|
71
71
|
const assumptionNode = this.getAssumptionNode(),
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
assumption = context.findAssumptionByAssumptionNode(assumptionNode),
|
|
73
|
+
validAssumption = assumption; ///
|
|
74
74
|
|
|
75
|
-
return
|
|
75
|
+
return validAssumption;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
validate(
|
|
79
|
-
let
|
|
78
|
+
validate(stated, context) {
|
|
79
|
+
let assumption = null;
|
|
80
80
|
|
|
81
81
|
const assumptionString = this.getString(); ///
|
|
82
82
|
|
|
83
83
|
context.trace(`Validating the '${assumptionString}' assumption...`);
|
|
84
84
|
|
|
85
|
-
const
|
|
85
|
+
const validAssumption = this.findValidAssumption(context);
|
|
86
86
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
87
|
+
if (validAssumption) {
|
|
88
|
+
assumption = validAssumption; ///
|
|
89
89
|
|
|
90
90
|
context.debug(`...the '${assumptionString}' assumption is already valid.`);
|
|
91
91
|
} else {
|
|
92
|
-
|
|
92
|
+
let validates = false;
|
|
93
|
+
|
|
94
|
+
const referenceValidates = this.validateReference(stated, context);
|
|
93
95
|
|
|
94
96
|
if (referenceValidates) {
|
|
95
|
-
const statementValidates = this.validateStatement(
|
|
97
|
+
const statementValidates = this.validateStatement(stated, context);
|
|
96
98
|
|
|
97
99
|
if (statementValidates) {
|
|
98
100
|
let validatesWhenStated = false,
|
|
99
101
|
validatesWhenDerived = false;
|
|
100
102
|
|
|
101
103
|
if (stated) {
|
|
102
|
-
validatesWhenStated = this.validateWhenStated(
|
|
104
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
103
105
|
} else {
|
|
104
106
|
validatesWhenDerived = this.validateWhenDerived(context);
|
|
105
107
|
}
|
|
@@ -111,7 +113,7 @@ export default define(class Assumption extends Element {
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
if (validates) {
|
|
114
|
-
|
|
116
|
+
assumption = this; ///
|
|
115
117
|
|
|
116
118
|
context.addAssumption(assumption);
|
|
117
119
|
|
|
@@ -119,18 +121,22 @@ export default define(class Assumption extends Element {
|
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
return
|
|
124
|
+
return assumption;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
validateReference(
|
|
126
|
-
let referenceValidates;
|
|
127
|
+
validateReference(stated, context) {
|
|
128
|
+
let referenceValidates = false;
|
|
127
129
|
|
|
128
130
|
const assumptionString = this.getString(), ///
|
|
129
131
|
referenceString = this.reference.getString();
|
|
130
132
|
|
|
131
133
|
context.trace(`Validating the '${assumptionString}' assumption's '${referenceString}' reference...`);
|
|
132
134
|
|
|
133
|
-
|
|
135
|
+
const reference = this.reference.validate(context);
|
|
136
|
+
|
|
137
|
+
if (reference !== null) {
|
|
138
|
+
referenceValidates = true;
|
|
139
|
+
}
|
|
134
140
|
|
|
135
141
|
if (referenceValidates) {
|
|
136
142
|
context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' statement.`);
|
|
@@ -139,19 +145,21 @@ export default define(class Assumption extends Element {
|
|
|
139
145
|
return referenceValidates;
|
|
140
146
|
}
|
|
141
147
|
|
|
142
|
-
validateStatement(
|
|
143
|
-
let statementValidates;
|
|
148
|
+
validateStatement(stated, context) {
|
|
149
|
+
let statementValidates = false;
|
|
144
150
|
|
|
145
151
|
const assumptionString = this.getString(), ///
|
|
146
|
-
|
|
152
|
+
statementString = this.statement.getString();
|
|
147
153
|
|
|
148
154
|
context.trace(`Validating the '${assumptionString}' assumption's '${statementString}' statement...`);
|
|
149
155
|
|
|
150
156
|
stated = true; ///
|
|
151
157
|
|
|
152
|
-
|
|
158
|
+
const statement = this.statement.validate(stated, context);
|
|
153
159
|
|
|
154
|
-
|
|
160
|
+
if (statement !== null) {
|
|
161
|
+
statementValidates = true;
|
|
162
|
+
}
|
|
155
163
|
|
|
156
164
|
if (statementValidates) {
|
|
157
165
|
context.debug(`...validated the '${assumptionString}' assumption's '${statementString}' statement.`);
|
|
@@ -160,7 +168,7 @@ export default define(class Assumption extends Element {
|
|
|
160
168
|
return statementValidates;
|
|
161
169
|
}
|
|
162
170
|
|
|
163
|
-
validateReferenceAsMetavariable(
|
|
171
|
+
validateReferenceAsMetavariable(stated, context) {
|
|
164
172
|
let referenceValidatesAsMetavariable;
|
|
165
173
|
|
|
166
174
|
const referenceString = this.reference.getString(),
|
|
@@ -177,7 +185,7 @@ export default define(class Assumption extends Element {
|
|
|
177
185
|
return referenceValidatesAsMetavariable;
|
|
178
186
|
}
|
|
179
187
|
|
|
180
|
-
validateWhenStated(
|
|
188
|
+
validateWhenStated(context) {
|
|
181
189
|
let validatesWhenStated;
|
|
182
190
|
|
|
183
191
|
const assumptionString = this.getString(); ///
|
|
@@ -12,14 +12,14 @@ export default define(class BracketedCombinator extends Combinator {
|
|
|
12
12
|
return bracketedCombinatorNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
unifyStatement(statement,
|
|
15
|
+
unifyStatement(statement, stated, context) {
|
|
16
16
|
let statementUnifies;
|
|
17
17
|
|
|
18
18
|
const statementString = statement.getString();
|
|
19
19
|
|
|
20
20
|
context.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
|
|
21
21
|
|
|
22
|
-
statementUnifies = super.unifyStatement(statement,
|
|
22
|
+
statementUnifies = super.unifyStatement(statement, stated, context);
|
|
23
23
|
|
|
24
24
|
if (statementUnifies) {
|
|
25
25
|
context.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
|
|
@@ -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;
|
|
@@ -47,7 +46,7 @@ export default define(class Combinator extends Element {
|
|
|
47
46
|
return verifies;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
unifyStatement(statement,
|
|
49
|
+
unifyStatement(statement, stated, context) {
|
|
51
50
|
let statementUnifies;
|
|
52
51
|
|
|
53
52
|
const statementString = statement.getString(),
|
|
@@ -64,7 +63,7 @@ export default define(class Combinator extends Element {
|
|
|
64
63
|
context = specifiContext; ///
|
|
65
64
|
|
|
66
65
|
const combinator = this, ///
|
|
67
|
-
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator,
|
|
66
|
+
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, stated, generalContext, specifiContext);
|
|
68
67
|
|
|
69
68
|
statementUnifies = statementUnifiesWithCombinator; ///
|
|
70
69
|
|
|
@@ -35,9 +35,14 @@ export default define(class Conclusion extends Element {
|
|
|
35
35
|
|
|
36
36
|
if (this.statement !== null) {
|
|
37
37
|
attempt((context) => {
|
|
38
|
+
let statementValidates = false;
|
|
39
|
+
|
|
38
40
|
const stated = true,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
statement = this.statement.validate(stated, context);
|
|
42
|
+
|
|
43
|
+
if (statement !== null) {
|
|
44
|
+
statementValidates = true;
|
|
45
|
+
}
|
|
41
46
|
|
|
42
47
|
if (statementValidates) {
|
|
43
48
|
this.setContext(context);
|
|
@@ -32,7 +32,7 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
32
32
|
|
|
33
33
|
term = termFromTermNode(termNode, context);
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
term = term.validate(context, () => {
|
|
36
36
|
let validatesForwards;
|
|
37
37
|
|
|
38
38
|
const type = term.getType();
|
|
@@ -44,7 +44,9 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
44
44
|
return validatesForwards;
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
if (term !== null) {
|
|
48
|
+
validatesForwards = true;
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
return validatesForwards;
|
|
@@ -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/deduction.js
CHANGED
|
@@ -35,9 +35,14 @@ export default define(class Deduction extends Element {
|
|
|
35
35
|
|
|
36
36
|
if (this.statement !== null) {
|
|
37
37
|
attempt((context) => {
|
|
38
|
+
let statementValidates = false;
|
|
39
|
+
|
|
38
40
|
const stated = true,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
statement = this.statement.validate(stated, context);
|
|
42
|
+
|
|
43
|
+
if (statement !== null) {
|
|
44
|
+
statementValidates = true;
|
|
45
|
+
}
|
|
41
46
|
|
|
42
47
|
if (statementValidates) {
|
|
43
48
|
this.setContext(context);
|