occam-verify-cli 0.0.1005 → 0.0.1007
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/action/verify.js +15 -2
- package/bin/utilities/releaseContext.js +10 -5
- package/lib/combinator.js +7 -3
- package/lib/conclusion.js +10 -6
- package/lib/context/file.js +134 -57
- package/lib/context/release.js +97 -119
- package/lib/log.js +15 -25
- package/lib/metaType.js +6 -4
- package/lib/metavariable.js +9 -15
- package/lib/premise.js +9 -4
- package/lib/ruleNames.js +5 -1
- package/lib/supposition.js +6 -7
- package/lib/utilities/node.js +22 -1
- package/lib/utilities/releaseContext.js +7 -10
- package/lib/utilities/tokens.js +8 -1
- package/lib/verify/declaration/metavariable.js +3 -10
- package/lib/verify/files.js +1 -1
- package/lib/verify/release.js +27 -18
- package/package.json +1 -1
- package/src/combinator.js +12 -2
- package/src/conclusion.js +15 -5
- package/src/context/file.js +84 -45
- package/src/context/release.js +120 -134
- package/src/log.js +16 -31
- package/src/metaType.js +5 -3
- package/src/metavariable.js +6 -12
- package/src/premise.js +15 -3
- package/src/ruleNames.js +1 -0
- package/src/supposition.js +6 -11
- package/src/utilities/node.js +27 -2
- package/src/utilities/releaseContext.js +8 -13
- package/src/utilities/tokens.js +7 -0
- package/src/verify/declaration/metavariable.js +2 -13
- package/src/verify/files.js +1 -1
- package/src/verify/release.js +30 -18
- package/lib/context/release.other.js +0 -605
- package/src/context/release.other.js +0 -547
package/src/metaType.js
CHANGED
|
@@ -71,11 +71,13 @@ Object.assign(shim, {
|
|
|
71
71
|
export default MetaType;
|
|
72
72
|
|
|
73
73
|
export function metaTypeFromJSON(json, fileContext) {
|
|
74
|
-
let metaType;
|
|
74
|
+
let metaType = null;
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
if (json !== null) {
|
|
77
|
+
const { name } = json;
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
metaType = new MetaType(name);
|
|
80
|
+
}
|
|
79
81
|
|
|
80
82
|
return metaType;
|
|
81
83
|
}
|
package/src/metavariable.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { metaTypeFromJSON } from "./metaType";
|
|
4
4
|
import { metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
5
|
+
import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
5
6
|
|
|
6
7
|
export default class Metavariable {
|
|
7
|
-
constructor(string, node, name,
|
|
8
|
+
constructor(string, node, name, metaType) {
|
|
8
9
|
this.string = string;
|
|
9
10
|
this.node = node;
|
|
10
11
|
this.name = name;
|
|
11
|
-
this.termType = termType;
|
|
12
12
|
this.metaType = metaType;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -24,10 +24,6 @@ export default class Metavariable {
|
|
|
24
24
|
return this.name;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
getTermType() {
|
|
28
|
-
return this.termType;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
27
|
getMetaType() {
|
|
32
28
|
return this.metaType;
|
|
33
29
|
}
|
|
@@ -80,8 +76,7 @@ export default class Metavariable {
|
|
|
80
76
|
|
|
81
77
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
82
78
|
name = metavariableName, ///
|
|
83
|
-
|
|
84
|
-
metavariable = new Metavariable(string, node, name, termType, metaType);
|
|
79
|
+
metavariable = new Metavariable(string, node, name, metaType);
|
|
85
80
|
|
|
86
81
|
return metavariable;
|
|
87
82
|
}
|
|
@@ -91,19 +86,18 @@ export default class Metavariable {
|
|
|
91
86
|
name = metavariableName, ///
|
|
92
87
|
node = metavariableNode, ///
|
|
93
88
|
string = fileContext.nodeAsString(node),
|
|
94
|
-
termType = null,
|
|
95
89
|
metaType = null,
|
|
96
|
-
metavariable = new Metavariable(string, node, name,
|
|
90
|
+
metavariable = new Metavariable(string, node, name, metaType);
|
|
97
91
|
|
|
98
92
|
return metavariable;
|
|
99
93
|
}
|
|
100
94
|
|
|
101
|
-
static
|
|
95
|
+
static fromMetavariableNodeAndMetaType(metavariableNode, metaType, fileContext) {
|
|
102
96
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
103
97
|
name = metavariableName, ///
|
|
104
98
|
node = metavariableNode, ///
|
|
105
99
|
string = fileContext.nodeAsString(node),
|
|
106
|
-
metavariable = new Metavariable(string, node, name,
|
|
100
|
+
metavariable = new Metavariable(string, node, name, metaType);
|
|
107
101
|
|
|
108
102
|
return metavariable;
|
|
109
103
|
}
|
package/src/premise.js
CHANGED
|
@@ -6,8 +6,10 @@ import metaLevelUnifier from "./unifier/metaLevel";
|
|
|
6
6
|
import SubproofAssertion from "./assertion/subproof";
|
|
7
7
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
8
8
|
|
|
9
|
+
import { trim } from "./utilities/string";
|
|
9
10
|
import { nodeQuery } from "./utilities/query";
|
|
10
11
|
import { assignAssignments } from "./utilities/assignments";
|
|
12
|
+
import { unqualifiedStatementNodeFromUnqualifiedStatementString } from "./utilities/node";
|
|
11
13
|
|
|
12
14
|
const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
|
|
13
15
|
|
|
@@ -106,9 +108,10 @@ export default class Premise {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
verify(localContext) {
|
|
109
|
-
let verified = false
|
|
111
|
+
let verified = false,
|
|
112
|
+
premiseString = this.getString(); ///
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
premiseString = trim(premiseString); ///
|
|
112
115
|
|
|
113
116
|
if (this.unqualifiedStatement !== null) {
|
|
114
117
|
localContext.trace(`Verifying the '${premiseString}' premise...`);
|
|
@@ -150,7 +153,16 @@ export default class Premise {
|
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
static fromJSON(json, fileContext) {
|
|
153
|
-
let
|
|
156
|
+
let { unqualifiedStatement } = json;
|
|
157
|
+
|
|
158
|
+
const lexer = fileContext.getLexer(),
|
|
159
|
+
parser = fileContext.getParser(),
|
|
160
|
+
unqualifiedStatementString = unqualifiedStatement, ///
|
|
161
|
+
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, lexer, parser);
|
|
162
|
+
|
|
163
|
+
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext);
|
|
164
|
+
|
|
165
|
+
const premise = new Premise(fileContext, unqualifiedStatement);
|
|
154
166
|
|
|
155
167
|
return premise;
|
|
156
168
|
}
|
package/src/ruleNames.js
CHANGED
package/src/supposition.js
CHANGED
|
@@ -3,17 +3,11 @@
|
|
|
3
3
|
import ProofStep from "./proofStep";
|
|
4
4
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { match } from "./utilities/array";
|
|
6
|
+
import { trim } from "./utilities/string";
|
|
7
|
+
import { nodeQuery } from "./utilities/query";
|
|
9
8
|
import { assignAssignments } from "./utilities/assignments";
|
|
10
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement"),
|
|
14
|
-
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
15
|
-
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
16
|
-
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
10
|
+
const unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement");
|
|
17
11
|
|
|
18
12
|
export default class Supposition {
|
|
19
13
|
constructor(fileContext, unqualifiedStatement) {
|
|
@@ -79,9 +73,10 @@ export default class Supposition {
|
|
|
79
73
|
// }
|
|
80
74
|
|
|
81
75
|
verify(localContext) {
|
|
82
|
-
let verified = false
|
|
76
|
+
let verified = false,
|
|
77
|
+
suppositionString = this.getString(); ///
|
|
83
78
|
|
|
84
|
-
|
|
79
|
+
suppositionString = trim(suppositionString); ///
|
|
85
80
|
|
|
86
81
|
if (this.unqualifiedStatement !== null) {
|
|
87
82
|
localContext.trace(`Verifying the '${suppositionString}' supposition...`);
|
package/src/utilities/node.js
CHANGED
|
@@ -4,8 +4,12 @@ import { parsersUtilities } from "occam-custom-grammars";
|
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
6
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
|
-
import { TERM_RULE_NAME,
|
|
8
|
-
|
|
7
|
+
import { TERM_RULE_NAME,
|
|
8
|
+
METAVARIABLE_RULE_NAME,
|
|
9
|
+
UNQUALIFIED_STATEMENT_RULE_NAME } from "../ruleNames";
|
|
10
|
+
import { termTokensFromTermString,
|
|
11
|
+
metavariableTokensFromMetavariableString,
|
|
12
|
+
unqualifiedStatementTokensFromUnqualifiedStatementString } from "../utilities/tokens";
|
|
9
13
|
|
|
10
14
|
const { nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
11
15
|
|
|
@@ -31,6 +35,20 @@ export function statementNodeFromStatementString(statementString, lexer, parser)
|
|
|
31
35
|
return statementNode;
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
export function metavariableNodeFromMetavariableString(metavariableString, lexer, parser) {
|
|
39
|
+
const metavariableTokens = metavariableTokensFromMetavariableString(metavariableString, lexer),
|
|
40
|
+
metavariableNode = metavariableNodeFromMetavariableTokens(metavariableTokens, parser);
|
|
41
|
+
|
|
42
|
+
return metavariableNode;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, lexer, parser) {
|
|
46
|
+
const unqualifiedStatementTokens = unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString, lexer),
|
|
47
|
+
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser);
|
|
48
|
+
|
|
49
|
+
return unqualifiedStatementNode;
|
|
50
|
+
}
|
|
51
|
+
|
|
34
52
|
export function termNodeFromTermTokens(termTokens, parser) {
|
|
35
53
|
const tokens = termTokens, ///
|
|
36
54
|
ruleName = TERM_RULE_NAME,
|
|
@@ -39,6 +57,13 @@ export function termNodeFromTermTokens(termTokens, parser) {
|
|
|
39
57
|
return termNode;
|
|
40
58
|
}
|
|
41
59
|
|
|
60
|
+
export function metavariableNodeFromMetavariableTokens(metavariableTokens, parser) {
|
|
61
|
+
const ruleName = METAVARIABLE_RULE_NAME,
|
|
62
|
+
metavariableNode = nodeFromTokensRuleNameAndParser(metavariableTokens, ruleName, parser);
|
|
63
|
+
|
|
64
|
+
return metavariableNode;
|
|
65
|
+
}
|
|
66
|
+
|
|
42
67
|
export function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser) {
|
|
43
68
|
const tokens = unqualifiedStatementTokens, ///
|
|
44
69
|
ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
@@ -9,9 +9,8 @@ export function createReleaseContext(dependency, dependentNames, context, callba
|
|
|
9
9
|
releaseContext = releaseContextMap[releaseName] || null;
|
|
10
10
|
|
|
11
11
|
if (releaseContext !== null) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const error = null;
|
|
12
|
+
const error = null,
|
|
13
|
+
releaseMatchesDependency = checkReleaseMatchesDependency(releaseContext, dependency, dependentNames, context);
|
|
15
14
|
|
|
16
15
|
let success;
|
|
17
16
|
|
|
@@ -102,20 +101,16 @@ export function initialiseReleaseContext(dependency, context) {
|
|
|
102
101
|
releaseContextInitialised = releaseContext.isInitialised();
|
|
103
102
|
|
|
104
103
|
if (!releaseContextInitialised) {
|
|
105
|
-
|
|
104
|
+
initialiseDependencyReleaseContexts(dependency, releaseContext, context);
|
|
106
105
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
106
|
+
const { log } = context,
|
|
107
|
+
releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
110
108
|
|
|
111
|
-
|
|
109
|
+
log.debug(`Initialising the '${dependencyName}' context...`);
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
releaseContext.initialise(releaseContexts);
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
log.info(`...initialised the '${dependencyName}' context.`) :
|
|
117
|
-
log.warning(`...unable to initialise the '${dependencyName}' context.`);
|
|
118
|
-
}
|
|
113
|
+
log.info(`...initialised the '${dependencyName}' context.`);
|
|
119
114
|
}
|
|
120
115
|
}
|
|
121
116
|
|
package/src/utilities/tokens.js
CHANGED
|
@@ -16,6 +16,13 @@ export function termTokensFromTermString(termString, lexer) {
|
|
|
16
16
|
return termTokens;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
export function metavariableTokensFromMetavariableString(metavariableString, lexer) {
|
|
20
|
+
const metavariableContent = `${metavariableString}`,
|
|
21
|
+
metavariableTokens = tokensFromContentAndLexer(metavariableContent, lexer);
|
|
22
|
+
|
|
23
|
+
return metavariableTokens;
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
export function unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString, lexer) {
|
|
20
27
|
const content = unqualifiedStatementString, ///
|
|
21
28
|
unqualifiedStatementTokens = tokensFromContentAndLexer(content, lexer);
|
|
@@ -52,24 +52,13 @@ function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
|
|
|
52
52
|
metaTypeVerified = verifyMetaType(metaTypeNode, metaTypes, fileContext);
|
|
53
53
|
|
|
54
54
|
if (argumentVerified && metaTypeVerified) {
|
|
55
|
-
let
|
|
56
|
-
metaType;
|
|
55
|
+
let metaType;
|
|
57
56
|
|
|
58
57
|
const firstMetaType = first(metaTypes);
|
|
59
58
|
|
|
60
59
|
metaType = firstMetaType; ///
|
|
61
60
|
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
if (termTypesLength === 0) {
|
|
65
|
-
termType = null;
|
|
66
|
-
} else {
|
|
67
|
-
const firstTermType = first(termTypes);
|
|
68
|
-
|
|
69
|
-
termType = firstTermType; ///
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const metavariable = Metavariable.fromMetavariableNodeNameTermTypeAndMetaType(metavariableNode, termType, metaType, fileContext),
|
|
61
|
+
const metavariable = Metavariable.fromMetavariableNodeAndMetaType(metavariableNode, metaType, fileContext),
|
|
73
62
|
metavariableAssignment = MetavariableAssignment.fromMetavariable(metavariable),
|
|
74
63
|
metavariableAssigned = metavariableAssignment.assign(fileContext);
|
|
75
64
|
|
package/src/verify/files.js
CHANGED
package/src/verify/release.js
CHANGED
|
@@ -2,34 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
import verifyFiles from "../verify/files";
|
|
4
4
|
|
|
5
|
-
export default function verifyRelease(releaseName, releaseContextMap) {
|
|
5
|
+
export default function verifyRelease(releaseName, dependentName, dependentReleased, releaseContextMap) {
|
|
6
6
|
let releaseVerified = false;
|
|
7
7
|
|
|
8
8
|
const releaseContext = releaseContextMap[releaseName];
|
|
9
9
|
|
|
10
10
|
if (releaseContext !== null) {
|
|
11
|
-
const
|
|
11
|
+
const released = releaseContext.isReleased();
|
|
12
12
|
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
13
|
+
if (released) {
|
|
14
|
+
releaseVerified = true;
|
|
15
|
+
} else {
|
|
16
|
+
if (dependentReleased) {
|
|
17
|
+
releaseContext.warning(`The '${releaseName}' project cannot be verified because its '${dependentName}' dependent is a package.`);
|
|
18
18
|
} else {
|
|
19
|
-
|
|
19
|
+
const dependentName = releaseName, ///
|
|
20
|
+
dependentReleased = released, ///
|
|
21
|
+
dependencyReleasesVVerified = verifyDependencyReleases(releaseContext, dependentName, dependentReleased, releaseContextMap);
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
if (dependencyReleasesVVerified) {
|
|
24
|
+
const verified = releaseContext.isVerified();
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
if (verified) {
|
|
27
|
+
releaseVerified = true;
|
|
28
|
+
} else {
|
|
29
|
+
releaseContext.info(`Verifying the '${releaseName}' project...`);
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
const releaseFilesVerified = verifyReleaseFiles(releaseContext);
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
if (releaseFilesVerified) {
|
|
34
|
+
const verified = true;
|
|
35
|
+
|
|
36
|
+
releaseContext.setVerified(verified);
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
releaseVerified = verified; ///
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (releaseVerified) {
|
|
42
|
+
releaseContext.info(`...verified the '${releaseName}' project.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
}
|
|
@@ -45,12 +57,12 @@ function verifyReleaseFiles(releaseContext) {
|
|
|
45
57
|
return releaseFilesVerified;
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
function verifyDependencyReleases(releaseContext, releaseContextMap) {
|
|
60
|
+
function verifyDependencyReleases(releaseContext, dependentName, dependentReleased, releaseContextMap) {
|
|
49
61
|
const dependencies = releaseContext.getDependencies(),
|
|
50
62
|
dependencyReleasesVVerified = dependencies.everyDependency((dependency) => {
|
|
51
63
|
const name = dependency.getName(),
|
|
52
64
|
releaseName = name, ///
|
|
53
|
-
releaseVerified = verifyRelease(releaseName, releaseContextMap);
|
|
65
|
+
releaseVerified = verifyRelease(releaseName, dependentName, dependentReleased, releaseContextMap);
|
|
54
66
|
|
|
55
67
|
if (releaseVerified) {
|
|
56
68
|
return true;
|