occam-verify-cli 0.0.316 → 0.0.318
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/bin/callbacks.js +27 -0
- package/bin/main.js +3 -5
- package/bin/messages.js +11 -0
- package/bin/utilities/logging.js +2 -10
- package/bin/utilities/release.js +68 -43
- package/lib/callbacks.js +68 -0
- package/lib/context/file.js +58 -81
- package/lib/context/metaproof.js +30 -118
- package/lib/context/proof.js +73 -137
- package/lib/context/release.js +81 -15
- package/lib/index.js +5 -1
- package/lib/mixins/callbacks.js +27 -0
- package/lib/mixins/file.js +23 -0
- package/lib/mixins/logging.js +39 -0
- package/lib/rule.js +3 -3
- package/lib/verify/IndicativeConditional.js +9 -5
- package/lib/verify/assertion/type.js +12 -10
- package/lib/verify/axiom.js +10 -14
- package/lib/verify/conclusion.js +5 -3
- package/lib/verify/conditinalInference.js +7 -5
- package/lib/verify/declaration/combinator.js +7 -3
- package/lib/verify/declaration/constructor.js +7 -3
- package/lib/verify/declaration/topLevel.js +11 -9
- package/lib/verify/declaration/type.js +8 -3
- package/lib/verify/declaration/variable.js +7 -3
- package/lib/verify/equality.js +8 -6
- package/lib/verify/file.js +7 -9
- package/lib/verify/label.js +6 -4
- package/lib/verify/labels.js +5 -4
- package/lib/verify/metaDerivation.js +21 -18
- package/lib/verify/metaproof.js +6 -4
- package/lib/verify/metastatement/qualified.js +7 -5
- package/lib/verify/metastatement/unqualified.js +7 -5
- package/lib/verify/premiseOrPremises.js +11 -12
- package/lib/verify/release.js +28 -18
- package/lib/verify/rule.js +11 -14
- package/lib/verify/statement/qualified.js +7 -3
- package/lib/verify/statement/unqualified.js +6 -4
- package/lib/verify/statement.js +8 -10
- package/lib/verify/statementAsCombinator.js +33 -36
- package/lib/verify/term.js +4 -2
- package/lib/verify/termAsConstructor.js +38 -39
- package/lib/verify/termAsVariable.js +4 -2
- package/lib/verify/type.js +18 -14
- package/lib/verify/unconditionalInference.js +5 -3
- package/lib/verify/variable.js +13 -10
- package/package.json +2 -2
- package/src/callbacks.js +27 -0
- package/src/context/file.js +62 -61
- package/src/context/metaproof.js +29 -44
- package/src/context/proof.js +51 -64
- package/src/context/release.js +33 -11
- package/src/index.js +1 -0
- package/src/mixins/callbacks.js +15 -0
- package/src/mixins/file.js +12 -0
- package/src/mixins/logging.js +24 -0
- package/src/rule.js +2 -2
- package/src/verify/IndicativeConditional.js +18 -9
- package/src/verify/assertion/type.js +15 -8
- package/src/verify/axiom.js +15 -17
- package/src/verify/conclusion.js +8 -2
- package/src/verify/conditinalInference.js +10 -4
- package/src/verify/declaration/combinator.js +12 -3
- package/src/verify/declaration/constructor.js +12 -3
- package/src/verify/declaration/topLevel.js +15 -9
- package/src/verify/declaration/type.js +14 -4
- package/src/verify/declaration/variable.js +12 -3
- package/src/verify/equality.js +11 -4
- package/src/verify/file.js +6 -8
- package/src/verify/label.js +9 -3
- package/src/verify/labels.js +5 -3
- package/src/verify/metaDerivation.js +26 -19
- package/src/verify/metaproof.js +9 -3
- package/src/verify/metastatement/qualified.js +10 -4
- package/src/verify/metastatement/unqualified.js +10 -4
- package/src/verify/premiseOrPremises.js +18 -14
- package/src/verify/release.js +45 -27
- package/src/verify/rule.js +15 -16
- package/src/verify/statement/qualified.js +12 -3
- package/src/verify/statement/unqualified.js +9 -3
- package/src/verify/statement.js +10 -9
- package/src/verify/statementAsCombinator.js +45 -46
- package/src/verify/term.js +7 -1
- package/src/verify/termAsConstructor.js +48 -45
- package/src/verify/termAsVariable.js +7 -1
- package/src/verify/type.js +25 -21
- package/src/verify/unconditionalInference.js +8 -2
- package/src/verify/variable.js +18 -11
- package/lib/mixins/log.js +0 -41
- package/lib/verify/supposition.js +0 -29
- package/src/mixins/log.js +0 -28
- package/src/verify/supposition.js +0 -22
package/src/context/file.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { levels } from "necessary";
|
|
4
3
|
import { rewriteNodes } from "occam-grammar-utilities";
|
|
5
4
|
|
|
5
|
+
import loggingMixins from "../mixins/logging";
|
|
6
|
+
|
|
6
7
|
import { push } from "../utilities/array";
|
|
7
8
|
import { leastLineIndexFromNodeAndTokens, greatestLineIndexFromNodeAndTokens } from "../utilities/tokens";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default class FileContext {
|
|
12
|
-
constructor(filePath, tokens, node, rules, types, axioms, variables, combinators, constructors, releaseContext) {
|
|
10
|
+
class FileContext {
|
|
11
|
+
constructor(filePath, context, tokens, node, rules, types, axioms, variables, combinators, constructors) {
|
|
13
12
|
this.filePath = filePath;
|
|
13
|
+
this.context = context;
|
|
14
14
|
this.tokens = tokens;
|
|
15
15
|
this.node = node;
|
|
16
16
|
this.rules = rules;
|
|
@@ -19,13 +19,16 @@ export default class FileContext {
|
|
|
19
19
|
this.variables = variables;
|
|
20
20
|
this.combinators = combinators;
|
|
21
21
|
this.constructors = constructors;
|
|
22
|
-
this.releaseContext = releaseContext;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
getFilePath() {
|
|
26
25
|
return this.filePath;
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
getContext() {
|
|
29
|
+
return this.context;
|
|
30
|
+
}
|
|
31
|
+
|
|
29
32
|
getTokens() {
|
|
30
33
|
return this.tokens;
|
|
31
34
|
}
|
|
@@ -34,13 +37,17 @@ export default class FileContext {
|
|
|
34
37
|
return this.node;
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
getVariables() {
|
|
41
|
+
return this.variables;
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
getRules(bubble = true) {
|
|
38
45
|
const rules = [
|
|
39
46
|
...this.rules
|
|
40
47
|
];
|
|
41
48
|
|
|
42
49
|
if (bubble) {
|
|
43
|
-
const releaseContextRules = this.
|
|
50
|
+
const releaseContextRules = this.context.getRules();
|
|
44
51
|
|
|
45
52
|
push(rules, releaseContextRules);
|
|
46
53
|
}
|
|
@@ -54,7 +61,7 @@ export default class FileContext {
|
|
|
54
61
|
];
|
|
55
62
|
|
|
56
63
|
if (bubble) {
|
|
57
|
-
const releaseContextTypes = this.
|
|
64
|
+
const releaseContextTypes = this.context.getTypes();
|
|
58
65
|
|
|
59
66
|
push(types, releaseContextTypes);
|
|
60
67
|
}
|
|
@@ -68,7 +75,7 @@ export default class FileContext {
|
|
|
68
75
|
];
|
|
69
76
|
|
|
70
77
|
if (bubble) {
|
|
71
|
-
const releaseContextAxioms = this.
|
|
78
|
+
const releaseContextAxioms = this.context.getAxioms();
|
|
72
79
|
|
|
73
80
|
push(axioms, releaseContextAxioms);
|
|
74
81
|
}
|
|
@@ -76,30 +83,13 @@ export default class FileContext {
|
|
|
76
83
|
return axioms;
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
getLabels() {
|
|
80
|
-
const axioms = this.getAxioms(),
|
|
81
|
-
labels = axioms.reduce((labels, axiom) => {
|
|
82
|
-
const axiomLabels = axiom.getLabels();
|
|
83
|
-
|
|
84
|
-
push(labels, axiomLabels);
|
|
85
|
-
|
|
86
|
-
return labels;
|
|
87
|
-
}, []);
|
|
88
|
-
|
|
89
|
-
return labels;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getVariables() {
|
|
93
|
-
return this.variables;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
86
|
getCombinators(bubble = true) {
|
|
97
87
|
const combinators = [
|
|
98
88
|
...this.combinators
|
|
99
89
|
];
|
|
100
90
|
|
|
101
91
|
if (bubble) {
|
|
102
|
-
const releaseContextCombinators = this.
|
|
92
|
+
const releaseContextCombinators = this.context.getCombinators();
|
|
103
93
|
|
|
104
94
|
push(combinators, releaseContextCombinators);
|
|
105
95
|
}
|
|
@@ -113,7 +103,7 @@ export default class FileContext {
|
|
|
113
103
|
];
|
|
114
104
|
|
|
115
105
|
if (bubble) {
|
|
116
|
-
const releaseContextConstructors = this.
|
|
106
|
+
const releaseContextConstructors = this.context.getConstructors();
|
|
117
107
|
|
|
118
108
|
push(constructors, releaseContextConstructors);
|
|
119
109
|
}
|
|
@@ -121,12 +111,14 @@ export default class FileContext {
|
|
|
121
111
|
return constructors;
|
|
122
112
|
}
|
|
123
113
|
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
getAssertions() {
|
|
115
|
+
const assertions = []; ///
|
|
116
|
+
|
|
117
|
+
return assertions;
|
|
126
118
|
}
|
|
127
119
|
|
|
128
120
|
getMetaAssertions() {
|
|
129
|
-
const metaAssertions = [];
|
|
121
|
+
const metaAssertions = []; ///
|
|
130
122
|
|
|
131
123
|
return metaAssertions;
|
|
132
124
|
}
|
|
@@ -164,7 +156,7 @@ export default class FileContext {
|
|
|
164
156
|
axioms = this.getAxioms(),
|
|
165
157
|
axiom = axioms.find((axiom) => {
|
|
166
158
|
const axiomLabels = axiom.getLabels(),
|
|
167
|
-
|
|
159
|
+
axiomLabelsIncludesLabel = axiomLabels.includes(label);
|
|
168
160
|
|
|
169
161
|
if (axiomLabelsIncludesLabel) {
|
|
170
162
|
return true;
|
|
@@ -176,7 +168,8 @@ export default class FileContext {
|
|
|
176
168
|
|
|
177
169
|
findVariableByVariableName(variableName) {
|
|
178
170
|
const name = variableName, ///
|
|
179
|
-
|
|
171
|
+
variables = this.getVariables(),
|
|
172
|
+
variable = variables.find((variable) => {
|
|
180
173
|
const matches = variable.matchName(name);
|
|
181
174
|
|
|
182
175
|
if (matches) {
|
|
@@ -187,40 +180,41 @@ export default class FileContext {
|
|
|
187
180
|
return variable;
|
|
188
181
|
}
|
|
189
182
|
|
|
190
|
-
isDerived() {
|
|
191
|
-
const derived = false;
|
|
192
|
-
|
|
193
|
-
return derived;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
183
|
isLabelPresent(label) {
|
|
197
184
|
const labels = this.getLabels(),
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
labelsIncludesLabel = labels.includes(label),
|
|
186
|
+
labelPresent = labelsIncludesLabel; ///
|
|
200
187
|
|
|
201
188
|
return labelPresent;
|
|
202
189
|
}
|
|
203
190
|
|
|
204
|
-
matchMetaAssertion(metaAssertion) {
|
|
205
|
-
const metaAssertionMatches = false;
|
|
206
|
-
|
|
207
|
-
return metaAssertionMatches;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
191
|
isTypePresentByTypeName(typeName) {
|
|
211
192
|
const type = this.findTypeByTypeName(typeName),
|
|
212
|
-
|
|
193
|
+
typePresent = (type !== null);
|
|
213
194
|
|
|
214
195
|
return typePresent;
|
|
215
196
|
}
|
|
216
197
|
|
|
217
198
|
isVariablePresentByVariableName(variableName) {
|
|
218
199
|
const variable = this.findVariableByVariableName(variableName),
|
|
219
|
-
|
|
200
|
+
variablePresent = (variable !== null);
|
|
220
201
|
|
|
221
202
|
return variablePresent;
|
|
222
203
|
}
|
|
223
204
|
|
|
205
|
+
getLabels() {
|
|
206
|
+
const axioms = this.getAxioms(),
|
|
207
|
+
labels = axioms.reduce((labels, axiom) => {
|
|
208
|
+
const axiomLabels = axiom.getLabels();
|
|
209
|
+
|
|
210
|
+
push(labels, axiomLabels);
|
|
211
|
+
|
|
212
|
+
return labels;
|
|
213
|
+
}, []);
|
|
214
|
+
|
|
215
|
+
return labels;
|
|
216
|
+
}
|
|
217
|
+
|
|
224
218
|
addType(type) {
|
|
225
219
|
this.types.push(type);
|
|
226
220
|
}
|
|
@@ -245,23 +239,25 @@ export default class FileContext {
|
|
|
245
239
|
this.constructors.push(constructor);
|
|
246
240
|
}
|
|
247
241
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
info(message, node) { this.log(node, INFO_LEVEL, message); }
|
|
242
|
+
halt(node) {
|
|
243
|
+
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
|
|
244
|
+
greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
|
|
253
245
|
|
|
254
|
-
|
|
246
|
+
this.context.halt(this.filePath, leastLineIndex, greatestLineIndex);
|
|
247
|
+
}
|
|
255
248
|
|
|
256
|
-
|
|
249
|
+
begin(node) {
|
|
250
|
+
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
|
|
251
|
+
greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
|
|
257
252
|
|
|
258
|
-
|
|
253
|
+
this.context.begin(this.filePath, leastLineIndex, greatestLineIndex);
|
|
254
|
+
}
|
|
259
255
|
|
|
260
|
-
|
|
256
|
+
complete(node) {
|
|
261
257
|
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
|
|
262
258
|
greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
|
|
263
259
|
|
|
264
|
-
this.
|
|
260
|
+
this.context.complete(this.filePath, leastLineIndex, greatestLineIndex);
|
|
265
261
|
}
|
|
266
262
|
|
|
267
263
|
static fromReleaseContextAndFilePath(releaseContext, filePath) {
|
|
@@ -272,14 +268,19 @@ export default class FileContext {
|
|
|
272
268
|
|
|
273
269
|
rewriteNodes(node);
|
|
274
270
|
|
|
275
|
-
const
|
|
271
|
+
const context = releaseContext, ///
|
|
272
|
+
rules = [],
|
|
276
273
|
types = [],
|
|
277
274
|
axioms = [],
|
|
278
275
|
variables = [],
|
|
279
276
|
combinators = [],
|
|
280
277
|
constructors = [],
|
|
281
|
-
fileContext = new FileContext(filePath, tokens, node, rules, types, axioms, variables, combinators, constructors
|
|
278
|
+
fileContext = new FileContext(filePath, context, tokens, node, rules, types, axioms, variables, combinators, constructors);
|
|
282
279
|
|
|
283
280
|
return fileContext;
|
|
284
281
|
}
|
|
285
282
|
}
|
|
283
|
+
|
|
284
|
+
Object.assign(FileContext.prototype, loggingMixins);
|
|
285
|
+
|
|
286
|
+
export default FileContext;
|
package/src/context/metaproof.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import fileMixins from "../mixins/file";
|
|
4
|
+
import loggingMixins from "../mixins/logging";
|
|
5
|
+
import callbacksMixins from "../mixins/callbacks";
|
|
6
|
+
|
|
7
|
+
class MetaproofContext {
|
|
4
8
|
constructor(context, derived, metaAssertions) {
|
|
5
9
|
this.context = context;
|
|
6
10
|
this.derived = derived;
|
|
@@ -18,7 +22,7 @@ export default class MetaproofContext {
|
|
|
18
22
|
getMetaAssertions() {
|
|
19
23
|
let metaAssertions = this.context.getMetaAssertions();
|
|
20
24
|
|
|
21
|
-
metaAssertions = [
|
|
25
|
+
metaAssertions = [ ///
|
|
22
26
|
...metaAssertions,
|
|
23
27
|
...this.metaAssertions
|
|
24
28
|
];
|
|
@@ -26,25 +30,13 @@ export default class MetaproofContext {
|
|
|
26
30
|
return metaAssertions;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
getAxioms() { return this.context.getAxioms(); }
|
|
34
|
-
|
|
35
|
-
getCombinators() { return this.context.getCombinators(); }
|
|
36
|
-
|
|
37
|
-
getConstructors() { return this.context.getConstructors(); }
|
|
38
|
-
|
|
39
|
-
findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
40
|
-
|
|
41
|
-
findRuleByReferenceName(referenceName) { return this.context.findRuleByReferenceName(referenceName); }
|
|
42
|
-
|
|
43
|
-
findVariableByVariableName(variableName) { return this.context.findVariableByVariableName(variableName); }
|
|
44
|
-
|
|
45
|
-
isLabelPresent(label) { return this.context.isLabelPresent(label); }
|
|
33
|
+
setDerived(derived) {
|
|
34
|
+
this.derived = derived;
|
|
35
|
+
}
|
|
46
36
|
|
|
47
|
-
|
|
37
|
+
addMetaAssertion(metaAssertion) {
|
|
38
|
+
this.metaAssertions.push(metaAssertion);
|
|
39
|
+
}
|
|
48
40
|
|
|
49
41
|
matchMetaAssertion(metaAssertion) {
|
|
50
42
|
let metaAssertionMatches;
|
|
@@ -67,35 +59,28 @@ export default class MetaproofContext {
|
|
|
67
59
|
return metaAssertionMatches;
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
addRule(rule) { this.context.addRule(rule); }
|
|
62
|
+
static fromFileContext(fileContext) {
|
|
63
|
+
const context = fileContext, ///
|
|
64
|
+
derived = false,
|
|
65
|
+
metaAssertions = [],
|
|
66
|
+
metaproofContext = new MetaproofContext(context, derived, metaAssertions);
|
|
77
67
|
|
|
78
|
-
|
|
79
|
-
this.metaAssertions.push(metaAssertion);
|
|
68
|
+
return metaproofContext;
|
|
80
69
|
}
|
|
81
70
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
static fromMetaproofContext(metaproofContext) {
|
|
72
|
+
const context = metaproofContext, ///
|
|
73
|
+
derived = false,
|
|
74
|
+
metaAssertions = [];
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
warning(message, node) { this.context.warning(message, node); }
|
|
89
|
-
|
|
90
|
-
error(message, node) { this.context.error(message, node); }
|
|
91
|
-
|
|
92
|
-
fatal(message, node) { this.context.fatal(message, node); }
|
|
93
|
-
|
|
94
|
-
static fromContext(context) {
|
|
95
|
-
const derived = false,
|
|
96
|
-
metaAssertions = [],
|
|
97
|
-
metaproofContext = new MetaproofContext(context, derived, metaAssertions);
|
|
76
|
+
metaproofContext = new MetaproofContext(context, derived, metaAssertions); ///
|
|
98
77
|
|
|
99
78
|
return metaproofContext;
|
|
100
79
|
}
|
|
101
80
|
}
|
|
81
|
+
|
|
82
|
+
Object.assign(MetaproofContext.prototype, fileMixins);
|
|
83
|
+
Object.assign(MetaproofContext.prototype, loggingMixins);
|
|
84
|
+
Object.assign(MetaproofContext.prototype, callbacksMixins);
|
|
85
|
+
|
|
86
|
+
export default MetaproofContext;
|
package/src/context/proof.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import fileMixins from "../mixins/file";
|
|
4
|
+
import loggingMixins from "../mixins/logging";
|
|
5
|
+
import callbacksMixins from "../mixins/callbacks";
|
|
6
|
+
|
|
7
|
+
class ProofContext {
|
|
8
|
+
constructor(context, derived, assertions) {
|
|
5
9
|
this.context = context;
|
|
6
10
|
this.derived = derived;
|
|
7
|
-
this.
|
|
8
|
-
this.statementNodes = statementNodes;
|
|
11
|
+
this.assertions = assertions;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
getContext() {
|
|
@@ -16,50 +19,15 @@ export default class ProofContext {
|
|
|
16
19
|
return this.derived;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getStatementNodes() {
|
|
24
|
-
return this.statementNodes;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getRules() { return this.context.getRules(); }
|
|
28
|
-
|
|
29
|
-
getTypes() { return this.context.getTypes(); }
|
|
30
|
-
|
|
31
|
-
getAxioms() { return this.context.getAxioms(); }
|
|
22
|
+
getAssertions() {
|
|
23
|
+
let assertions = this.context.getAssertions();
|
|
32
24
|
|
|
33
|
-
|
|
25
|
+
assertions = [
|
|
26
|
+
...assertions,
|
|
27
|
+
...this.assertions
|
|
28
|
+
];
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
38
|
-
|
|
39
|
-
findRuleByReferenceName(referenceName) { return this.context.findRuleByReferenceName(referenceName); }
|
|
40
|
-
|
|
41
|
-
findVariableByVariableName(variableName) {
|
|
42
|
-
const name = variableName, ///
|
|
43
|
-
variable = this.variables.find((variable) => {
|
|
44
|
-
const matches = variable.matchName(name);
|
|
45
|
-
|
|
46
|
-
if (matches) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
}) || this.context.findVariableByVariableName(variableName); ///
|
|
50
|
-
|
|
51
|
-
return variable;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
isLabelPresent(label) { return this.context.isLabelPresent(label); }
|
|
55
|
-
|
|
56
|
-
isTypePresentByTypeName(typeName) { return this.context.isTypePresentByTypeName(typeName); }
|
|
57
|
-
|
|
58
|
-
isVariablePresentByVariableName(variableName) {
|
|
59
|
-
const variable = this.findVariableByVariableName(variableName),
|
|
60
|
-
variablePresent = (variable !== null);
|
|
61
|
-
|
|
62
|
-
return variablePresent;
|
|
30
|
+
return assertions;
|
|
63
31
|
}
|
|
64
32
|
|
|
65
33
|
setDerived(derived) {
|
|
@@ -70,34 +38,53 @@ export default class ProofContext {
|
|
|
70
38
|
this.derived = derived;
|
|
71
39
|
}
|
|
72
40
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
addVariable(variable) {
|
|
76
|
-
this.variables.push(variable);
|
|
41
|
+
addAssertion(assertion) {
|
|
42
|
+
this.assertions.push(assertion);
|
|
77
43
|
}
|
|
78
44
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
45
|
+
matchAssertion(assertion) {
|
|
46
|
+
let assertionMatches;
|
|
82
47
|
|
|
83
|
-
|
|
48
|
+
const assertionB = assertion; ///
|
|
84
49
|
|
|
85
|
-
|
|
50
|
+
assertionMatches = this.assertions.some((assertion) => {
|
|
51
|
+
const assertionA = assertion, ///
|
|
52
|
+
matches = assertionA.match(assertionB);
|
|
86
53
|
|
|
87
|
-
|
|
54
|
+
if (matches) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
88
58
|
|
|
89
|
-
|
|
59
|
+
if (!assertionMatches) {
|
|
60
|
+
assertionMatches = this.context.matchAssertion(assertion);
|
|
61
|
+
}
|
|
90
62
|
|
|
91
|
-
|
|
63
|
+
return assertionMatches;
|
|
64
|
+
}
|
|
92
65
|
|
|
93
|
-
|
|
66
|
+
static fromFileContext(fileContext) {
|
|
67
|
+
const context = fileContext, ///
|
|
68
|
+
derived = false,
|
|
69
|
+
assertions = [],
|
|
70
|
+
proofContext = new ProofContext(context, derived, assertions);
|
|
94
71
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
return proofContext;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static fromProofContext(proofContext) {
|
|
76
|
+
const context = proofContext, ///
|
|
77
|
+
derived = false,
|
|
78
|
+
assertions = [];
|
|
79
|
+
|
|
80
|
+
proofContext = new ProofContext(context, derived, assertions); ///
|
|
100
81
|
|
|
101
82
|
return proofContext;
|
|
102
83
|
}
|
|
103
84
|
}
|
|
85
|
+
|
|
86
|
+
Object.assign(ProofContext.prototype, fileMixins);
|
|
87
|
+
Object.assign(ProofContext.prototype, loggingMixins);
|
|
88
|
+
Object.assign(ProofContext.prototype, callbacksMixins);
|
|
89
|
+
|
|
90
|
+
export default ProofContext;
|
package/src/context/release.js
CHANGED
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
|
|
4
4
|
|
|
5
|
-
import logMixins from "../mixins/log";
|
|
6
|
-
|
|
7
5
|
import { push } from "../utilities/array";
|
|
8
6
|
import { customGrammarFromRelease, combinedCustomGrammarFromReleaseContexts } from "../utilities/customGrammar";
|
|
9
7
|
|
|
10
8
|
const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
11
9
|
{ florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
12
10
|
|
|
13
|
-
class ReleaseContext {
|
|
14
|
-
constructor(log, release, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts) {
|
|
11
|
+
export default class ReleaseContext {
|
|
12
|
+
constructor(log, release, callbacks, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts) {
|
|
15
13
|
this.log = log;
|
|
16
14
|
this.release = release;
|
|
15
|
+
this.callbacks = callbacks;
|
|
17
16
|
this.verified = verified;
|
|
18
17
|
this.customGrammar = customGrammar;
|
|
19
|
-
|
|
20
18
|
this.fileContexts = fileContexts;
|
|
21
19
|
this.florenceLexer = florenceLexer;
|
|
22
20
|
this.florenceParser = florenceParser;
|
|
@@ -31,6 +29,10 @@ class ReleaseContext {
|
|
|
31
29
|
return this.release;
|
|
32
30
|
}
|
|
33
31
|
|
|
32
|
+
getCallbacks() {
|
|
33
|
+
return this.callbacks;
|
|
34
|
+
}
|
|
35
|
+
|
|
34
36
|
isVerified() {
|
|
35
37
|
return this.verified;
|
|
36
38
|
}
|
|
@@ -65,6 +67,8 @@ class ReleaseContext {
|
|
|
65
67
|
|
|
66
68
|
getDependencies() { return this.release.getDependencies(); }
|
|
67
69
|
|
|
70
|
+
matchShortenedVersion(shortenedVersion) { return this.release.matchShortenedVersion(shortenedVersion); }
|
|
71
|
+
|
|
68
72
|
getRules(releaseNames = []) {
|
|
69
73
|
const name = this.getName(),
|
|
70
74
|
rules = [],
|
|
@@ -204,10 +208,32 @@ class ReleaseContext {
|
|
|
204
208
|
this.fileContexts.push(fileContext);
|
|
205
209
|
}
|
|
206
210
|
|
|
211
|
+
setVerified(verified) {
|
|
212
|
+
this.verified = verified;
|
|
213
|
+
}
|
|
214
|
+
|
|
207
215
|
tokenise(content) { return this.florenceLexer.tokenise(content); }
|
|
208
216
|
|
|
209
217
|
parse(tokens) { return this.florenceParser.parse(tokens); }
|
|
210
218
|
|
|
219
|
+
trace(message) { this.log.trace(message); }
|
|
220
|
+
|
|
221
|
+
debug(message) { this.log.debug(message); }
|
|
222
|
+
|
|
223
|
+
info(message) { this.log.info(message); }
|
|
224
|
+
|
|
225
|
+
warning(message) { this.log.warning(message); }
|
|
226
|
+
|
|
227
|
+
error(message) { this.log.error(message); }
|
|
228
|
+
|
|
229
|
+
fatal(message) { this.log.fatal(message); }
|
|
230
|
+
|
|
231
|
+
halt(filePath, leastLineIndex, greatestLineIndex) { this.callbacks.halt(filePath, leastLineIndex, greatestLineIndex); }
|
|
232
|
+
|
|
233
|
+
begin(filePath, leastLineIndex, greatestLineIndex) { this.callbacks.begin(filePath, leastLineIndex, greatestLineIndex); }
|
|
234
|
+
|
|
235
|
+
complete(filePath, leastLineIndex, greatestLineIndex) { this.callbacks.complete(filePath, leastLineIndex, greatestLineIndex); }
|
|
236
|
+
|
|
211
237
|
initialise(releaseContexts, dependencyReleaseContexts) {
|
|
212
238
|
const releaseContext = this; ///
|
|
213
239
|
|
|
@@ -222,19 +248,15 @@ class ReleaseContext {
|
|
|
222
248
|
this.releaseContexts = releaseContexts;
|
|
223
249
|
}
|
|
224
250
|
|
|
225
|
-
static
|
|
251
|
+
static fromLogReleaseAndCallbacks(log, release, callbacks, ...remainingArguments) {
|
|
226
252
|
const verified = false,
|
|
227
253
|
customGrammar = customGrammarFromRelease(release),
|
|
228
254
|
fileContexts = [],
|
|
229
255
|
florenceLexer = null,
|
|
230
256
|
florenceParser = null,
|
|
231
257
|
releaseContexts = [],
|
|
232
|
-
releaseContext = new ReleaseContext(log, release, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts, ...remainingArguments);
|
|
258
|
+
releaseContext = new ReleaseContext(log, release, callbacks, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts, ...remainingArguments);
|
|
233
259
|
|
|
234
260
|
return releaseContext;
|
|
235
261
|
}
|
|
236
262
|
}
|
|
237
|
-
|
|
238
|
-
Object.assign(ReleaseContext.prototype, logMixins);
|
|
239
|
-
|
|
240
|
-
export default ReleaseContext;
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function halt(node) { this.context.halt(node); }
|
|
4
|
+
|
|
5
|
+
function begin(node) { this.context.begin(node); }
|
|
6
|
+
|
|
7
|
+
function complete(node) { this.context.complete(node); }
|
|
8
|
+
|
|
9
|
+
const callbacksMixins = {
|
|
10
|
+
halt,
|
|
11
|
+
begin,
|
|
12
|
+
complete
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default callbacksMixins;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function findRuleByReferenceName(referenceName) { return this.context.findRuleByReferenceName(referenceName); }
|
|
4
|
+
|
|
5
|
+
function findAxiomByReferenceName(referenceName) { return this.context.findAxiomByReferenceName(referenceName); }
|
|
6
|
+
|
|
7
|
+
const fileMixins = {
|
|
8
|
+
findRuleByReferenceName,
|
|
9
|
+
findAxiomByReferenceName
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default fileMixins;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function trace(message) { this.context.trace(message); }
|
|
4
|
+
|
|
5
|
+
function debug(message) { this.context.debug(message); }
|
|
6
|
+
|
|
7
|
+
function info(message) { this.context.info(message); }
|
|
8
|
+
|
|
9
|
+
function warning(message) { this.context.warning(message); }
|
|
10
|
+
|
|
11
|
+
function error(message) { this.context.error(message); }
|
|
12
|
+
|
|
13
|
+
function fatal(message) { this.context.fatal(message); }
|
|
14
|
+
|
|
15
|
+
const loggingMixins = {
|
|
16
|
+
trace,
|
|
17
|
+
debug,
|
|
18
|
+
info,
|
|
19
|
+
warning,
|
|
20
|
+
error,
|
|
21
|
+
fatal
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default loggingMixins;
|