occam-nominal 1.0.427 → 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 +39 -34
- package/lib/element/label.js +1 -1
- package/lib/element/signature.js +53 -58
- package/lib/node/assertion/signature.js +4 -4
- package/lib/node/header.js +2 -2
- package/lib/utilities/continuation.js +1 -18
- 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 +54 -46
- package/src/element/label.js +3 -3
- package/src/element/signature.js +58 -63
- package/src/node/assertion/signature.js +5 -5
- package/src/node/header.js +2 -3
- package/src/utilities/continuation.js +0 -23
- package/src/utilities/element.js +10 -15
package/src/element/signature.js
CHANGED
|
@@ -1,16 +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
|
+
import { declare } from "../utilities/state";
|
|
8
|
+
import { all, every } from "../utilities/continuation";
|
|
7
9
|
import { instantiateSignature } from "../process/instantiate";
|
|
8
|
-
import {
|
|
9
|
-
import { ablate, attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
10
|
-
import {all} from "../utilities/continuation";
|
|
10
|
+
import { attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
11
11
|
|
|
12
12
|
const { match } = arrayUtilities,
|
|
13
|
-
{ asynchronousEvery } = continuationUtilities,
|
|
14
13
|
{ breakPointFromJSON, breakPointToBreakPointJSON } = breakPointUtilities;
|
|
15
14
|
|
|
16
15
|
export default define(class Signature extends Element {
|
|
@@ -60,44 +59,33 @@ export default define(class Signature extends Element {
|
|
|
60
59
|
return signatureNodeMatches;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
const signatureNode = this.getSignatureNode(),
|
|
65
|
-
signature = context.findSignatureBySignatureNode(signatureNode);
|
|
66
|
-
|
|
67
|
-
return signature;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
verify(context) {
|
|
62
|
+
verify(context, continuation) {
|
|
71
63
|
let verifies = false;
|
|
72
64
|
|
|
73
|
-
const signatureString = this.getString();
|
|
65
|
+
const signatureString = this.getString(); ///
|
|
74
66
|
|
|
75
67
|
context.trace(`Verifying the '${signatureString}' signature...`);
|
|
76
68
|
|
|
77
|
-
|
|
69
|
+
declare((state) => {
|
|
70
|
+
const validates = this.validate(state, context, (conclusion, context) => true);
|
|
78
71
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (verifies) {
|
|
86
|
-
this.commit(context);
|
|
87
|
-
}
|
|
72
|
+
if (validates) {
|
|
73
|
+
verifies = true;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
88
76
|
|
|
89
77
|
if (verifies) {
|
|
90
|
-
context.debug(`...
|
|
78
|
+
context.debug(`...verified the '${signatureString}' signature.`);
|
|
91
79
|
}
|
|
92
80
|
|
|
93
|
-
return verifies;
|
|
81
|
+
return continuation(verifies, context);
|
|
94
82
|
}
|
|
95
83
|
|
|
96
84
|
validate(state, context, continuation) {
|
|
97
85
|
let validates;
|
|
98
86
|
|
|
99
87
|
const specificContext = context, ///
|
|
100
|
-
signatureString = this.getString();
|
|
88
|
+
signatureString = this.getString();
|
|
101
89
|
|
|
102
90
|
context.trace(`Validating the '${signatureString}' signature...`);
|
|
103
91
|
|
|
@@ -130,32 +118,52 @@ export default define(class Signature extends Element {
|
|
|
130
118
|
return validates;
|
|
131
119
|
}
|
|
132
120
|
|
|
133
|
-
|
|
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
|
+
|
|
146
|
+
validateTerms(state, context, continuation) {
|
|
134
147
|
let termsValidate;
|
|
135
148
|
|
|
136
149
|
const signatureString = this.getString(); ///
|
|
137
150
|
|
|
138
151
|
context.trace(`Validating the '${signatureString}' signature's terms...`);
|
|
139
152
|
|
|
140
|
-
const terms = []
|
|
153
|
+
const terms = [],
|
|
154
|
+
validateTerm = this.validateTerm.bind(this);
|
|
141
155
|
|
|
142
|
-
termsValidate =
|
|
143
|
-
|
|
144
|
-
const validatesForwards = true;
|
|
156
|
+
termsValidate = every(this.terms, validateTerm, terms, state, context, (terms, state, context) => {
|
|
157
|
+
let termsValidate;
|
|
145
158
|
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
if (term !== null) {
|
|
150
|
-
terms.push(term);
|
|
159
|
+
termsValidate = continuation(state, context);
|
|
151
160
|
|
|
152
|
-
|
|
161
|
+
if (termsValidate) {
|
|
162
|
+
this.terms = terms;
|
|
153
163
|
}
|
|
154
|
-
});
|
|
155
164
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
165
|
+
return termsValidate;
|
|
166
|
+
});
|
|
159
167
|
|
|
160
168
|
if (termsValidate){
|
|
161
169
|
context.debug(`...validated the '${signatureString}' signature's terms.`);
|
|
@@ -164,8 +172,10 @@ export default define(class Signature extends Element {
|
|
|
164
172
|
return termsValidate
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
|
|
168
|
-
let
|
|
175
|
+
unifyTerms(terms, context, continuation) {
|
|
176
|
+
let termsUnify;
|
|
177
|
+
|
|
178
|
+
debugger
|
|
169
179
|
|
|
170
180
|
const generalSignature = this, ///
|
|
171
181
|
specificSignature = signature, ///
|
|
@@ -185,7 +195,7 @@ export default define(class Signature extends Element {
|
|
|
185
195
|
|
|
186
196
|
debugger
|
|
187
197
|
|
|
188
|
-
|
|
198
|
+
termsUnify = reconcile((specificContext) => {
|
|
189
199
|
match(generalTerms, specificTerms, (generalTerm, specificTerm) => {
|
|
190
200
|
let termUnifies;
|
|
191
201
|
|
|
@@ -196,16 +206,16 @@ export default define(class Signature extends Element {
|
|
|
196
206
|
}
|
|
197
207
|
});
|
|
198
208
|
|
|
199
|
-
if (
|
|
209
|
+
if (termsUnify) {
|
|
200
210
|
specificContext.commit(context);
|
|
201
211
|
}
|
|
202
212
|
}, specificContext);
|
|
203
213
|
|
|
204
|
-
if (
|
|
214
|
+
if (termsUnify) {
|
|
205
215
|
context.debug(`...unified the '${specificSignatureString}' signature with the '${generalSignatureString}' signature.`);
|
|
206
216
|
}
|
|
207
217
|
|
|
208
|
-
return
|
|
218
|
+
return termsUnify;
|
|
209
219
|
}
|
|
210
220
|
|
|
211
221
|
toJSON() {
|
|
@@ -251,21 +261,6 @@ export default define(class Signature extends Element {
|
|
|
251
261
|
|
|
252
262
|
return signature;
|
|
253
263
|
}
|
|
254
|
-
|
|
255
|
-
static fromSignatureString(signatureString, context) {
|
|
256
|
-
let signature;
|
|
257
|
-
|
|
258
|
-
ablate((context) => {
|
|
259
|
-
instantiate((context) => {
|
|
260
|
-
const string = signatureString, ///
|
|
261
|
-
signatureNode = instantiateSignature(string, context);
|
|
262
|
-
|
|
263
|
-
signature = signatureFromSignatureNode(signatureNode, context);
|
|
264
|
-
}, context);
|
|
265
|
-
}, context);
|
|
266
|
-
|
|
267
|
-
return signature;
|
|
268
|
-
}
|
|
269
264
|
});
|
|
270
265
|
|
|
271
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
|
}
|
|
@@ -1,28 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export function any(array, callback, ...initialArguments) {
|
|
4
|
-
let success = false;
|
|
5
|
-
|
|
6
|
-
const continuation = initialArguments.pop(),
|
|
7
|
-
length = array.length;
|
|
8
|
-
|
|
9
|
-
let count = 0;
|
|
10
|
-
|
|
11
|
-
for (let index = 0; index < length; index++) {
|
|
12
|
-
const element = array[index];
|
|
13
|
-
|
|
14
|
-
success = callback(element, ...initialArguments, continuation);
|
|
15
|
-
|
|
16
|
-
if (success) {
|
|
17
|
-
count++;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
success = (count >= 1);
|
|
22
|
-
|
|
23
|
-
return success;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
3
|
export function one(array, callback, ...initialArguments) {
|
|
27
4
|
let success = false;
|
|
28
5
|
|
package/src/utilities/element.js
CHANGED
|
@@ -778,12 +778,12 @@ export function signatureAssertionFromSignatureAssertionNode(signatureAssertionN
|
|
|
778
778
|
node = signatureAssertionNode, ///
|
|
779
779
|
string = context.nodeAsString(node),
|
|
780
780
|
breakPoint = null,
|
|
781
|
-
|
|
781
|
+
terms = termsFromSignatureAssertionNode(signatureAssertionNode, context),
|
|
782
782
|
reference = referenceFromSignatureAssertionNode(signatureAssertionNode, context);
|
|
783
783
|
|
|
784
784
|
context = null;
|
|
785
785
|
|
|
786
|
-
const signatureAssertion = new SignatureAssertion(context, string, node, breakPoint,
|
|
786
|
+
const signatureAssertion = new SignatureAssertion(context, string, node, breakPoint, terms, reference);
|
|
787
787
|
|
|
788
788
|
return signatureAssertion;
|
|
789
789
|
}
|
|
@@ -1208,10 +1208,7 @@ export function signatureFromClaimNode(claimNode, context) {
|
|
|
1208
1208
|
const signatureNode = claimNode.getSignatureNode();
|
|
1209
1209
|
|
|
1210
1210
|
if (signatureNode !== null) {
|
|
1211
|
-
|
|
1212
|
-
signatureString = context.nodeAsString(signatureNode);
|
|
1213
|
-
|
|
1214
|
-
signature = Signature.fromSignatureString(signatureString, context);
|
|
1211
|
+
signature = signatureFromSignatureNode(signatureNode, context);
|
|
1215
1212
|
}
|
|
1216
1213
|
|
|
1217
1214
|
return signature;
|
|
@@ -1810,6 +1807,13 @@ export function parametersFromProcedureCallNode(procedureCallNode, context) {
|
|
|
1810
1807
|
return parameters;
|
|
1811
1808
|
}
|
|
1812
1809
|
|
|
1810
|
+
export function termsFromSignatureAssertionNode(signatureAssertionNode, context) {
|
|
1811
|
+
const termNodes = signatureAssertionNode.getTermNodes(),
|
|
1812
|
+
terms = termsFromTermNodes(termNodes, context);
|
|
1813
|
+
|
|
1814
|
+
return terms;
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1813
1817
|
export function typeFromPropertyDeclarationNode(propertyDeclarationNode, context) {
|
|
1814
1818
|
const typeNode = propertyDeclarationNode.getTypeNode(),
|
|
1815
1819
|
type = typeFromTypeNode(typeNode, context);
|
|
@@ -2018,15 +2022,6 @@ export function statementFromContainedAssertionNode(containedAssertionNode, cont
|
|
|
2018
2022
|
return statement;
|
|
2019
2023
|
}
|
|
2020
2024
|
|
|
2021
|
-
export function signatureFromSignatureAssertionNode(signatureAssertionNode, context) {
|
|
2022
|
-
const { Signature } = elements,
|
|
2023
|
-
signatureNode = signatureAssertionNode.getSignatureNode(),
|
|
2024
|
-
signatureString = context.nodeAsString(signatureNode),
|
|
2025
|
-
signature = Signature.fromSignatureString(signatureString, context);
|
|
2026
|
-
|
|
2027
|
-
return signature;
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
2025
|
export function referenceFromSignatureAssertionNode(signatureAssertionNode, context) {
|
|
2031
2026
|
const metavariableNode = signatureAssertionNode.getMetavariableNode(),
|
|
2032
2027
|
reference = referenceFromMetavariableNode(metavariableNode, context);
|