occam-nominal 1.0.428 → 1.0.430
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 +5 -1
- package/lib/context.js +5 -1
- package/lib/element/assertion/signature.js +69 -69
- package/lib/element/claim/axiom.js +37 -31
- package/lib/element/label.js +1 -1
- package/lib/element/signature.js +31 -48
- package/lib/node/assertion/signature.js +4 -4
- package/lib/node/header.js +2 -2
- package/lib/utilities/element.js +11 -12
- package/package.json +5 -5
- package/src/context/file/nominal.js +13 -6
- package/src/context.js +8 -1
- package/src/element/assertion/signature.js +77 -72
- package/src/element/claim/axiom.js +51 -42
- package/src/element/label.js +3 -3
- package/src/element/signature.js +34 -60
- package/src/node/assertion/signature.js +5 -5
- package/src/node/header.js +2 -3
- package/src/utilities/element.js +10 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "occam-nominal",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.430",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/occam-nominal",
|
|
7
7
|
"description": "Occam's Nominal language.",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"necessary": "^17.6.3",
|
|
14
|
-
"occam-furtle": "^3.0.
|
|
14
|
+
"occam-furtle": "^3.0.438",
|
|
15
15
|
"occam-grammar-utilities": "^8.1.22",
|
|
16
|
-
"occam-languages": "^2.2.
|
|
16
|
+
"occam-languages": "^2.2.55",
|
|
17
17
|
"occam-query": "^4.1.203"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@swc/core": "1.13.20",
|
|
21
21
|
"decaf-cli": "^1.0.37",
|
|
22
|
-
"occam-model": "^1.0.
|
|
23
|
-
"occam-server": "^7.0.
|
|
22
|
+
"occam-model": "^1.0.572",
|
|
23
|
+
"occam-server": "^7.0.72",
|
|
24
24
|
"watchful-cli": "^1.7.102"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
@@ -621,17 +621,24 @@ export default class NominalFileContext extends FileContext {
|
|
|
621
621
|
|
|
622
622
|
isLabelPresentByLabelNode(labelNode) {
|
|
623
623
|
const labels = this.getLabels(),
|
|
624
|
-
|
|
625
|
-
|
|
624
|
+
labelPresent = labels.some((label) => {
|
|
625
|
+
const labelNodeMatches = label.matchLabelNode(labelNode);
|
|
626
626
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
627
|
+
if (labelNodeMatches) {
|
|
628
|
+
return true;
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
631
|
|
|
632
632
|
return labelPresent;
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
+
isAxiomPresentByReference(reference) {
|
|
636
|
+
const axiom = this.findAxiomByReference(reference),
|
|
637
|
+
axiomPresent = (axiom !== null);
|
|
638
|
+
|
|
639
|
+
return axiomPresent;
|
|
640
|
+
}
|
|
641
|
+
|
|
635
642
|
isTypePresentByTypeName(typeName, includeRelease = true) {
|
|
636
643
|
const type = this.findTypeByTypeName(typeName, includeRelease),
|
|
637
644
|
typePresent = (type !== null);
|
package/src/context.js
CHANGED
|
@@ -417,9 +417,16 @@ export default class Context extends ContextBase {
|
|
|
417
417
|
return declaredMetavariable;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
isAxiomPresentByReference(reference) {
|
|
421
|
+
const context = this.getContext(),
|
|
422
|
+
axiomPresent = context.isAxiomPresentByReference(reference);
|
|
423
|
+
|
|
424
|
+
return axiomPresent;
|
|
425
|
+
}
|
|
426
|
+
|
|
420
427
|
isTermPresentByTermNode(termNode) {
|
|
421
428
|
const context = this.getContext(),
|
|
422
|
-
|
|
429
|
+
termPresent = context.isTermPresentByTermNode(termNode);
|
|
423
430
|
|
|
424
431
|
return termPresent;
|
|
425
432
|
}
|
|
@@ -5,23 +5,23 @@ import { breakPointUtilities } from "occam-languages";
|
|
|
5
5
|
import Assertion from "../assertion";
|
|
6
6
|
|
|
7
7
|
import { define } from "../../elements";
|
|
8
|
+
import { all, every } from "../../utilities/continuation";
|
|
8
9
|
import { reconcile, instantiate } from "../../utilities/context";
|
|
9
10
|
import { instantiateSignatureAssertion } from "../../process/instantiate";
|
|
10
|
-
import {
|
|
11
|
-
import {all, exists} from "../../utilities/continuation";
|
|
11
|
+
import { termsFromSignatureAssertionNode, referenceFromSignatureAssertionNode, signatureAssertionFromStatementNode } from "../../utilities/element";
|
|
12
12
|
|
|
13
13
|
const { breakPointFromJSON } = breakPointUtilities;
|
|
14
14
|
|
|
15
15
|
export default define(class SignatureAssertion extends Assertion {
|
|
16
|
-
constructor(context, string, node, breakPoint,
|
|
16
|
+
constructor(context, string, node, breakPoint, terms, reference) {
|
|
17
17
|
super(context, string, node, breakPoint);
|
|
18
18
|
|
|
19
|
-
this.
|
|
19
|
+
this.terms = terms;
|
|
20
20
|
this.reference = reference;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
return this.
|
|
23
|
+
getTerms() {
|
|
24
|
+
return this.terms;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
getReference() {
|
|
@@ -55,11 +55,11 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
55
55
|
} else {
|
|
56
56
|
assertion = this; ///
|
|
57
57
|
|
|
58
|
-
const
|
|
58
|
+
const validateTerms = this.validateTerms.bind(this),
|
|
59
59
|
validateReference = this.validateReference.bind(this);
|
|
60
60
|
|
|
61
61
|
validates = all([
|
|
62
|
-
|
|
62
|
+
validateTerms,
|
|
63
63
|
validateReference
|
|
64
64
|
], state, context, (state, context) => {
|
|
65
65
|
let validates;
|
|
@@ -81,91 +81,91 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
81
81
|
return validates;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
let
|
|
84
|
+
validateTerm(term, terms, state, context, continuation) {
|
|
85
|
+
let termValidates;
|
|
86
86
|
|
|
87
|
-
const
|
|
87
|
+
const termString = term.getString(),
|
|
88
|
+
signatureAssertionString = this.getString(); ///
|
|
88
89
|
|
|
89
|
-
context.trace(`Validating the '${signatureAssertionString}' signature assertion's
|
|
90
|
+
context.trace(`Validating the '${signatureAssertionString}' signature assertion's '${termString}' term...`);
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
termValidates = term.validate(state, context, (term, context) => {
|
|
93
|
+
let validates;
|
|
92
94
|
|
|
93
|
-
|
|
94
|
-
this.signature = signature;
|
|
95
|
+
terms.push(term);
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
validates = continuation(terms, state, context);
|
|
98
|
+
|
|
99
|
+
return validates;
|
|
100
|
+
});
|
|
98
101
|
|
|
99
|
-
if (
|
|
100
|
-
context.debug(`...validated the '${signatureAssertionString}' signature assertion's
|
|
102
|
+
if (termValidates) {
|
|
103
|
+
context.debug(`...validated the '${signatureAssertionString}' signature assertion's '${termString}' term.`);
|
|
101
104
|
}
|
|
102
105
|
|
|
103
|
-
return
|
|
106
|
+
return termValidates;
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
|
|
107
|
-
let
|
|
109
|
+
validateTerms(state, context, continuation) {
|
|
110
|
+
let termsValidate;
|
|
108
111
|
|
|
109
112
|
const signatureAssertionString = this.getString(); ///
|
|
110
113
|
|
|
111
|
-
context.trace(`Validating the '${signatureAssertionString}' signature assertion's
|
|
112
|
-
|
|
113
|
-
const reference = this.reference.validate(state, context);
|
|
114
|
-
|
|
115
|
-
if (reference !== null) {
|
|
116
|
-
const axiom = context.findAxiomByReference(reference);
|
|
117
|
-
|
|
118
|
-
if (axiom !== null) {
|
|
119
|
-
const satisfiable = axiom.isSatisfiable();
|
|
120
|
-
|
|
121
|
-
if (satisfiable) {
|
|
122
|
-
const signatureUnifies = this.unifySignature(context);
|
|
114
|
+
context.trace(`Validating the '${signatureAssertionString}' signature assertion's terms...`);
|
|
123
115
|
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
const terms = [],
|
|
117
|
+
validateTerm = this.validateTerm.bind(this);
|
|
126
118
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
|
-
const axiomString = axiom.getString();
|
|
119
|
+
termsValidate = every(this.terms, validateTerm, terms, state, context, (terms, state, context) => {
|
|
120
|
+
let termsValidate;
|
|
131
121
|
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
const referencdString = reference.getString();
|
|
122
|
+
termsValidate = continuation(state, context);
|
|
136
123
|
|
|
137
|
-
|
|
124
|
+
if (termsValidate) {
|
|
125
|
+
this.terms = terms;
|
|
138
126
|
}
|
|
139
|
-
}
|
|
140
127
|
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
return termsValidate;
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
if (termsValidate){
|
|
132
|
+
context.debug(`...validated the '${signatureAssertionString}' signature assertion's terms.`);
|
|
143
133
|
}
|
|
144
134
|
|
|
145
|
-
return
|
|
135
|
+
return termsValidate
|
|
146
136
|
}
|
|
147
137
|
|
|
148
|
-
|
|
149
|
-
let
|
|
138
|
+
validateReference(state, context, continuation) {
|
|
139
|
+
let referenceValidates;
|
|
150
140
|
|
|
151
141
|
const signatureAssertionString = this.getString(); ///
|
|
152
142
|
|
|
153
|
-
context.trace(`
|
|
143
|
+
context.trace(`Validating the '${signatureAssertionString}' signature assertion's reference...`);
|
|
154
144
|
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
referenceValidates = this.reference.validate(state, context, (reference, context) => {
|
|
146
|
+
let validates = false;
|
|
157
147
|
|
|
158
|
-
|
|
159
|
-
|
|
148
|
+
const asiomPresent = context.isAxiomPresentByReference(reference);
|
|
149
|
+
|
|
150
|
+
if (asiomPresent) {
|
|
151
|
+
this.reference = reference;
|
|
152
|
+
|
|
153
|
+
validates = continuation(state, context);
|
|
154
|
+
}
|
|
160
155
|
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
return validates;
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (referenceValidates) {
|
|
160
|
+
context.debug(`...validated the '${signatureAssertionString}' signature assertion's reference.`);
|
|
163
161
|
}
|
|
164
162
|
|
|
165
|
-
return
|
|
163
|
+
return referenceValidates;
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
|
|
166
|
+
unifyClaim(claim, context) {
|
|
167
|
+
debugger
|
|
168
|
+
|
|
169
169
|
let claimUnifies;
|
|
170
170
|
|
|
171
171
|
const claimString = claim.getString(),
|
|
@@ -173,12 +173,12 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
173
173
|
|
|
174
174
|
context.trace(`Unifying the '${claimString}' claim with the '${signatureAssertionString}' signature assertion...`);
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
reconcile((context) => {
|
|
177
177
|
const axiom = context.findAxiomByReference(this.reference);
|
|
178
178
|
|
|
179
179
|
axiom.unifySignature(this.signature, context);
|
|
180
180
|
|
|
181
|
-
claimUnifies =
|
|
181
|
+
claimUnifies = axiom.unifyClaim(claim, context);
|
|
182
182
|
}, context);
|
|
183
183
|
|
|
184
184
|
if (claimUnifies) {
|
|
@@ -188,18 +188,23 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
188
188
|
return claimUnifies;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
let stepAndFactOrSubproofsUnify;
|
|
191
|
+
unifyStepAndFactOrSubproofs(step, factOrSubproofs, context, continuation) {
|
|
192
|
+
let stepAndFactOrSubproofsUnify = false;
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
const axiom = context.findAxiomByReference(this.reference)
|
|
194
|
+
return reconcile((context) => {
|
|
195
|
+
const axiom = context.findAxiomByReference(this.reference),
|
|
196
|
+
signatureAssertion = this; ///
|
|
196
197
|
|
|
197
|
-
axiom.
|
|
198
|
+
return axiom.unifySignatureAssertion(signatureAssertion, context, (signatureAssertionUnifies) => {
|
|
199
|
+
if (!signatureAssertionUnifies) {
|
|
200
|
+
return continuation(stepAndFactOrSubproofsUnify);
|
|
201
|
+
}
|
|
198
202
|
|
|
199
|
-
|
|
200
|
-
}, context);
|
|
203
|
+
debugger
|
|
201
204
|
|
|
202
|
-
|
|
205
|
+
// stepAndFactOrSubproofsUnify = axiom.unifyStepAndFactOrSubproofs(step, factOrSubproofs, context);
|
|
206
|
+
});
|
|
207
|
+
}, context);
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
static name = "SignatureAssertion";
|
|
@@ -215,12 +220,12 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
215
220
|
definedAssertionNode = instantiateSignatureAssertion(string, context),
|
|
216
221
|
node = definedAssertionNode, ///
|
|
217
222
|
breakPoint = breakPointFromJSON(json),
|
|
218
|
-
|
|
223
|
+
terms = termsFromSignatureAssertionNode(definedAssertionNode, context),
|
|
219
224
|
reference = referenceFromSignatureAssertionNode(definedAssertionNode, context);
|
|
220
225
|
|
|
221
226
|
context = null;
|
|
222
227
|
|
|
223
|
-
signatureAssertion = new SignatureAssertion(context, string, node, breakPoint,
|
|
228
|
+
signatureAssertion = new SignatureAssertion(context, string, node, breakPoint, terms, reference);
|
|
224
229
|
}, context);
|
|
225
230
|
}
|
|
226
231
|
|
|
@@ -74,30 +74,66 @@ export default define(class Axiom extends Claim {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
unifyClaim(claim, context) {
|
|
78
|
+
debugger
|
|
79
|
+
|
|
80
|
+
let claimUnifies = false;
|
|
79
81
|
|
|
80
82
|
const axiomString = this.getString(), ///
|
|
81
|
-
|
|
83
|
+
claimString = claim.getString();
|
|
82
84
|
|
|
83
|
-
context.trace(`Unifying the '${
|
|
85
|
+
context.trace(`Unifying the '${claimString}' claim with the '${axiomString}' axiom...`);
|
|
84
86
|
|
|
85
|
-
const
|
|
87
|
+
const deduction = claim.getDeduction(),
|
|
88
|
+
deductionUnifies = this.unifyDeduction(deduction, context);
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
if (deductionUnifies) {
|
|
91
|
+
const hypothesesDischarges = claim.dischargeHypotheses(context);
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
if (hypothesesDischarges) {
|
|
94
|
+
const suppositions = claim.getSuppositions(),
|
|
95
|
+
suppositionsUnify = this.unifySuppositions(suppositions, context);
|
|
90
96
|
|
|
91
|
-
|
|
97
|
+
if (suppositionsUnify) {
|
|
98
|
+
claimUnifies = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
92
102
|
|
|
93
|
-
if (
|
|
94
|
-
context.debug(`...unified the '${
|
|
103
|
+
if (claimUnifies) {
|
|
104
|
+
context.debug(`...unified the '${claimString}' claim with the '${axiomString}' axiom.`);
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
return
|
|
107
|
+
return claimUnifies;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
unifySignatureAssertion(signatureAssertion, context, continuation) {
|
|
111
|
+
let signatureAssertionUnifies = false;
|
|
112
|
+
|
|
113
|
+
const axiomString = this.getString(), ///
|
|
114
|
+
signatureAssertionString = signatureAssertion.getString();
|
|
115
|
+
|
|
116
|
+
context.trace(`Unifying the '${signatureAssertionString}' signature assertion with the '${axiomString}' axiom...`);
|
|
117
|
+
|
|
118
|
+
const terms = signatureAssertion.getTerms(),
|
|
119
|
+
signature = this.getSignature();
|
|
120
|
+
|
|
121
|
+
return signature.unifyTerms(terms, context, (termsUnify) => {
|
|
122
|
+
if (termsUnify) {
|
|
123
|
+
signatureAssertionUnifies = true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (signatureAssertionUnifies) {
|
|
127
|
+
context.debug(`...unified the '${signatureAssertionString}' signature assertion with the '${axiomString}' axiom.`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return continuation(signatureAssertionUnifies);
|
|
131
|
+
});
|
|
98
132
|
}
|
|
99
133
|
|
|
100
134
|
unifyDeduction(deduction, context) {
|
|
135
|
+
debugger
|
|
136
|
+
|
|
101
137
|
let deductionUnifies;
|
|
102
138
|
|
|
103
139
|
const axiomString = this.getString(), ///
|
|
@@ -142,6 +178,8 @@ export default define(class Axiom extends Claim {
|
|
|
142
178
|
}
|
|
143
179
|
|
|
144
180
|
unifySupposition(supposition, index, context) {
|
|
181
|
+
debugger
|
|
182
|
+
|
|
145
183
|
let suppositionUnifies = false;
|
|
146
184
|
|
|
147
185
|
const specificSupposition = supposition; ///
|
|
@@ -189,6 +227,8 @@ export default define(class Axiom extends Claim {
|
|
|
189
227
|
}
|
|
190
228
|
|
|
191
229
|
unifySuppositions(suppositions, context) {
|
|
230
|
+
debugger
|
|
231
|
+
|
|
192
232
|
let suppositionsUnify;
|
|
193
233
|
|
|
194
234
|
const specificSuppositions = suppositions; ///
|
|
@@ -209,37 +249,6 @@ export default define(class Axiom extends Claim {
|
|
|
209
249
|
return suppositionsUnify;
|
|
210
250
|
}
|
|
211
251
|
|
|
212
|
-
unifyClaim(claim, context) {
|
|
213
|
-
let claimUnifies = false;
|
|
214
|
-
|
|
215
|
-
const axiomString = this.getString(), ///
|
|
216
|
-
claimString = claim.getString();
|
|
217
|
-
|
|
218
|
-
context.trace(`Unifying the '${claimString}' claim with the '${axiomString}' axiom...`);
|
|
219
|
-
|
|
220
|
-
const deduction = claim.getDeduction(),
|
|
221
|
-
deductionUnifies = this.unifyDeduction(deduction, context);
|
|
222
|
-
|
|
223
|
-
if (deductionUnifies) {
|
|
224
|
-
const hypothesesDischarges = claim.dischargeHypotheses(context);
|
|
225
|
-
|
|
226
|
-
if (hypothesesDischarges) {
|
|
227
|
-
const suppositions = claim.getSuppositions(),
|
|
228
|
-
suppositionsUnify = this.unifySuppositions(suppositions, context);
|
|
229
|
-
|
|
230
|
-
if (suppositionsUnify) {
|
|
231
|
-
claimUnifies = true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (claimUnifies) {
|
|
237
|
-
context.debug(`...unified the '${claimString}' claim with the '${axiomString}' axiom.`);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return claimUnifies;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
252
|
static name = "Axiom";
|
|
244
253
|
|
|
245
254
|
static fromJSON(json, context) { return Claim.fromJSON(Axiom, json, context); }
|
package/src/element/label.js
CHANGED
|
@@ -249,10 +249,10 @@ export default define(class Label extends Element {
|
|
|
249
249
|
|
|
250
250
|
ablate((context) => {
|
|
251
251
|
instantiate((context) => {
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
const string = labelString, ///
|
|
253
|
+
labelNode = instantiateLabel(string, context);
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
label = labelFromLabelNode(labelNode, context);
|
|
256
256
|
}, context);
|
|
257
257
|
}, context);
|
|
258
258
|
|
package/src/element/signature.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
|
-
import { Element, breakPointUtilities
|
|
4
|
+
import { Element, breakPointUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
import { declare } from "../utilities/state";
|
|
8
8
|
import { all, every } from "../utilities/continuation";
|
|
9
9
|
import { instantiateSignature } from "../process/instantiate";
|
|
10
|
-
import {
|
|
11
|
-
import { ablate, attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
10
|
+
import { attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
12
11
|
|
|
13
12
|
const { match } = arrayUtilities,
|
|
14
|
-
{ asynchronousEvery } = continuationUtilities,
|
|
15
13
|
{ breakPointFromJSON, breakPointToBreakPointJSON } = breakPointUtilities;
|
|
16
14
|
|
|
17
15
|
export default define(class Signature extends Element {
|
|
@@ -61,13 +59,6 @@ export default define(class Signature extends Element {
|
|
|
61
59
|
return signatureNodeMatches;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
findSignature(context) {
|
|
65
|
-
const signatureNode = this.getSignatureNode(),
|
|
66
|
-
signature = context.findSignatureBySignatureNode(signatureNode);
|
|
67
|
-
|
|
68
|
-
return signature;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
62
|
verify(context, continuation) {
|
|
72
63
|
let verifies = false;
|
|
73
64
|
|
|
@@ -127,6 +118,31 @@ export default define(class Signature extends Element {
|
|
|
127
118
|
return validates;
|
|
128
119
|
}
|
|
129
120
|
|
|
121
|
+
validateTerm(term, terms, state, context, continuation) {
|
|
122
|
+
let termValidates;
|
|
123
|
+
|
|
124
|
+
const termString = term.getString(),
|
|
125
|
+
signatureString = this.getString(); ///
|
|
126
|
+
|
|
127
|
+
context.trace(`Validating the '${signatureString}' signature's '${termString}' term...`);
|
|
128
|
+
|
|
129
|
+
termValidates = term.validate(state, context, (term, context) => {
|
|
130
|
+
let validates;
|
|
131
|
+
|
|
132
|
+
terms.push(term);
|
|
133
|
+
|
|
134
|
+
validates = continuation(terms, state, context);
|
|
135
|
+
|
|
136
|
+
return validates;
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (termValidates) {
|
|
140
|
+
context.debug(`...validated the '${signatureString}' signature's '${termString}' term.`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return termValidates;
|
|
144
|
+
}
|
|
145
|
+
|
|
130
146
|
validateTerms(state, context, continuation) {
|
|
131
147
|
let termsValidate;
|
|
132
148
|
|
|
@@ -137,7 +153,7 @@ export default define(class Signature extends Element {
|
|
|
137
153
|
const terms = [],
|
|
138
154
|
validateTerm = this.validateTerm.bind(this);
|
|
139
155
|
|
|
140
|
-
termsValidate = every(this.terms, validateTerm, terms, state, context, (state, context) => {
|
|
156
|
+
termsValidate = every(this.terms, validateTerm, terms, state, context, (terms, state, context) => {
|
|
141
157
|
let termsValidate;
|
|
142
158
|
|
|
143
159
|
termsValidate = continuation(state, context);
|
|
@@ -156,35 +172,8 @@ export default define(class Signature extends Element {
|
|
|
156
172
|
return termsValidate
|
|
157
173
|
}
|
|
158
174
|
|
|
159
|
-
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
const termString = term.getString(),
|
|
163
|
-
signatureString = this.getString(); ///
|
|
164
|
-
|
|
165
|
-
context.trace(`Validating the '${signatureString}' signature's '${termString}' term...`);
|
|
166
|
-
|
|
167
|
-
termValidates = term.validate(state, context, (term, context) => {
|
|
168
|
-
let validates;
|
|
169
|
-
|
|
170
|
-
validates = continuation(terms, state, context);
|
|
171
|
-
|
|
172
|
-
if (validates) {
|
|
173
|
-
terms.push(term);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return validates;
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
if (termValidates) {
|
|
180
|
-
context.debug(`...validated the '${signatureString}' signature's '${termString}' term.`);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return termValidates;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
unifySignature(signature, context) {
|
|
187
|
-
let signatureUnifies;
|
|
175
|
+
unifyTerms(terms, context, continuation) {
|
|
176
|
+
let termsUnify;
|
|
188
177
|
|
|
189
178
|
debugger
|
|
190
179
|
|
|
@@ -206,7 +195,7 @@ export default define(class Signature extends Element {
|
|
|
206
195
|
|
|
207
196
|
debugger
|
|
208
197
|
|
|
209
|
-
|
|
198
|
+
termsUnify = reconcile((specificContext) => {
|
|
210
199
|
match(generalTerms, specificTerms, (generalTerm, specificTerm) => {
|
|
211
200
|
let termUnifies;
|
|
212
201
|
|
|
@@ -217,16 +206,16 @@ export default define(class Signature extends Element {
|
|
|
217
206
|
}
|
|
218
207
|
});
|
|
219
208
|
|
|
220
|
-
if (
|
|
209
|
+
if (termsUnify) {
|
|
221
210
|
specificContext.commit(context);
|
|
222
211
|
}
|
|
223
212
|
}, specificContext);
|
|
224
213
|
|
|
225
|
-
if (
|
|
214
|
+
if (termsUnify) {
|
|
226
215
|
context.debug(`...unified the '${specificSignatureString}' signature with the '${generalSignatureString}' signature.`);
|
|
227
216
|
}
|
|
228
217
|
|
|
229
|
-
return
|
|
218
|
+
return termsUnify;
|
|
230
219
|
}
|
|
231
220
|
|
|
232
221
|
toJSON() {
|
|
@@ -272,21 +261,6 @@ export default define(class Signature extends Element {
|
|
|
272
261
|
|
|
273
262
|
return signature;
|
|
274
263
|
}
|
|
275
|
-
|
|
276
|
-
static fromSignatureString(signatureString, context) {
|
|
277
|
-
let signature;
|
|
278
|
-
|
|
279
|
-
ablate((context) => {
|
|
280
|
-
instantiate((context) => {
|
|
281
|
-
const string = signatureString, ///
|
|
282
|
-
signatureNode = instantiateSignature(string, context);
|
|
283
|
-
|
|
284
|
-
signature = signatureFromSignatureNode(signatureNode, context);
|
|
285
|
-
}, context);
|
|
286
|
-
}, context);
|
|
287
|
-
|
|
288
|
-
return signature;
|
|
289
|
-
}
|
|
290
264
|
});
|
|
291
265
|
|
|
292
266
|
function termsFromSignatureNode(signatureNode, context) {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import AssertionNode from "../../node/assertion";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { TERM_RULE_NAME, METAVARIABLE_RULE_NAME } from "../../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class SignatureAssertionNode extends AssertionNode {
|
|
8
|
-
|
|
9
|
-
const ruleName =
|
|
10
|
-
|
|
8
|
+
getTermNodes() {
|
|
9
|
+
const ruleName = TERM_RULE_NAME,
|
|
10
|
+
termNodes = this.getNodesByRuleName(ruleName);
|
|
11
11
|
|
|
12
|
-
return
|
|
12
|
+
return termNodes;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
getMetavariableNode() {
|
package/src/node/header.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { NonTerminalNode } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { PARENTHESISED_LABEL_RULE_NAME, PARENTHESISED_LABELS_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class HeaderNode extends NonTerminalNode {
|
|
8
8
|
getLabelNodes() {
|
|
@@ -30,8 +30,7 @@ export default class HeaderNode extends NonTerminalNode {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
getSignatureNode() {
|
|
33
|
-
const
|
|
34
|
-
signatureNode = this.getNodeByRuleName(ruleName);
|
|
33
|
+
const signatureNode = null;
|
|
35
34
|
|
|
36
35
|
return signatureNode;
|
|
37
36
|
}
|