occam-verify-cli 0.0.1007 → 0.0.1010
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/argument.js +106 -0
- package/lib/combinator.js +6 -4
- package/lib/conclusion.js +4 -5
- package/lib/context/release.js +2 -2
- package/lib/declaration/combinator.js +16 -9
- package/lib/declaration/metavariable.js +87 -0
- package/lib/metaType.js +11 -20
- package/lib/metavariable.js +50 -6
- package/lib/premise.js +4 -4
- package/lib/statement/qualified.js +3 -3
- package/lib/statement/unqualified.js +30 -13
- package/lib/verifier/topLevel.js +4 -4
- package/lib/verify/release.js +7 -22
- package/package.json +1 -1
- package/src/argument.js +79 -0
- package/src/combinator.js +6 -7
- package/src/conclusion.js +5 -8
- package/src/context/release.js +1 -1
- package/src/declaration/combinator.js +13 -8
- package/src/declaration/metavariable.js +57 -0
- package/src/metaType.js +6 -12
- package/src/metavariable.js +64 -5
- package/src/premise.js +4 -7
- package/src/statement/qualified.js +3 -5
- package/src/statement/unqualified.js +28 -14
- package/src/verifier/topLevel.js +5 -3
- package/src/verify/release.js +8 -23
- package/lib/verify/declaration/metavariable.js +0 -89
- package/src/verify/declaration/metavariable.js +0 -125
package/lib/verify/release.js
CHANGED
|
@@ -8,12 +8,6 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return verifyRelease;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
var _files = /*#__PURE__*/ _interop_require_default(require("../verify/files"));
|
|
12
|
-
function _interop_require_default(obj) {
|
|
13
|
-
return obj && obj.__esModule ? obj : {
|
|
14
|
-
default: obj
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
11
|
function verifyRelease(releaseName, dependentName, dependentReleased, releaseContextMap) {
|
|
18
12
|
var releaseVerified = false;
|
|
19
13
|
var releaseContext = releaseContextMap[releaseName];
|
|
@@ -27,31 +21,22 @@ function verifyRelease(releaseName, dependentName, dependentReleased, releaseCon
|
|
|
27
21
|
} else {
|
|
28
22
|
var _$dependentName = releaseName, _$dependentReleased = released, dependencyReleasesVVerified = verifyDependencyReleases(releaseContext, _$dependentName, _$dependentReleased, releaseContextMap);
|
|
29
23
|
if (dependencyReleasesVVerified) {
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} else {
|
|
24
|
+
var releaseContextVerified;
|
|
25
|
+
releaseContextVerified = releaseContext.isVerified();
|
|
26
|
+
if (!releaseContextVerified) {
|
|
34
27
|
releaseContext.info("Verifying the '".concat(releaseName, "' project..."));
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
var verified1 = true;
|
|
38
|
-
releaseContext.setVerified(verified1);
|
|
39
|
-
releaseVerified = verified1; ///
|
|
40
|
-
}
|
|
41
|
-
if (releaseVerified) {
|
|
28
|
+
releaseContextVerified = releaseContext.verify();
|
|
29
|
+
if (releaseContextVerified) {
|
|
42
30
|
releaseContext.info("...verified the '".concat(releaseName, "' project."));
|
|
43
31
|
}
|
|
44
32
|
}
|
|
33
|
+
releaseVerified = releaseContextVerified; ///
|
|
45
34
|
}
|
|
46
35
|
}
|
|
47
36
|
}
|
|
48
37
|
}
|
|
49
38
|
return releaseVerified;
|
|
50
39
|
}
|
|
51
|
-
function verifyReleaseFiles(releaseContext) {
|
|
52
|
-
var filesVerified = (0, _files.default)(releaseContext), releaseFilesVerified = filesVerified; ///
|
|
53
|
-
return releaseFilesVerified;
|
|
54
|
-
}
|
|
55
40
|
function verifyDependencyReleases(releaseContext, dependentName, dependentReleased, releaseContextMap) {
|
|
56
41
|
var dependencies = releaseContext.getDependencies(), dependencyReleasesVVerified = dependencies.everyDependency(function(dependency) {
|
|
57
42
|
var name = dependency.getName(), releaseName = name, releaseVerified = verifyRelease(releaseName, dependentName, dependentReleased, releaseContextMap);
|
|
@@ -62,4 +47,4 @@ function verifyDependencyReleases(releaseContext, dependentName, dependentReleas
|
|
|
62
47
|
return dependencyReleasesVVerified;
|
|
63
48
|
}
|
|
64
49
|
|
|
65
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
50
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZnkvcmVsZWFzZS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdmVyaWZ5UmVsZWFzZShyZWxlYXNlTmFtZSwgZGVwZW5kZW50TmFtZSwgZGVwZW5kZW50UmVsZWFzZWQsIHJlbGVhc2VDb250ZXh0TWFwKSB7XG4gIGxldCByZWxlYXNlVmVyaWZpZWQgPSBmYWxzZTtcblxuICBjb25zdCByZWxlYXNlQ29udGV4dCA9IHJlbGVhc2VDb250ZXh0TWFwW3JlbGVhc2VOYW1lXTtcblxuICBpZiAocmVsZWFzZUNvbnRleHQgIT09IG51bGwpIHtcbiAgICBjb25zdCByZWxlYXNlZCA9IHJlbGVhc2VDb250ZXh0LmlzUmVsZWFzZWQoKTtcblxuICAgIGlmIChyZWxlYXNlZCkge1xuICAgICAgcmVsZWFzZVZlcmlmaWVkID0gdHJ1ZTtcbiAgICB9IGVsc2Uge1xuICAgICAgaWYgKGRlcGVuZGVudFJlbGVhc2VkKSB7XG4gICAgICAgIHJlbGVhc2VDb250ZXh0Lndhcm5pbmcoYFRoZSAnJHtyZWxlYXNlTmFtZX0nIHByb2plY3QgY2Fubm90IGJlIHZlcmlmaWVkIGJlY2F1c2UgaXRzICcke2RlcGVuZGVudE5hbWV9JyBkZXBlbmRlbnQgaXMgYSBwYWNrYWdlLmApO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgY29uc3QgZGVwZW5kZW50TmFtZSA9IHJlbGVhc2VOYW1lLCAgLy8vXG4gICAgICAgICAgICAgIGRlcGVuZGVudFJlbGVhc2VkID0gcmVsZWFzZWQsIC8vL1xuICAgICAgICAgICAgICBkZXBlbmRlbmN5UmVsZWFzZXNWVmVyaWZpZ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osYUFBYSxFQUFFQyxpQkFBaUIsRUFBRUMsaUJBQWlCO0lBQ25HLElBQU1ZLGVBQWVWLGVBQWVXLGVBQWUsSUFDN0NQLDhCQUE4Qk0sYUFBYUUsZUFBZSxDQUFDLFNBQUNDO1FBQzFELElBQU1DLE9BQU9ELFdBQVdFLE9BQU8sSUFDekJwQixjQUFjbUIsTUFDZGYsa0JBQWtCTCxjQUFjQyxhQUFhQyxlQUFlQyxtQkFBbUJDO1FBRXJGLElBQUlDLGlCQUFpQjtZQUNuQixPQUFPO1FBQ1Q7SUFDRjtJQUVOLE9BQU9LO0FBQ1QifQ==
|
package/package.json
CHANGED
package/src/argument.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "./utilities/query";
|
|
4
|
+
|
|
5
|
+
const termNodeQuery = nodeQuery("/argument/term"),
|
|
6
|
+
typeNodeQuery = nodeQuery("/argument//type");
|
|
7
|
+
|
|
8
|
+
export default class Argument {
|
|
9
|
+
constructor(string, node, fileContext) {
|
|
10
|
+
this.string = string;
|
|
11
|
+
this.node = node;
|
|
12
|
+
this.fileContext = fileContext;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getString() {
|
|
16
|
+
return this.string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getNode() {
|
|
20
|
+
return this.node;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getFileContext() {
|
|
24
|
+
return this.fileContext;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
verify(fileContext) {
|
|
28
|
+
let verified = false;
|
|
29
|
+
|
|
30
|
+
const argumentString = this.string; ///
|
|
31
|
+
|
|
32
|
+
fileContext.trace(`Verifying the '${argumentString}' argument...`);
|
|
33
|
+
|
|
34
|
+
if (this.node === null) {
|
|
35
|
+
verified = true;
|
|
36
|
+
} else {
|
|
37
|
+
const termNode = termNodeQuery(this.node);
|
|
38
|
+
|
|
39
|
+
if (termNode !== null) {
|
|
40
|
+
const termString = this.fileContext.nodeAsString(termNode);
|
|
41
|
+
|
|
42
|
+
this.fileContext.debug(`The '${termString}' term was found when a type should have been present.`);
|
|
43
|
+
} else {
|
|
44
|
+
const typeNode = typeNodeQuery(this.node);
|
|
45
|
+
|
|
46
|
+
if (typeNode !== null) {
|
|
47
|
+
const typePresent = this.fileContext.isTypePresentByTypeNode(typeNode);
|
|
48
|
+
|
|
49
|
+
if (typePresent) {
|
|
50
|
+
verified = true;
|
|
51
|
+
} else {
|
|
52
|
+
const typeString = this.fileContext.nodeAsString(typeNode);
|
|
53
|
+
|
|
54
|
+
this.fileContext.debug(`The '${typeString}' type is not present.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (verified) {
|
|
61
|
+
fileContext.debug(`...verified the '${argumentString}' argument.`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return verified;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static fromArgumentNode(argumentNode, fileContext) {
|
|
68
|
+
let argument = null;
|
|
69
|
+
|
|
70
|
+
if (argumentNode !== null) {
|
|
71
|
+
const node = argumentNode, ///
|
|
72
|
+
string = fileContext.nodeAsString(node);
|
|
73
|
+
|
|
74
|
+
argument = new Argument(string, node, fileContext);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return argument;
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/combinator.js
CHANGED
|
@@ -5,7 +5,6 @@ import Statement from "./statement";
|
|
|
5
5
|
import LocalContext from "./context/local";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery } from "./utilities/query";
|
|
8
|
-
import { statementNodeFromStatementString } from "./utilities/node";
|
|
9
8
|
|
|
10
9
|
const statementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
|
|
11
10
|
|
|
@@ -47,13 +46,13 @@ export default class Combinator {
|
|
|
47
46
|
static fromJSON(json, fileContext) {
|
|
48
47
|
let { statement } = json;
|
|
49
48
|
|
|
50
|
-
const
|
|
51
|
-
parser = fileContext.getParser(),
|
|
52
|
-
statementString = statement, ///
|
|
53
|
-
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
54
|
-
localContext = LocalContext.fromFileContext(fileContext);
|
|
49
|
+
const string = statement; ///
|
|
55
50
|
|
|
56
|
-
|
|
51
|
+
json = { ///
|
|
52
|
+
string
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
statement = Statement.fromJSON(json, fileContext);
|
|
57
56
|
|
|
58
57
|
const combinator = new Combinator(statement);
|
|
59
58
|
|
package/src/conclusion.js
CHANGED
|
@@ -6,7 +6,6 @@ import UnqualifiedStatement from "./statement/unqualified";
|
|
|
6
6
|
|
|
7
7
|
import { trim } from "./utilities/string";
|
|
8
8
|
import { nodeQuery } from "./utilities/query";
|
|
9
|
-
import { unqualifiedStatementNodeFromUnqualifiedStatementString } from "./utilities/node";
|
|
10
9
|
|
|
11
10
|
const unqualifiedStatementNodeQuery = nodeQuery("/conclusion/unqualifiedStatement");
|
|
12
11
|
|
|
@@ -80,8 +79,8 @@ export default class Conclusion {
|
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
toJSON() {
|
|
83
|
-
const
|
|
84
|
-
unqualifiedStatement =
|
|
82
|
+
const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
|
|
83
|
+
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
85
84
|
json = {
|
|
86
85
|
unqualifiedStatement
|
|
87
86
|
};
|
|
@@ -92,17 +91,15 @@ export default class Conclusion {
|
|
|
92
91
|
static fromJSON(json, fileContext) {
|
|
93
92
|
let { unqualifiedStatement } = json;
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
parser = fileContext.getParser(),
|
|
97
|
-
unqualifiedStatementString = unqualifiedStatement, ///
|
|
98
|
-
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, lexer, parser);
|
|
94
|
+
json = unqualifiedStatement; ///
|
|
99
95
|
|
|
100
|
-
unqualifiedStatement = UnqualifiedStatement.
|
|
96
|
+
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
101
97
|
|
|
102
98
|
const conclusion = new Conclusion(fileContext, unqualifiedStatement);
|
|
103
99
|
|
|
104
100
|
return conclusion;
|
|
105
101
|
}
|
|
102
|
+
|
|
106
103
|
static fromConclusionNode(conclusionNode, fileContext) {
|
|
107
104
|
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(conclusionNode),
|
|
108
105
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
package/src/context/release.js
CHANGED
|
@@ -470,7 +470,7 @@ export default class ReleaseContext {
|
|
|
470
470
|
parser = null,
|
|
471
471
|
verified = false,
|
|
472
472
|
initialised = false,
|
|
473
|
-
fileContexts =
|
|
473
|
+
fileContexts = [],
|
|
474
474
|
customGrammar = customGrammarFromNameAndEntries(name, entries),
|
|
475
475
|
dependencyReleaseContexts = null,
|
|
476
476
|
releaseContext = new ReleaseContext(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts);
|
|
@@ -3,33 +3,38 @@
|
|
|
3
3
|
import Combinator from "../combinator";
|
|
4
4
|
|
|
5
5
|
export default class CombinatorDeclaration {
|
|
6
|
-
constructor(combinator) {
|
|
6
|
+
constructor(fileContext, combinator) {
|
|
7
|
+
this.fileContext = fileContext;
|
|
7
8
|
this.combinator = combinator;
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
getFileContext() {
|
|
12
|
+
return this.fileContext;
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
getCombinator() {
|
|
11
16
|
return this.combinator;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
getString() { return this.combinator.getString(); }
|
|
15
20
|
|
|
16
|
-
verify(
|
|
21
|
+
verify() {
|
|
17
22
|
let verified;
|
|
18
23
|
|
|
19
|
-
const
|
|
24
|
+
const combinatorDeclarationString = this.getString(); ///
|
|
20
25
|
|
|
21
|
-
fileContext.trace(`Verifying the '${
|
|
26
|
+
this.fileContext.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration...`);
|
|
22
27
|
|
|
23
|
-
const combinatorVerified = this.combinator.verify(fileContext);
|
|
28
|
+
const combinatorVerified = this.combinator.verify(this.fileContext);
|
|
24
29
|
|
|
25
30
|
if (combinatorVerified) {
|
|
26
|
-
fileContext.addCombinator(this.combinator);
|
|
31
|
+
this.fileContext.addCombinator(this.combinator);
|
|
27
32
|
|
|
28
33
|
verified = true;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
if (verified) {
|
|
32
|
-
fileContext.debug(`...verified the '${
|
|
37
|
+
this.fileContext.debug(`...verified the '${combinatorDeclarationString}' combinator declaration.`);
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
return verified;
|
|
@@ -37,7 +42,7 @@ export default class CombinatorDeclaration {
|
|
|
37
42
|
|
|
38
43
|
static fromCombinatorDeclarationNode(combinatorDeclarationNode, fileContext) {
|
|
39
44
|
const combinator = Combinator.fromCombinatorDeclarationNode(combinatorDeclarationNode, fileContext),
|
|
40
|
-
combinatorDeclaration = new CombinatorDeclaration(combinator);
|
|
45
|
+
combinatorDeclaration = new CombinatorDeclaration(fileContext, combinator);
|
|
41
46
|
|
|
42
47
|
return combinatorDeclaration;
|
|
43
48
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaType from "../metaType";
|
|
4
|
+
import Metavariable from "../metavariable";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType");
|
|
9
|
+
|
|
10
|
+
export default class MetavariableDeclaration {
|
|
11
|
+
constructor(string, metavariable) {
|
|
12
|
+
this.string = string;
|
|
13
|
+
this.metavariable = metavariable;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getString() {
|
|
17
|
+
return this.string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getMetavariable() {
|
|
21
|
+
return this.metavariable;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
verify(fileContext) {
|
|
25
|
+
let verified;
|
|
26
|
+
|
|
27
|
+
const metavariableDeclarationString = this.string; ///
|
|
28
|
+
|
|
29
|
+
fileContext.trace(`Verifying the '${metavariableDeclarationString}' metavariable declaration...`);
|
|
30
|
+
|
|
31
|
+
const metavariableVerified = this.metavariable.verify(fileContext);
|
|
32
|
+
|
|
33
|
+
if (metavariableVerified) {
|
|
34
|
+
fileContext.addMetavariable(this.metavariable);
|
|
35
|
+
|
|
36
|
+
verified = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (verified) {
|
|
40
|
+
fileContext.debug(`...verified the '${metavariableDeclarationString}' metavariable declaration.`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return verified;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromMetavariableDeclarationNode(metavariableDeclarationNode, fileContext) {
|
|
47
|
+
const metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
|
|
48
|
+
metaType = MetaType.fromMetaTypeNode(metaTypeNode, fileContext),
|
|
49
|
+
metavariable = Metavariable.fromMetavariableDeclarationNode(metavariableDeclarationNode, fileContext),
|
|
50
|
+
metavariableString = metavariable.getString(),
|
|
51
|
+
metaTypeString = metaType.getString(),
|
|
52
|
+
string = `${metavariableString}:${metaTypeString}`,
|
|
53
|
+
metavariableDeclaration = new MetavariableDeclaration(string, metavariable);
|
|
54
|
+
|
|
55
|
+
return metavariableDeclaration;
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/metaType.js
CHANGED
|
@@ -13,6 +13,12 @@ class MetaType {
|
|
|
13
13
|
return this.name;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
getString() {
|
|
17
|
+
const string = this.name; ///
|
|
18
|
+
|
|
19
|
+
return string;
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
isEqualTo(metaType) {
|
|
17
23
|
const equalTo = (this === metaType);
|
|
18
24
|
|
|
@@ -69,15 +75,3 @@ Object.assign(shim, {
|
|
|
69
75
|
});
|
|
70
76
|
|
|
71
77
|
export default MetaType;
|
|
72
|
-
|
|
73
|
-
export function metaTypeFromJSON(json, fileContext) {
|
|
74
|
-
let metaType = null;
|
|
75
|
-
|
|
76
|
-
if (json !== null) {
|
|
77
|
-
const { name } = json;
|
|
78
|
-
|
|
79
|
-
metaType = new MetaType(name);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return metaType;
|
|
83
|
-
}
|
package/src/metavariable.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Argument from "./argument";
|
|
4
|
+
import MetaType from "./metaType";
|
|
5
|
+
import LocalContext from "./context/local";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "./utilities/query";
|
|
4
8
|
import { metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
5
9
|
import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
6
10
|
|
|
11
|
+
const argumentNodeQuery = nodeQuery("/metavariable/argument"),
|
|
12
|
+
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
13
|
+
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable");
|
|
14
|
+
|
|
7
15
|
export default class Metavariable {
|
|
8
16
|
constructor(string, node, name, metaType) {
|
|
9
17
|
this.string = string;
|
|
@@ -46,6 +54,40 @@ export default class Metavariable {
|
|
|
46
54
|
return metavariableNodeMatches;
|
|
47
55
|
}
|
|
48
56
|
|
|
57
|
+
verify(fileContext) {
|
|
58
|
+
let metavariableVerified = false;
|
|
59
|
+
|
|
60
|
+
const metavariableString = this.string; ///
|
|
61
|
+
|
|
62
|
+
fileContext.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
63
|
+
|
|
64
|
+
const metavariableNode = this.node, ///
|
|
65
|
+
metavariablePresent = fileContext.isMetavariablePresentByMetavariableNode(metavariableNode);
|
|
66
|
+
|
|
67
|
+
if (metavariablePresent) {
|
|
68
|
+
fileContext.debug(`The metavariable '${metavariableString}' is already present.`);
|
|
69
|
+
} else {
|
|
70
|
+
const argumentNode = argumentNodeQuery(metavariableNode),
|
|
71
|
+
argument = Argument.fromArgumentNode(argumentNode, fileContext);
|
|
72
|
+
|
|
73
|
+
if (argument === null) {
|
|
74
|
+
metavariableVerified = true;
|
|
75
|
+
} else {
|
|
76
|
+
const argumentVerified = argument.verify(fileContext);
|
|
77
|
+
|
|
78
|
+
if (argumentVerified) {
|
|
79
|
+
metavariableVerified = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (metavariableVerified) {
|
|
85
|
+
fileContext.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return metavariableVerified;
|
|
89
|
+
}
|
|
90
|
+
|
|
49
91
|
toJSON() {
|
|
50
92
|
const metaTypeJSON = (this.metaType !== null) ?
|
|
51
93
|
this.metaType.toJSON() :
|
|
@@ -70,9 +112,11 @@ export default class Metavariable {
|
|
|
70
112
|
|
|
71
113
|
let { metaType } = json;
|
|
72
114
|
|
|
73
|
-
|
|
115
|
+
if (metaType !== null) {
|
|
116
|
+
json = metaType; ///
|
|
74
117
|
|
|
75
|
-
|
|
118
|
+
metaType = MetaType.fromJSON(json, fileContext);
|
|
119
|
+
}
|
|
76
120
|
|
|
77
121
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
78
122
|
name = metavariableName, ///
|
|
@@ -83,8 +127,8 @@ export default class Metavariable {
|
|
|
83
127
|
|
|
84
128
|
static fromMetavariableNode(metavariableNode, fileContext) {
|
|
85
129
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
86
|
-
name = metavariableName, ///
|
|
87
130
|
node = metavariableNode, ///
|
|
131
|
+
name = metavariableName, ///
|
|
88
132
|
string = fileContext.nodeAsString(node),
|
|
89
133
|
metaType = null,
|
|
90
134
|
metavariable = new Metavariable(string, node, name, metaType);
|
|
@@ -94,11 +138,26 @@ export default class Metavariable {
|
|
|
94
138
|
|
|
95
139
|
static fromMetavariableNodeAndMetaType(metavariableNode, metaType, fileContext) {
|
|
96
140
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
97
|
-
name = metavariableName, ///
|
|
98
141
|
node = metavariableNode, ///
|
|
142
|
+
name = metavariableName, ///
|
|
99
143
|
string = fileContext.nodeAsString(node),
|
|
100
144
|
metavariable = new Metavariable(string, node, name, metaType);
|
|
101
145
|
|
|
102
146
|
return metavariable;
|
|
103
147
|
}
|
|
148
|
+
|
|
149
|
+
static fromMetavariableDeclarationNode(metavariableDeclarationNode, fileContext) {
|
|
150
|
+
const metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
|
|
151
|
+
metavariableNode = metavariableNodeQuery(metavariableDeclarationNode),
|
|
152
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
153
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
154
|
+
metavariableString = fileContext.nodeAsString(metavariableNode),
|
|
155
|
+
string = metavariableString, ///
|
|
156
|
+
node = metavariableNode, ///
|
|
157
|
+
name = metavariableName, ///
|
|
158
|
+
metaType = MetaType.fromMetaTypeNode(metaTypeNode, localContext),
|
|
159
|
+
metavariable = new Metavariable(string, node, name, metaType);
|
|
160
|
+
|
|
161
|
+
return metavariable;
|
|
162
|
+
}
|
|
104
163
|
}
|
package/src/premise.js
CHANGED
|
@@ -143,8 +143,8 @@ export default class Premise {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
toJSON() {
|
|
146
|
-
const
|
|
147
|
-
unqualifiedStatement =
|
|
146
|
+
const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
|
|
147
|
+
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
148
148
|
json = {
|
|
149
149
|
unqualifiedStatement
|
|
150
150
|
};
|
|
@@ -155,12 +155,9 @@ export default class Premise {
|
|
|
155
155
|
static fromJSON(json, fileContext) {
|
|
156
156
|
let { unqualifiedStatement } = json;
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
parser = fileContext.getParser(),
|
|
160
|
-
unqualifiedStatementString = unqualifiedStatement, ///
|
|
161
|
-
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, lexer, parser);
|
|
158
|
+
json = unqualifiedStatement; ///
|
|
162
159
|
|
|
163
|
-
unqualifiedStatement = UnqualifiedStatement.
|
|
160
|
+
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
164
161
|
|
|
165
162
|
const premise = new Premise(fileContext, unqualifiedStatement);
|
|
166
163
|
|
|
@@ -36,7 +36,7 @@ export default class QualifiedStatement {
|
|
|
36
36
|
verify(substitutions, localContext) {
|
|
37
37
|
let verified;
|
|
38
38
|
|
|
39
|
-
const qualifiedStatementString =
|
|
39
|
+
const qualifiedStatementString = this.string; ///
|
|
40
40
|
|
|
41
41
|
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement...`);
|
|
42
42
|
|
|
@@ -89,12 +89,10 @@ export default class QualifiedStatement {
|
|
|
89
89
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
90
90
|
referenceNode = referenceNodeQuery(qualifiedStatementNode),
|
|
91
91
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
92
|
-
statement = (statementNode
|
|
93
|
-
Statement.fromStatementNode(statementNode, localContext) :
|
|
94
|
-
null,
|
|
92
|
+
statement = Statement.fromStatementNode(statementNode, localContext),
|
|
95
93
|
reference = Reference.fromReferenceNode(referenceNode, fileContext),
|
|
96
94
|
node = qualifiedStatementNode, ///
|
|
97
|
-
string = fileContext.nodeAsString(node);
|
|
95
|
+
string = trim(fileContext.nodeAsString(node)); ///
|
|
98
96
|
|
|
99
97
|
qualifiedStatement = new QualifiedStatement(string, statement, reference);
|
|
100
98
|
}
|
|
@@ -3,29 +3,25 @@
|
|
|
3
3
|
import Statement from "../statement";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
5
|
|
|
6
|
-
import { trim } from "../utilities/string";
|
|
7
6
|
import { nodeQuery } from "../utilities/query";
|
|
8
7
|
|
|
9
8
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement");
|
|
10
9
|
|
|
11
10
|
export default class UnqualifiedStatement {
|
|
12
|
-
constructor(
|
|
13
|
-
this.string = string;
|
|
11
|
+
constructor(statement) {
|
|
14
12
|
this.statement = statement;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
getString() {
|
|
18
|
-
return this.string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
15
|
getStatement() {
|
|
22
16
|
return this.statement;
|
|
23
17
|
}
|
|
24
18
|
|
|
19
|
+
getString() { return this.statement.getString(); }
|
|
20
|
+
|
|
25
21
|
verify(assignments, stated, localContext) {
|
|
26
22
|
let verified;
|
|
27
23
|
|
|
28
|
-
const unqualifiedStatementString =
|
|
24
|
+
const unqualifiedStatementString = this.getString(); ///
|
|
29
25
|
|
|
30
26
|
localContext.trace(`Verifying the '${unqualifiedStatementString}' unqualified statement...`);
|
|
31
27
|
|
|
@@ -40,19 +36,37 @@ export default class UnqualifiedStatement {
|
|
|
40
36
|
return verified;
|
|
41
37
|
}
|
|
42
38
|
|
|
39
|
+
toJSON() {
|
|
40
|
+
const statementJSON = this.statement.toJSON(),
|
|
41
|
+
statement = statementJSON, ///
|
|
42
|
+
json = {
|
|
43
|
+
statement
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return json;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static fromJSON(json, fileContext) {
|
|
50
|
+
let { statement } = json;
|
|
51
|
+
|
|
52
|
+
json = statement; ///
|
|
53
|
+
|
|
54
|
+
statement = Statement.fromJSON(json, fileContext);
|
|
55
|
+
|
|
56
|
+
const unqualifiedStatement = new UnqualifiedStatement(statement);
|
|
57
|
+
|
|
58
|
+
return unqualifiedStatement;
|
|
59
|
+
}
|
|
60
|
+
|
|
43
61
|
static fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext) {
|
|
44
62
|
let unqualifiedStatement = null;
|
|
45
63
|
|
|
46
64
|
if (unqualifiedStatementNode !== null) {
|
|
47
65
|
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
48
66
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
49
|
-
statement = (statementNode
|
|
50
|
-
Statement.fromStatementNode(statementNode, localContext) :
|
|
51
|
-
null,
|
|
52
|
-
node = unqualifiedStatementNode, ///
|
|
53
|
-
string = fileContext.nodeAsString(node);
|
|
67
|
+
statement = Statement.fromStatementNode(statementNode, localContext);
|
|
54
68
|
|
|
55
|
-
unqualifiedStatement = new UnqualifiedStatement(
|
|
69
|
+
unqualifiedStatement = new UnqualifiedStatement(statement);
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
return unqualifiedStatement;
|
package/src/verifier/topLevel.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Rule from "../rule";
|
|
4
|
+
import CombinatorDeclaration from "../declaration/combinator";
|
|
5
|
+
import MetavariableDeclaration from "../declaration/metavariable";
|
|
6
|
+
|
|
4
7
|
import Verifier from "../verifier";
|
|
5
8
|
import verifyError from "../verify/error";
|
|
6
9
|
import verifyAxiom from "../verify/axiom";
|
|
@@ -9,11 +12,9 @@ import verifyTheorem from "../verify/theorem";
|
|
|
9
12
|
import verifyMetaLemma from "../verify/metaLemma";
|
|
10
13
|
import verifyConjecture from "../verify/conjecture";
|
|
11
14
|
import verifyMetatheorem from "../verify/metatheorem";
|
|
12
|
-
import CombinatorDeclaration from "../declaration/combinator";
|
|
13
15
|
import verifyTypeDeclaration from "../verify/declaration/type";
|
|
14
16
|
import verifyVariableDeclaration from "../verify/declaration/variable";
|
|
15
17
|
import verifyConstructorDeclaration from "../verify/declaration/constructor";
|
|
16
|
-
import verifyMetavariableDeclaration from "../verify/declaration/metavariable";
|
|
17
18
|
|
|
18
19
|
import { nodeQuery } from "../utilities/query";
|
|
19
20
|
|
|
@@ -145,7 +146,8 @@ class TopLevelVerifier extends Verifier {
|
|
|
145
146
|
{
|
|
146
147
|
nodeQuery: metavariableDeclarationNodeQuery,
|
|
147
148
|
verify: (metavariableDeclarationNode, fileContext) => {
|
|
148
|
-
const
|
|
149
|
+
const metavariableDeclaration = MetavariableDeclaration.fromMetavariableDeclarationNode(metavariableDeclarationNode, fileContext),
|
|
150
|
+
metavariableDeclarationVerified = metavariableDeclaration.verify(fileContext);
|
|
149
151
|
|
|
150
152
|
return metavariableDeclarationVerified;
|
|
151
153
|
}
|