occam-verify-cli 0.0.1016 → 0.0.1020
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 +12 -11
- package/lib/assignment/equality.js +3 -3
- package/lib/axiom.js +102 -6
- package/lib/combinator.js +12 -12
- package/lib/conclusion.js +3 -4
- package/lib/consequent.js +75 -14
- package/lib/constructor/bracketed.js +3 -3
- package/lib/constructor.js +68 -18
- package/lib/context/file.js +49 -89
- package/lib/context/local.js +34 -58
- package/lib/declaration/combinator.js +3 -3
- package/lib/declaration/metavariable.js +15 -4
- package/lib/declaration/type.js +3 -3
- package/lib/declaration/variable.js +146 -0
- package/lib/equality.js +95 -19
- package/lib/index.js +6 -1
- package/lib/label.js +9 -9
- package/lib/lemma.js +107 -6
- package/lib/metavariable.js +14 -21
- package/lib/mixins/statement/qualified/unify.js +3 -3
- package/lib/mixins/statement/verify.js +4 -5
- package/lib/mixins/term/unify.js +82 -0
- package/lib/mixins/term/verify.js +44 -0
- package/lib/node/term/constructor/bracketed.js +15 -11
- package/lib/premise.js +3 -5
- package/lib/proofStep.js +2 -2
- package/lib/reference.js +9 -9
- package/lib/rule.js +5 -5
- package/lib/ruleNames.js +5 -5
- package/lib/statement/qualified.js +6 -3
- package/lib/statement.js +22 -39
- package/lib/supposition.js +75 -50
- package/lib/term.js +62 -16
- package/lib/topLevelAssertion.js +98 -33
- package/lib/type.js +22 -31
- package/lib/unifier/equality.js +12 -4
- package/lib/unifier/intrinsicLevel.js +1 -4
- package/lib/unifier/metaLevel.js +1 -4
- package/lib/unifier/metavariable.js +10 -7
- package/lib/unifier/statementWithCombinator.js +18 -9
- package/lib/unifier/termWithConstructor.js +11 -4
- package/lib/unify/frameWithMetaType.js +2 -2
- package/lib/utilities/name.js +9 -2
- package/lib/utilities/node.js +14 -14
- package/lib/utilities/tokens.js +7 -7
- package/lib/utilities/unify.js +3 -3
- package/lib/variable.js +155 -20
- package/lib/verifier/statementAsCombinator.js +2 -2
- package/lib/verifier/termAsConstructor.js +2 -2
- package/lib/verifier/topLevel.js +7 -7
- package/lib/verify/assertion/type.js +3 -4
- package/lib/verify/conjecture.js +2 -3
- package/lib/verify/frame.js +2 -6
- package/lib/verify/lemma.js +2 -3
- package/lib/verify/metaLemma.js +2 -3
- package/lib/verify/metatheorem.js +2 -3
- package/lib/verify/metavariableGivenMetaType.js +3 -3
- package/lib/verify/theorem.js +2 -3
- package/package.json +1 -1
- package/src/argument.js +11 -9
- package/src/assignment/equality.js +3 -4
- package/src/axiom.js +78 -1
- package/src/combinator.js +10 -9
- package/src/conclusion.js +2 -4
- package/src/consequent.js +88 -13
- package/src/constructor/bracketed.js +4 -1
- package/src/constructor.js +18 -14
- package/src/context/file.js +50 -93
- package/src/context/local.js +13 -31
- package/src/declaration/combinator.js +2 -2
- package/src/declaration/metavariable.js +20 -6
- package/src/declaration/type.js +2 -2
- package/src/declaration/variable.js +78 -0
- package/src/equality.js +123 -22
- package/src/index.js +6 -0
- package/src/label.js +7 -7
- package/src/lemma.js +91 -1
- package/src/metavariable.js +13 -22
- package/src/mixins/statement/qualified/unify.js +2 -2
- package/src/mixins/statement/verify.js +5 -5
- package/src/mixins/term/unify.js +110 -0
- package/src/mixins/term/verify.js +47 -0
- package/src/node/term/constructor/bracketed.js +4 -3
- package/src/premise.js +2 -5
- package/src/proofStep.js +1 -1
- package/src/reference.js +7 -7
- package/src/rule.js +4 -4
- package/src/ruleNames.js +1 -1
- package/src/statement/qualified.js +7 -3
- package/src/statement.js +28 -60
- package/src/supposition.js +106 -53
- package/src/term.js +70 -14
- package/src/topLevelAssertion.js +120 -33
- package/src/type.js +39 -41
- package/src/unifier/equality.js +15 -3
- package/src/unifier/intrinsicLevel.js +0 -4
- package/src/unifier/metaLevel.js +0 -4
- package/src/unifier/metavariable.js +16 -8
- package/src/unifier/statementWithCombinator.js +33 -11
- package/src/unifier/termWithConstructor.js +17 -4
- package/src/unify/frameWithMetaType.js +1 -1
- package/src/utilities/name.js +9 -1
- package/src/utilities/node.js +14 -14
- package/src/utilities/tokens.js +4 -4
- package/src/utilities/unify.js +2 -2
- package/src/variable.js +158 -22
- package/src/verifier/statementAsCombinator.js +1 -1
- package/src/verifier/termAsConstructor.js +1 -1
- package/src/verifier/topLevel.js +9 -6
- package/src/verify/assertion/type.js +1 -1
- package/src/verify/conjecture.js +1 -1
- package/src/verify/frame.js +1 -7
- package/src/verify/lemma.js +1 -1
- package/src/verify/metaLemma.js +1 -1
- package/src/verify/metatheorem.js +1 -1
- package/src/verify/metavariableGivenMetaType.js +2 -2
- package/src/verify/theorem.js +1 -1
- package/lib/tokens/constructorTerm/bracketed.js +0 -17
- package/lib/unify/termWithBracketedConstructor.js +0 -39
- package/lib/unify/termWithConstructor.js +0 -37
- package/lib/unify/termWithConstructors.js +0 -34
- package/lib/unify/termWithTerm.js +0 -27
- package/lib/unify/termWithType.js +0 -24
- package/lib/verify/axiom.js +0 -45
- package/lib/verify/consequent.js +0 -38
- package/lib/verify/declaration/variable.js +0 -67
- package/lib/verify/equality.js +0 -92
- package/lib/verify/proofStep.js +0 -28
- package/lib/verify/term.js +0 -97
- package/lib/verify/termAsConstructor.js +0 -58
- package/lib/verify/termGivenType.js +0 -34
- package/lib/verify/terms.js +0 -38
- package/lib/verify/type.js +0 -23
- package/lib/verify/variable.js +0 -25
- package/src/tokens/constructorTerm/bracketed.js +0 -10
- package/src/unify/termWithBracketedConstructor.js +0 -39
- package/src/unify/termWithConstructor.js +0 -39
- package/src/unify/termWithConstructors.js +0 -27
- package/src/unify/termWithTerm.js +0 -24
- package/src/unify/termWithType.js +0 -14
- package/src/verify/axiom.js +0 -56
- package/src/verify/consequent.js +0 -40
- package/src/verify/declaration/variable.js +0 -85
- package/src/verify/equality.js +0 -118
- package/src/verify/proofStep.js +0 -21
- package/src/verify/term.js +0 -123
- package/src/verify/termAsConstructor.js +0 -66
- package/src/verify/termGivenType.js +0 -32
- package/src/verify/terms.js +0 -38
- package/src/verify/type.js +0 -19
- package/src/verify/variable.js +0 -21
package/src/consequent.js
CHANGED
|
@@ -1,32 +1,107 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import LocalContext from "./context/local";
|
|
3
4
|
import metaLevelUnifier from "./unifier/metaLevel";
|
|
5
|
+
import UnqualifiedStatement from "./statement/unqualified";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "./utilities/query";
|
|
8
|
+
|
|
9
|
+
const unqualifiedStatementNodeQuery = nodeQuery("/consequent/unqualifiedStatement");
|
|
4
10
|
|
|
5
11
|
export default class Consequent {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
12
|
+
constructor(fileContext, unqualifiedStatement) {
|
|
13
|
+
this.fileContext = fileContext;
|
|
14
|
+
this.unqualifiedStatement = unqualifiedStatement;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getFileContext() {
|
|
18
|
+
return this.fileContext;
|
|
8
19
|
}
|
|
9
20
|
|
|
10
|
-
|
|
11
|
-
return this.
|
|
21
|
+
getUnqualifiedStatement() {
|
|
22
|
+
return this.unqualifiedStatement;
|
|
12
23
|
}
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
getString() { return this.unqualifiedStatement.getString(); }
|
|
26
|
+
|
|
27
|
+
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
28
|
+
|
|
29
|
+
unifyStatement(statement, substitutions, localContext) {
|
|
30
|
+
let statementUnified;
|
|
31
|
+
|
|
32
|
+
const consequent = this, ///
|
|
33
|
+
statementString = statement.getString(),
|
|
34
|
+
consequentStatement = consequent.getStatement(),
|
|
35
|
+
consequentStatementString = consequentStatement.getString();
|
|
36
|
+
|
|
37
|
+
localContext.trace(`Unifying the '${statementString}' statement with the consequent's '${consequentStatementString}' statement...`);
|
|
16
38
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
39
|
+
const statementNode = statement.getNode(),
|
|
40
|
+
consequentStatementNode = consequentStatement.getNode(),
|
|
41
|
+
nodeA = consequentStatementNode, ///
|
|
42
|
+
nodeB = statementNode, ///
|
|
43
|
+
fileContextA = this.fileContext, ///
|
|
44
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
45
|
+
localContextB = localContext, ///
|
|
46
|
+
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
21
47
|
|
|
22
|
-
|
|
48
|
+
statementUnified = unified; ///
|
|
49
|
+
|
|
50
|
+
if (statementUnified) {
|
|
51
|
+
localContext.debug(`...unified the '${statementString}' statement with the consequent's '${consequentStatementString}' statement.`);
|
|
23
52
|
}
|
|
24
53
|
|
|
25
54
|
return statementUnified;
|
|
26
55
|
}
|
|
27
56
|
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
verify(localContext) {
|
|
58
|
+
let verified = false;
|
|
59
|
+
|
|
60
|
+
const consequentString = this.getString(); ///
|
|
61
|
+
|
|
62
|
+
localContext.trace(`Verifying the '${consequentString}' consequent...`);
|
|
63
|
+
|
|
64
|
+
const stated = true,
|
|
65
|
+
assignments = [],
|
|
66
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
67
|
+
|
|
68
|
+
if (unqualifiedStatementVerified) {
|
|
69
|
+
verified = true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (verified) {
|
|
73
|
+
localContext.debug(`...verified the '${consequentString}' consequent.`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return verified;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
toJSON() {
|
|
80
|
+
const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
|
|
81
|
+
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
82
|
+
json = {
|
|
83
|
+
unqualifiedStatement
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return json;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static fromJSON(json, fileContext) {
|
|
90
|
+
let { unqualifiedStatement } = json;
|
|
91
|
+
|
|
92
|
+
json = unqualifiedStatement; ///
|
|
93
|
+
|
|
94
|
+
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
95
|
+
|
|
96
|
+
const consequent = new Consequent(fileContext, unqualifiedStatement);
|
|
97
|
+
|
|
98
|
+
return consequent;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static fromConsequentNode(consequentNode, fileContext) {
|
|
102
|
+
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(consequentNode),
|
|
103
|
+
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
104
|
+
consequent = new Consequent(fileContext, unqualifiedStatement);
|
|
30
105
|
|
|
31
106
|
return consequent;
|
|
32
107
|
}
|
|
@@ -4,6 +4,7 @@ import shim from "../shim";
|
|
|
4
4
|
import Constructor from "../constructor";
|
|
5
5
|
import bracketedConstructorTermNode from "../node/term/constructor/bracketed";
|
|
6
6
|
|
|
7
|
+
import { stringFromTermAndType } from "../constructor";
|
|
7
8
|
import { bracketedConstructorTermString } from "../node/term/constructor/bracketed";
|
|
8
9
|
|
|
9
10
|
const localContext = {
|
|
@@ -19,7 +20,9 @@ export default class BracketedConstructor extends Constructor {
|
|
|
19
20
|
const { Term } = shim,
|
|
20
21
|
termNode = bracketedConstructorTermNode, ///
|
|
21
22
|
term = Term.fromTermNode(termNode, localContext),
|
|
22
|
-
|
|
23
|
+
type = null,
|
|
24
|
+
string = stringFromTermAndType(term, type),
|
|
25
|
+
bracketedConstructor = new BracketedConstructor(string, term);
|
|
23
26
|
|
|
24
27
|
return bracketedConstructor;
|
|
25
28
|
}
|
package/src/constructor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
import Type, {objectType} from "./type";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "./utilities/query";
|
|
7
7
|
|
|
@@ -24,28 +24,28 @@ export default class Constructor {
|
|
|
24
24
|
|
|
25
25
|
getType() { return this.term.getType(); }
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
let
|
|
27
|
+
verifyAtTopLevel(fileContext) {
|
|
28
|
+
let verifiedAtTopLevel;
|
|
29
29
|
|
|
30
30
|
const constructorString = this.string; ///
|
|
31
31
|
|
|
32
|
-
fileContext.trace(`Verifying the '${constructorString}' constructor...`);
|
|
32
|
+
fileContext.trace(`Verifying the '${constructorString}' constructor at top level...`);
|
|
33
33
|
|
|
34
34
|
const termTypeVerified = this.term.verifyType(fileContext);
|
|
35
35
|
|
|
36
36
|
if (termTypeVerified) {
|
|
37
|
-
const
|
|
37
|
+
const termVerifiedAtTopLevel = this.term.verifyAtTopLevel(fileContext);
|
|
38
38
|
|
|
39
|
-
if (
|
|
40
|
-
|
|
39
|
+
if (termVerifiedAtTopLevel) {
|
|
40
|
+
verifiedAtTopLevel = true; ///
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (
|
|
45
|
-
fileContext.debug(`...verified the '${constructorString}' constructor.`);
|
|
44
|
+
if (verifiedAtTopLevel) {
|
|
45
|
+
fileContext.debug(`...verified the '${constructorString}' constructor at top level.`);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return verifiedAtTopLevel;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
toJSON() {
|
|
@@ -65,6 +65,8 @@ export default class Constructor {
|
|
|
65
65
|
|
|
66
66
|
json = termJSON; ///
|
|
67
67
|
|
|
68
|
+
const { Term } = shim;
|
|
69
|
+
|
|
68
70
|
term = Term.fromJSON(json, fileContext);
|
|
69
71
|
|
|
70
72
|
const type = term.getType(),
|
|
@@ -77,8 +79,10 @@ export default class Constructor {
|
|
|
77
79
|
static fromConstructorDeclarationNode(constructorDeclarationNode, fileContext) {
|
|
78
80
|
const termNode = termNodeQuery(constructorDeclarationNode),
|
|
79
81
|
typeNode = typeNodeQuery(constructorDeclarationNode),
|
|
80
|
-
type =
|
|
81
|
-
|
|
82
|
+
type = (typeNode === null) ?
|
|
83
|
+
objectType :
|
|
84
|
+
Type.fromTypeNode(typeNode),
|
|
85
|
+
term = Term.fromTermNodeAndType(termNode, type),
|
|
82
86
|
string = stringFromTermAndType(term, type),
|
|
83
87
|
constructor = new Constructor(string, term);
|
|
84
88
|
|
|
@@ -86,7 +90,7 @@ export default class Constructor {
|
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
function stringFromTermAndType(term, type) {
|
|
93
|
+
export function stringFromTermAndType(term, type) {
|
|
90
94
|
let string;
|
|
91
95
|
|
|
92
96
|
const termString = term.getString();
|
package/src/context/file.js
CHANGED
|
@@ -364,40 +364,10 @@ export default class FileContext {
|
|
|
364
364
|
return type;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
|
|
368
|
-
let types = this.getTypes();
|
|
369
|
-
|
|
370
|
-
types.push(objectType);
|
|
371
|
-
|
|
372
|
-
const type = types.find((type) => {
|
|
373
|
-
const nodeMatches = type.matchTypeNode(typeNode);
|
|
374
|
-
|
|
375
|
-
if (nodeMatches) {
|
|
376
|
-
return true;
|
|
377
|
-
}
|
|
378
|
-
}) || null;
|
|
379
|
-
|
|
380
|
-
return type;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
findVariableByVariableNode(variableNode) {
|
|
384
|
-
const node = variableNode, ///
|
|
385
|
-
variables = this.getVariables(),
|
|
386
|
-
variable = variables.find((variable) => {
|
|
387
|
-
const nodeMatches = variable.matchNode(node);
|
|
388
|
-
|
|
389
|
-
if (nodeMatches) {
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
}) || null;
|
|
393
|
-
|
|
394
|
-
return variable;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
findMetaTypeByMetaTypeNode(metaTypeNode) {
|
|
367
|
+
findMetaTypeByMetaTypeName(metaTypeName) {
|
|
398
368
|
const metaTypes = this.getMetaTypes(),
|
|
399
369
|
metaType = metaTypes.find((metaType) => {
|
|
400
|
-
const metaTypeNodeMatches = metaType.
|
|
370
|
+
const metaTypeNodeMatches = metaType.matchMetaTypeName(metaTypeName);
|
|
401
371
|
|
|
402
372
|
if (metaTypeNodeMatches) {
|
|
403
373
|
return true;
|
|
@@ -420,6 +390,48 @@ export default class FileContext {
|
|
|
420
390
|
return label;
|
|
421
391
|
}
|
|
422
392
|
|
|
393
|
+
findMetavariableByMetavariableName(metavariableName) {
|
|
394
|
+
const name = metavariableName, ///
|
|
395
|
+
metavariables = this.getMetavariables(),
|
|
396
|
+
metavariable = metavariables.find((metavariable) => {
|
|
397
|
+
const nameMatches = metavariable.matchName(name);
|
|
398
|
+
|
|
399
|
+
if (nameMatches) {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
}) || null;
|
|
403
|
+
|
|
404
|
+
return metavariable;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
isTypePresentByTypeName(typeName) {
|
|
408
|
+
const type = this.findTypeByTypeName(typeName),
|
|
409
|
+
typePresent = (type !== null);
|
|
410
|
+
|
|
411
|
+
return typePresent;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
isVariablePresentByVariableName(variableName) {
|
|
415
|
+
const variable = this.findVariableByVariableName(variableName),
|
|
416
|
+
variablePresent = (variable !== null);
|
|
417
|
+
|
|
418
|
+
return variablePresent;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
isLabelPresentByMetavariableNode(metavariableNode) {
|
|
422
|
+
const label = this.findLabelByMetavariableNode(metavariableNode),
|
|
423
|
+
labelPresent = (label !== null);
|
|
424
|
+
|
|
425
|
+
return labelPresent;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
isMetavariablePresentByMetavariableName(metavariableName) {
|
|
429
|
+
const metavariable = this.findMetavariableByMetavariableName(metavariableName),
|
|
430
|
+
metavariablePresent = (metavariable !== null);
|
|
431
|
+
|
|
432
|
+
return metavariablePresent;
|
|
433
|
+
}
|
|
434
|
+
|
|
423
435
|
findRuleByReference(reference) {
|
|
424
436
|
const rules = this.getRules(),
|
|
425
437
|
metavariableNode = reference.getMetavariableNode(),
|
|
@@ -518,73 +530,18 @@ export default class FileContext {
|
|
|
518
530
|
return metatheorem;
|
|
519
531
|
}
|
|
520
532
|
|
|
521
|
-
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (metavariableNodeMatches) {
|
|
527
|
-
return true;
|
|
528
|
-
}
|
|
529
|
-
}) || null;
|
|
530
|
-
|
|
531
|
-
return metavariable;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
findMetavariableByMetavariableName(metavariableName) {
|
|
535
|
-
const name = metavariableName, ///
|
|
536
|
-
metavariables = this.getMetavariables(),
|
|
537
|
-
metavariable = metavariables.find((metavariable) => {
|
|
538
|
-
const nameMatches = metavariable.matchName(name);
|
|
533
|
+
findVariableByVariableName(variableName) {
|
|
534
|
+
const name = variableName, ///
|
|
535
|
+
variables = this.getVariables(),
|
|
536
|
+
variable = variables.find((variable) => {
|
|
537
|
+
const nameMatches = variable.matchName(name);
|
|
539
538
|
|
|
540
539
|
if (nameMatches) {
|
|
541
540
|
return true;
|
|
542
541
|
}
|
|
543
542
|
}) || null;
|
|
544
543
|
|
|
545
|
-
return
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
isTypePresentByTypeName(typeName) {
|
|
549
|
-
const type = this.findTypeByTypeName(typeName),
|
|
550
|
-
typePresent = (type !== null);
|
|
551
|
-
|
|
552
|
-
return typePresent;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
isTypePresentByTypeNode(typeNode) {
|
|
556
|
-
const type = this.findTypeByTypeNode(typeNode),
|
|
557
|
-
typePresent = (type !== null);
|
|
558
|
-
|
|
559
|
-
return typePresent;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
isVariablePresentByVariableNode(variableNode) {
|
|
563
|
-
const variable = this.findVariableByVariableNode(variableNode),
|
|
564
|
-
variablePresent = (variable !== null);
|
|
565
|
-
|
|
566
|
-
return variablePresent;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
isLabelPresentByMetavariableNode(metavariableNode) {
|
|
570
|
-
const label = this.findLabelByMetavariableNode(metavariableNode),
|
|
571
|
-
labelPresent = (label !== null);
|
|
572
|
-
|
|
573
|
-
return labelPresent;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
isMetavariablePresentByMetavariableName(metavariablename) {
|
|
577
|
-
const metavariable = this.findMetavariableByMetavariableName(metavariablename),
|
|
578
|
-
metavariablePresent = (metavariable !== null);
|
|
579
|
-
|
|
580
|
-
return metavariablePresent;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
isMetavariablePresentByMetavariableNode(metavariableNode) {
|
|
584
|
-
const metavariable = this.findMetavariableByMetavariableNode(metavariableNode),
|
|
585
|
-
metavariablePresent = (metavariable !== null);
|
|
586
|
-
|
|
587
|
-
return metavariablePresent;
|
|
544
|
+
return variable;
|
|
588
545
|
}
|
|
589
546
|
|
|
590
547
|
nodeAsString(node) {
|
package/src/context/local.js
CHANGED
|
@@ -303,8 +303,14 @@ class LocalContext {
|
|
|
303
303
|
return variableDefined;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
isTypePresentByTypeName(typeName) { return this.context.isTypePresentByTypeName(typeName); }
|
|
307
|
+
|
|
308
|
+
isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
|
|
309
|
+
|
|
310
|
+
isMetavariablePresentByMetavariableName(metavariableName) { return this.context.isMetavariablePresentByMetavariableName(metavariableName); }
|
|
311
|
+
|
|
312
|
+
isVariablePresentByVariableName(variableName) {
|
|
313
|
+
const variable = this.findVariableByVariableName(variableName),
|
|
308
314
|
variablePresent = (variable !== null);
|
|
309
315
|
|
|
310
316
|
return variablePresent;
|
|
@@ -319,34 +325,18 @@ class LocalContext {
|
|
|
319
325
|
|
|
320
326
|
isMetavariableDefinedByMetavariableName(metavariableName) {
|
|
321
327
|
const judgementPresent = this.isJudgementPresentByMetavariableName(metavariableName),
|
|
322
|
-
|
|
328
|
+
metavariableDefinedByMetavariableName = judgementPresent; ///
|
|
323
329
|
|
|
324
330
|
return metavariableDefinedByMetavariableName
|
|
325
331
|
}
|
|
326
332
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
isTypePresentByTypeNode(typeNode) { return this.context.isTypePresentByTypeNode(typeNode); }
|
|
330
|
-
|
|
331
|
-
isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
|
|
332
|
-
|
|
333
|
-
isMetavariablePresentByMetavariableName(metavariableName) { return this.context.isMetavariablePresentByMetavariableName(metavariableName); }
|
|
334
|
-
|
|
335
|
-
isMetavariablePresentByMetavariableNode(metavariableNode) { return this.context.isMetavariablePresentByMetavariableNode(metavariableNode); }
|
|
333
|
+
findMetaTypeByMetaTypeName(metaTypeName) { return this.context.findMetaTypeByMetaTypeName(metaTypeName); }
|
|
336
334
|
|
|
337
|
-
|
|
338
|
-
const node = variableNode, ///
|
|
339
|
-
variables = this.getVariables(),
|
|
340
|
-
variable = variables.find((variable) => {
|
|
341
|
-
const nodeMatches = variable.matchNode(node);
|
|
335
|
+
findVariableByVariableName(variableName) { return this.context.findVariableByVariableName(variableName); }
|
|
342
336
|
|
|
343
|
-
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
|
-
}) || null;
|
|
337
|
+
findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
347
338
|
|
|
348
|
-
|
|
349
|
-
}
|
|
339
|
+
findMetavariableByMetavariableName(metavariableName) { return this.context.findMetavariableByMetavariableName(metavariableName); }
|
|
350
340
|
|
|
351
341
|
findJudgementByMetavariableName(metavariableName) {
|
|
352
342
|
const judgements = this.getJudgements(),
|
|
@@ -375,16 +365,8 @@ class LocalContext {
|
|
|
375
365
|
return metavariable;
|
|
376
366
|
}
|
|
377
367
|
|
|
378
|
-
findMetaTypeByMetaTypeNode(metaTypeNode) { return this.context.findMetaTypeByMetaTypeNode(metaTypeNode); }
|
|
379
|
-
|
|
380
|
-
findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
381
|
-
|
|
382
|
-
findMetavariableByMetavariableName(metavariableName) { return this.context.findMetavariableByMetavariableName(metavariableName); }
|
|
383
|
-
|
|
384
368
|
findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
385
369
|
|
|
386
|
-
findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
387
|
-
|
|
388
370
|
findRuleByReference(reference) { return this.context.findRuleByReference(reference); }
|
|
389
371
|
|
|
390
372
|
findAxiomByReference(reference) { return this.context.findAxiomByReference(reference); }
|
|
@@ -25,9 +25,9 @@ export default class CombinatorDeclaration {
|
|
|
25
25
|
|
|
26
26
|
this.fileContext.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration...`);
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const combinatorVerifiedAtTopLevel = this.combinator.verifyAtTopLevel(this.fileContext);
|
|
29
29
|
|
|
30
|
-
if (
|
|
30
|
+
if (combinatorVerifiedAtTopLevel) {
|
|
31
31
|
this.fileContext.addCombinator(this.combinator);
|
|
32
32
|
|
|
33
33
|
verified = true;
|
|
@@ -33,9 +33,9 @@ export default class MetavariableDeclaration {
|
|
|
33
33
|
|
|
34
34
|
this.fileContext.trace(`Verifying the '${metavariableDeclarationString}' metavariable declaration...`);
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const metavariableVerifiedAtTopLevel = this.metavariable.verifyAtTopLevel(this.fileContext);
|
|
37
37
|
|
|
38
|
-
if (
|
|
38
|
+
if (metavariableVerifiedAtTopLevel) {
|
|
39
39
|
this.fileContext.addMetavariable(this.metavariable);
|
|
40
40
|
|
|
41
41
|
verified = true;
|
|
@@ -52,11 +52,25 @@ export default class MetavariableDeclaration {
|
|
|
52
52
|
const metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
|
|
53
53
|
metaType = MetaType.fromMetaTypeNode(metaTypeNode, fileContext),
|
|
54
54
|
metavariable = Metavariable.fromMetavariableDeclarationNode(metavariableDeclarationNode, fileContext),
|
|
55
|
-
|
|
56
|
-
metaTypeString = metaType.getString(),
|
|
57
|
-
string = `${metavariableString}:${metaTypeString}`,
|
|
55
|
+
string = stringFromMetavariableAndMetaType(metavariable, metaType),
|
|
58
56
|
metavariableDeclaration = new MetavariableDeclaration(fileContext, string, metavariable);
|
|
59
57
|
|
|
60
58
|
return metavariableDeclaration;
|
|
61
59
|
}
|
|
62
|
-
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function stringFromMetavariableAndMetaType(metavariable, metaType) {
|
|
63
|
+
let string;
|
|
64
|
+
|
|
65
|
+
const metavariableString = metavariable.getString();
|
|
66
|
+
|
|
67
|
+
if (metaType === null) {
|
|
68
|
+
string = metavariableString; ///
|
|
69
|
+
} else {
|
|
70
|
+
const metaTypeString = metaType.getString();
|
|
71
|
+
|
|
72
|
+
string = `${metavariableString}:${metaTypeString}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return string;
|
|
76
|
+
}
|
package/src/declaration/type.js
CHANGED
|
@@ -25,9 +25,9 @@ export default class TypeDeclaration {
|
|
|
25
25
|
|
|
26
26
|
this.fileContext.trace(`Verifying the '${typeDeclarationString}' type declaration...`);
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const typeVerifiedAtTopLevel = this.type.verifyAtTopLevel(this.fileContext);
|
|
29
29
|
|
|
30
|
-
if (
|
|
30
|
+
if (typeVerifiedAtTopLevel) {
|
|
31
31
|
this.fileContext.addType(this.type);
|
|
32
32
|
|
|
33
33
|
verified = true;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Type, {objectType} from "../type";
|
|
4
|
+
import Variable from "../variable";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const typeNodeQuery = nodeQuery("/variableDeclaration/type");
|
|
9
|
+
|
|
10
|
+
export default class VariableDeclaration {
|
|
11
|
+
constructor(fileContext, string, variable) {
|
|
12
|
+
this.fileContext = fileContext;
|
|
13
|
+
this.string = string;
|
|
14
|
+
this.variable = variable;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getFileContext() {
|
|
18
|
+
return this.fileContext;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getString() {
|
|
22
|
+
return this.string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getVariable() {
|
|
26
|
+
return this.variable;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
verify() {
|
|
30
|
+
let verified;
|
|
31
|
+
|
|
32
|
+
const variableDeclarationString = this.string; ///
|
|
33
|
+
|
|
34
|
+
this.fileContext.trace(`Verifying the '${variableDeclarationString}' variable declaration...`);
|
|
35
|
+
|
|
36
|
+
const variableVerifiedAtTopLevel = this.variable.verifyAtTopLevel(this.fileContext);
|
|
37
|
+
|
|
38
|
+
if (variableVerifiedAtTopLevel) {
|
|
39
|
+
this.fileContext.addVariable(this.variable);
|
|
40
|
+
|
|
41
|
+
verified = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (verified) {
|
|
45
|
+
this.fileContext.debug(`...verified the '${variableDeclarationString}' variable declaration.`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return verified;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static fromVariableDeclarationNode(variableDeclarationNode, fileContext) {
|
|
52
|
+
const typeNode = typeNodeQuery(variableDeclarationNode),
|
|
53
|
+
type = (typeNode === null) ?
|
|
54
|
+
objectType :
|
|
55
|
+
Type.fromTypeNode(typeNode, fileContext),
|
|
56
|
+
variable = Variable.fromVariableDeclarationNode(variableDeclarationNode, fileContext),
|
|
57
|
+
string = stringFromVariableAndType(variable, type),
|
|
58
|
+
variableDeclaration = new VariableDeclaration(fileContext, string, variable);
|
|
59
|
+
|
|
60
|
+
return variableDeclaration;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function stringFromVariableAndType(variable, type) {
|
|
65
|
+
let string;
|
|
66
|
+
|
|
67
|
+
const variableString = variable.getString();
|
|
68
|
+
|
|
69
|
+
if (type === null) {
|
|
70
|
+
string = variableString; ///
|
|
71
|
+
} else {
|
|
72
|
+
const typeString = type.getString();
|
|
73
|
+
|
|
74
|
+
string = `${variableString}:${typeString}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return string;
|
|
78
|
+
}
|