occam-verify-cli 0.0.833 → 0.0.835
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/conclusion.js +5 -5
- package/lib/consequent.js +3 -3
- package/lib/constants.js +5 -1
- package/lib/context/localMeta.js +20 -1
- package/lib/premise.js +7 -7
- package/lib/ruleNames.js +5 -1
- package/lib/supposition.js +4 -4
- package/lib/utilities/array.js +5 -2
- package/lib/verifier/node/metastatement.js +21 -1
- package/lib/verifier/nodes/intrinsicLevel.js +223 -0
- package/lib/verifier/nodes/metaLevel.js +204 -0
- package/lib/verifier/nodes/metaLevelToIntrinsicLevel.js +203 -0
- package/lib/verifier/nodes/statement.js +7 -7
- package/lib/verifier/nodes/term.js +3 -2
- package/lib/verify/containment.js +42 -0
- package/lib/verify/statement.js +66 -15
- package/package.json +2 -2
- package/src/conclusion.js +4 -4
- package/src/consequent.js +2 -2
- package/src/constants.js +1 -0
- package/src/context/localMeta.js +21 -0
- package/src/premise.js +6 -6
- package/src/ruleNames.js +1 -0
- package/src/supposition.js +3 -3
- package/src/utilities/array.js +1 -1
- package/src/verifier/node/metastatement.js +33 -1
- package/src/verifier/nodes/{termForVariable.js → intrinsicLevel.js} +22 -15
- package/src/verifier/nodes/{metastatementForMetavariable.js → metaLevel.js} +22 -15
- package/src/verifier/nodes/{statementForMetavariable.js → metaLevelToIntrinsicLevel.js} +4 -3
- package/src/verifier/nodes/statement.js +10 -10
- package/src/verifier/nodes/term.js +4 -1
- package/src/verify/containment.js +40 -0
- package/src/verify/statement.js +37 -13
- package/lib/verifier/nodes/metastatementForMetavariable.js +0 -197
- package/lib/verifier/nodes/statementForMetavariable.js +0 -202
- package/lib/verifier/nodes/termForVariable.js +0 -216
package/src/consequent.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import intrinsicLevelNodesVerifier from "./verifier/nodes/intrinsicLevel";
|
|
4
4
|
|
|
5
5
|
import { nodeAsString } from "./utilities/string";
|
|
6
6
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
@@ -19,7 +19,7 @@ export default class Consequent {
|
|
|
19
19
|
nonTerminalNodeB = statementNode, ///
|
|
20
20
|
localContextA = localContext, ///
|
|
21
21
|
localContextB = statementLocalContext, ///
|
|
22
|
-
nonTerminalNodeVerified =
|
|
22
|
+
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
23
23
|
const verifiedAhead = true;
|
|
24
24
|
|
|
25
25
|
return verifiedAhead;
|
package/src/constants.js
CHANGED
package/src/context/localMeta.js
CHANGED
|
@@ -104,6 +104,27 @@ class LocalMetaContext {
|
|
|
104
104
|
return metastatementMatches;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
findVariableByVariableNode(variableNode) {
|
|
108
|
+
const node = variableNode, ///
|
|
109
|
+
variables = this.getVariables(),
|
|
110
|
+
variable = variables.find((variable) => {
|
|
111
|
+
const matches = variable.matchNode(node);
|
|
112
|
+
|
|
113
|
+
if (matches) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}) || null;
|
|
117
|
+
|
|
118
|
+
return variable;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
isVariablePresentByVariableNode(variableNode) {
|
|
122
|
+
const variable = this.findVariableByVariableNode(variableNode),
|
|
123
|
+
variablePresent = (variable !== null);
|
|
124
|
+
|
|
125
|
+
return variablePresent;
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
findMetavariableByMetavariableNode(metavariableNode) {
|
|
108
129
|
const node = metavariableNode, ///
|
|
109
130
|
metavariables = this.getMetavariables(),
|
package/src/premise.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import metaLevelNodesVerifier from "./verifier/nodes/metaLevel";
|
|
4
|
+
import metaLevelToIntrinsicLevelNodesVerifier from "./verifier/nodes/metaLevelToIntrinsicLevel";
|
|
5
5
|
|
|
6
6
|
import { match } from "./utilities/array";
|
|
7
7
|
import { nodeAsString } from "./utilities/string";
|
|
@@ -46,7 +46,7 @@ export default class Premise {
|
|
|
46
46
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
47
47
|
fileContextA = fileContext, ///
|
|
48
48
|
localContextB = statementLocalContext, ///
|
|
49
|
-
nonTerminalNodeVerified =
|
|
49
|
+
nonTerminalNodeVerified = metaLevelToIntrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
|
|
50
50
|
const verifiedAhead = true;
|
|
51
51
|
|
|
52
52
|
return verifiedAhead;
|
|
@@ -67,7 +67,7 @@ export default class Premise {
|
|
|
67
67
|
nonTerminalNodeB = statementNode, ///
|
|
68
68
|
fileContextA = fileContext, ///
|
|
69
69
|
localContextB = statementLocalContext, ///
|
|
70
|
-
nonTerminalNodeVerified =
|
|
70
|
+
nonTerminalNodeVerified = metaLevelToIntrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
|
|
71
71
|
const verifiedAhead = true;
|
|
72
72
|
|
|
73
73
|
return verifiedAhead;
|
|
@@ -99,7 +99,7 @@ export default class Premise {
|
|
|
99
99
|
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
100
100
|
fileContextA = fileContext, ///
|
|
101
101
|
localMetaContextB = metastatementLocalMetaContext, ///
|
|
102
|
-
nonTerminalNodeVerified =
|
|
102
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
|
|
103
103
|
const verifiedAhead = true;
|
|
104
104
|
|
|
105
105
|
return verifiedAhead;
|
|
@@ -120,7 +120,7 @@ export default class Premise {
|
|
|
120
120
|
nonTerminalNodeB = metastatementNode, ///
|
|
121
121
|
fileContextA = fileContext, ///
|
|
122
122
|
localMetaContextB = metastatementLocalMetaContext, ///
|
|
123
|
-
nonTerminalNodeVerified =
|
|
123
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
|
|
124
124
|
const verifiedAhead = true;
|
|
125
125
|
|
|
126
126
|
return verifiedAhead;
|
package/src/ruleNames.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export const TERM_RULE_NAME = "term";
|
|
4
4
|
export const TYPE_RULE_NAME = "type";
|
|
5
5
|
export const LABEL_RULE_NAME = "label";
|
|
6
|
+
export const VARIABLE_RULE_NAME = "variable";
|
|
6
7
|
export const ARGUMENT_RULE_NAME = "argument";
|
|
7
8
|
export const SUBPROOF_RULE_NAME = "subproof";
|
|
8
9
|
export const STATEMENT_RULE_NAME = "statement";
|
package/src/supposition.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import intrinsicLevelNodesVerifier from "./verifier/nodes/intrinsicLevel";
|
|
4
4
|
|
|
5
5
|
import { match } from "./utilities/array";
|
|
6
6
|
import { nodeAsString } from "./utilities/string";
|
|
@@ -43,7 +43,7 @@ export default class Supposition {
|
|
|
43
43
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
44
44
|
localContextA = localContext, ///
|
|
45
45
|
localContextB = statementLocalContext, ///
|
|
46
|
-
nonTerminalNodeVerified =
|
|
46
|
+
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
47
47
|
const verifiedAhead = true;
|
|
48
48
|
|
|
49
49
|
return verifiedAhead;
|
|
@@ -64,7 +64,7 @@ export default class Supposition {
|
|
|
64
64
|
nonTerminalNodeB = statementNode, ///
|
|
65
65
|
localContextA = localContext, ///
|
|
66
66
|
localContextB = statementLocalContext, ///
|
|
67
|
-
nonTerminalNodeVerified =
|
|
67
|
+
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
68
68
|
const verifiedAhead = true;
|
|
69
69
|
|
|
70
70
|
return verifiedAhead;
|
package/src/utilities/array.js
CHANGED
|
@@ -6,7 +6,7 @@ import permutationsMatrix from "../permutationsMatrix";
|
|
|
6
6
|
|
|
7
7
|
import { MAXIMUM_INDEXES_LENGTH, MAXIMUM_PERMUTATION_LENGTH } from "../constants";
|
|
8
8
|
|
|
9
|
-
export const { first, second, last, push, prune, match, filter, compress } = arrayUtilities;
|
|
9
|
+
export const { first, second, third, last, push, prune, match, filter, compress } = arrayUtilities;
|
|
10
10
|
|
|
11
11
|
export function someSubArray(array, subArrayLength, callback) {
|
|
12
12
|
let found = false;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import NodeVerifier from "../../verifier/node";
|
|
4
4
|
|
|
5
|
-
import { METAVARIABLE_RULE_NAME } from "../../ruleNames";
|
|
5
|
+
import { VARIABLE_RULE_NAME, METAVARIABLE_RULE_NAME } from "../../ruleNames";
|
|
6
6
|
|
|
7
7
|
class MetastatementNodeVerifier extends NodeVerifier {
|
|
8
8
|
verifyNonTerminalNode(nonTerminalNode, localMetaContext, verifyAhead) {
|
|
@@ -21,6 +21,16 @@ class MetastatementNodeVerifier extends NodeVerifier {
|
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
case VARIABLE_RULE_NAME: {
|
|
25
|
+
const variableNode = nonTerminalNode, ///
|
|
26
|
+
variableVerified = verifyVariable(variableNode, localMetaContext, verifyAhead),
|
|
27
|
+
variableNodeVerified = variableVerified; ///
|
|
28
|
+
|
|
29
|
+
nonTerminalNodeVerified = variableNodeVerified; ///
|
|
30
|
+
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
default: {
|
|
25
35
|
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNode, localMetaContext, verifyAhead);
|
|
26
36
|
|
|
@@ -57,3 +67,25 @@ function verifyMetavariable(metavariableNode, localMetaContext, verifyAhead) {
|
|
|
57
67
|
|
|
58
68
|
return metavariableVerified;
|
|
59
69
|
}
|
|
70
|
+
|
|
71
|
+
function verifyVariable(variableNode, localMetaContext, verifyAhead) {
|
|
72
|
+
let variableVerified;
|
|
73
|
+
|
|
74
|
+
const variableString = localMetaContext.nodeAsString(variableNode);
|
|
75
|
+
|
|
76
|
+
localMetaContext.trace(`Verifying the '${variableString}' variable...`, variableNode);
|
|
77
|
+
|
|
78
|
+
const variablePresent = localMetaContext.isVariablePresentByVariableNode(variableNode);
|
|
79
|
+
|
|
80
|
+
if (variablePresent) {
|
|
81
|
+
const verifiedAhead = verifyAhead();
|
|
82
|
+
|
|
83
|
+
variableVerified = verifiedAhead; ///
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (variableVerified) {
|
|
87
|
+
localMetaContext.debug(`...verified the '${variableString}' variable.`, variableNode);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return variableVerified;
|
|
91
|
+
}
|
|
@@ -10,29 +10,36 @@ import { TERM_RULE_NAME } from "../../ruleNames";
|
|
|
10
10
|
|
|
11
11
|
const variableNodeQuery = nodeQuery('/term/variable!');
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class IntrinsicLevelNodesVerifier extends NodesVerifier {
|
|
14
14
|
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead) {
|
|
15
15
|
let nonTerminalNodeVerified = false;
|
|
16
16
|
|
|
17
17
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
18
18
|
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName();
|
|
19
19
|
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
nonTerminalNodeBRuleNameTermRuleName = (nonTerminalNodeBRuleName === TERM_RULE_NAME);
|
|
20
|
+
if (nonTerminalNodeARuleName === nonTerminalNodeBRuleName) {
|
|
21
|
+
const ruleName = nonTerminalNodeARuleName; ///
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
switch (ruleName) {
|
|
24
|
+
case TERM_RULE_NAME: {
|
|
25
|
+
const termNodeA = nonTerminalNodeA, ///
|
|
26
|
+
termNodeB = nonTerminalNodeB, ///
|
|
27
|
+
termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (termNodeVerified) {
|
|
30
|
+
nonTerminalNodeVerified = true; ///
|
|
31
|
+
} else {
|
|
32
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
default: {
|
|
32
39
|
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
40
|
+
|
|
41
|
+
break;
|
|
33
42
|
}
|
|
34
|
-
} else {
|
|
35
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -115,6 +122,6 @@ class TermForVariableNodesVerifier extends NodesVerifier {
|
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
|
|
118
|
-
const
|
|
125
|
+
const intrinsicLevelNodesVerifier = new IntrinsicLevelNodesVerifier();
|
|
119
126
|
|
|
120
|
-
export default
|
|
127
|
+
export default intrinsicLevelNodesVerifier;
|
|
@@ -8,29 +8,36 @@ import { METASTATEMENT_RULE_NAME } from "../../ruleNames";
|
|
|
8
8
|
|
|
9
9
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class MetaLevelNodesVerifier extends NodesVerifier {
|
|
12
12
|
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
|
|
13
13
|
let nonTerminalNodeVerified = false;
|
|
14
14
|
|
|
15
15
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
16
16
|
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName();
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
nonTerminalNodeBRuleNameMetastatementRuleName = (nonTerminalNodeBRuleName === METASTATEMENT_RULE_NAME);
|
|
18
|
+
if (nonTerminalNodeARuleName === nonTerminalNodeBRuleName) {
|
|
19
|
+
const ruleName = nonTerminalNodeARuleName; ///
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
switch (ruleName) {
|
|
22
|
+
case METASTATEMENT_RULE_NAME: {
|
|
23
|
+
const metastatementNodeA = nonTerminalNodeA, ///
|
|
24
|
+
metastatementNodeB = nonTerminalNodeB, ///
|
|
25
|
+
metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (metastatementNodeVerified) {
|
|
28
|
+
nonTerminalNodeVerified = true; ///
|
|
29
|
+
} else {
|
|
30
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
default: {
|
|
30
37
|
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
38
|
+
|
|
39
|
+
break;
|
|
31
40
|
}
|
|
32
|
-
} else {
|
|
33
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
|
|
@@ -82,6 +89,6 @@ class MetastatementForMetavariableNodesVerifier extends NodesVerifier {
|
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
|
|
85
|
-
const
|
|
92
|
+
const metaLevelNodesVerifier = new MetaLevelNodesVerifier();
|
|
86
93
|
|
|
87
|
-
export default
|
|
94
|
+
export default metaLevelNodesVerifier;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import NodesVerifier from "../../verifier/nodes";
|
|
4
|
+
import TermForVariableSubstitution from "../../substitution/termForVariable";
|
|
4
5
|
import StatementForMetavariableSubstitution from "../../substitution/statementForMetavariable";
|
|
5
6
|
|
|
6
7
|
import { nodeQuery } from "../../utilities/query";
|
|
@@ -9,7 +10,7 @@ import { STATEMENT_RULE_NAME, METASTATEMENT_RULE_NAME, META_ARGUMENT_RULE_NAME }
|
|
|
9
10
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!'),
|
|
10
11
|
metaArgumentChildNodeNodeQuery = nodeQuery('/metaArgument/*!');
|
|
11
12
|
|
|
12
|
-
class
|
|
13
|
+
class MetaLevelToIntrinsicLevelNodesVerifier extends NodesVerifier {
|
|
13
14
|
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext) {
|
|
14
15
|
let nonTerminalNodeVerified = false;
|
|
15
16
|
|
|
@@ -98,6 +99,6 @@ class StatementForMetavariableNodesVerifier extends NodesVerifier {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
const
|
|
102
|
+
const metaLevelToIntrinsicLevelNodesVerifier = new MetaLevelToIntrinsicLevelNodesVerifier();
|
|
102
103
|
|
|
103
|
-
export default
|
|
104
|
+
export default metaLevelToIntrinsicLevelNodesVerifier;
|
|
@@ -23,16 +23,6 @@ class StatementNodesVerifier extends NodesVerifier {
|
|
|
23
23
|
|
|
24
24
|
if (ruleName === combinatorRuleName) {
|
|
25
25
|
switch (ruleName) {
|
|
26
|
-
case ARGUMENT_RULE_NAME: {
|
|
27
|
-
const argumentNode = nonTerminalNode, ///
|
|
28
|
-
constructorArgumentNode = combinatorNonTerminalNode, ///
|
|
29
|
-
argumentNodeVerified = termNodesVerifier.verifyArgumentNode(argumentNode, constructorArgumentNode, context, verifyAhead);
|
|
30
|
-
|
|
31
|
-
nonTerminalNodeVerified = argumentNodeVerified; ///
|
|
32
|
-
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
26
|
case META_ARGUMENT_RULE_NAME: {
|
|
37
27
|
const metaArgumentNode = nonTerminalNode, ///
|
|
38
28
|
combinatorMetaargumentNode = combinatorNonTerminalNode, ///
|
|
@@ -43,6 +33,16 @@ class StatementNodesVerifier extends NodesVerifier {
|
|
|
43
33
|
break;
|
|
44
34
|
}
|
|
45
35
|
|
|
36
|
+
case ARGUMENT_RULE_NAME: {
|
|
37
|
+
const argumentNode = nonTerminalNode, ///
|
|
38
|
+
constructorArgumentNode = combinatorNonTerminalNode, ///
|
|
39
|
+
argumentNodeVerified = termNodesVerifier.verifyArgumentNode(argumentNode, constructorArgumentNode, context, verifyAhead);
|
|
40
|
+
|
|
41
|
+
nonTerminalNodeVerified = argumentNodeVerified; ///
|
|
42
|
+
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
46
|
default: {
|
|
47
47
|
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead);
|
|
48
48
|
|
|
@@ -10,9 +10,12 @@ const termNodeQuery = nodeQuery("/argument/term!"),
|
|
|
10
10
|
typeNodeQuery = nodeQuery("/argument/type!");
|
|
11
11
|
|
|
12
12
|
class TermNodesVerifier extends NodesVerifier {
|
|
13
|
-
verifyNonTerminalNode(
|
|
13
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead) {
|
|
14
14
|
let nonTerminalNodeVerified = false;
|
|
15
15
|
|
|
16
|
+
const nonTerminalNode = nonTerminalNodeA, ///
|
|
17
|
+
constructorNonTerminalNode = nonTerminalNodeB; ///
|
|
18
|
+
|
|
16
19
|
const ruleName = nonTerminalNode.getRuleName(), ///
|
|
17
20
|
constructorRuleName = constructorNonTerminalNode.getRuleName(); ///
|
|
18
21
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { third } from "../utilities/array";
|
|
4
|
+
import { CONTAINED } from "../constants";
|
|
5
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
6
|
+
|
|
7
|
+
const statementVariableNodesQuery = nodesQuery("/statement//variable");
|
|
8
|
+
|
|
9
|
+
export const containmentVariableNodeQuery = nodeQuery("/containment/argument/term/variable!");
|
|
10
|
+
|
|
11
|
+
export default function verifyContainment(containmentNode, statementNode) {
|
|
12
|
+
let containmentVerified = false;
|
|
13
|
+
|
|
14
|
+
const contained = containedFromContainmendNode(containmentNode),
|
|
15
|
+
statementVariableNodes = statementVariableNodesQuery(statementNode),
|
|
16
|
+
containmentVariableNode = containmentVariableNodeQuery(containmentNode),
|
|
17
|
+
containmentVariableNodeMatchesStatementVariableNode = statementVariableNodes.some((statementVariableNode) => {
|
|
18
|
+
const containmentVariableNodeMatchesStatementVariableNode = containmentVariableNode.match(statementVariableNode);
|
|
19
|
+
|
|
20
|
+
if (containmentVariableNodeMatchesStatementVariableNode) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (contained === containmentVariableNodeMatchesStatementVariableNode) {
|
|
26
|
+
containmentVerified = true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return containmentVerified;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function containedFromContainmendNode(containmentNode) {
|
|
33
|
+
const childNodes = containmentNode.getChildNodes(),
|
|
34
|
+
thirdChildNode = third(childNodes),
|
|
35
|
+
terminalNode = thirdChildNode, ///
|
|
36
|
+
content = terminalNode.getContent(),
|
|
37
|
+
contained = (content === CONTAINED);
|
|
38
|
+
|
|
39
|
+
return contained;
|
|
40
|
+
}
|
package/src/verify/statement.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import verifyEquality from "../verify/equality";
|
|
4
|
+
import verifyContainment from "../verify/containment";
|
|
4
5
|
import bracketedCombinator from "../ocmbinator/bracketed";
|
|
5
6
|
import verifyTypeAssertion from "../verify/typeAssertion";
|
|
6
7
|
import statementNodesVerifier from "../verifier/nodes/statement";
|
|
7
8
|
|
|
8
9
|
import { nodeQuery } from "../utilities/query";
|
|
10
|
+
import { containmentVariableNodeQuery } from "../verify/containment";
|
|
9
11
|
|
|
10
12
|
const equalityNodeQuery = nodeQuery("/statement/equality!"),
|
|
13
|
+
statementNodeQuery = nodeQuery("/statement/statement!"),
|
|
11
14
|
containmentNodeQuery = nodeQuery("/statement/containment!"),
|
|
12
15
|
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
|
|
13
16
|
|
|
@@ -112,25 +115,46 @@ function verifyStatementAsTypeAssertion(statementNode, assignments, derived, con
|
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
function verifyStatementWithContainment(statementNode, assignments, derived, context, verifyAhead) {
|
|
115
|
-
let
|
|
118
|
+
let statementVerifiedWithContainment = false;
|
|
116
119
|
|
|
117
120
|
const containmentNode = containmentNodeQuery(statementNode);
|
|
118
121
|
|
|
119
122
|
if (containmentNode !== null) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
123
|
+
statementNode = statementNodeQuery(statementNode); ///
|
|
124
|
+
|
|
125
|
+
const statementString = context.nodeAsString(statementNode),
|
|
126
|
+
containmentVariableNode = containmentVariableNodeQuery(containmentNode),
|
|
127
|
+
containmentVariableString = context.nodeAsString(containmentVariableNode);
|
|
128
|
+
|
|
129
|
+
context.trace(`Verifying that the '${containmentVariableString}' is either contained in or omitted from the '${statementString}' statement...`, statementNode);
|
|
130
|
+
|
|
131
|
+
const containmentVerified = verifyContainment(containmentNode, statementNode);
|
|
132
|
+
|
|
133
|
+
if (containmentVerified) {
|
|
134
|
+
const verifyStatementFunctions = [
|
|
135
|
+
verifyStatementAsEquality,
|
|
136
|
+
verifyStatementAgainstCombinators
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
const statementVerified = verifyStatementFunctions.some((verifyStatementFunction) => {
|
|
140
|
+
const derived = false,
|
|
141
|
+
assignments = [],
|
|
142
|
+
statementVerified = verifyStatementFunction(statementNode, assignments, derived, context, verifyAhead);
|
|
143
|
+
|
|
144
|
+
if (statementVerified) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
statementVerifiedWithContainment = statementVerified; ///
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (statementVerifiedWithContainment) {
|
|
153
|
+
context.debug(`...verified that '${containmentVariableString}' is either contained in or omitted from the '${statementString}' statement.`, statementNode);
|
|
154
|
+
}
|
|
131
155
|
}
|
|
132
156
|
|
|
133
|
-
return
|
|
157
|
+
return statementVerifiedWithContainment;
|
|
134
158
|
}
|
|
135
159
|
|
|
136
160
|
function verifyStatementAgainstCombinators(statementNode, assignments, derived, context, verifyAhead) {
|