occam-verify-cli 0.0.698 → 0.0.702
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/assignment/equality.js +4 -4
- package/lib/assignment/metavariable.js +4 -4
- package/lib/assignment/variable.js +4 -4
- package/lib/collection.js +44 -6
- package/lib/conclusion.js +6 -6
- package/lib/consequent.js +4 -4
- package/lib/constructor.js +3 -10
- package/lib/context/file.js +12 -73
- package/lib/context/local.js +31 -70
- package/lib/context/localMeta.js +12 -9
- package/lib/context/release.js +2 -4
- package/lib/equality.js +22 -6
- package/lib/metaType.js +10 -10
- package/lib/metavariable.js +3 -10
- package/lib/mixins/context.js +107 -0
- package/lib/premise.js +9 -9
- package/lib/ruleNames.js +9 -1
- package/lib/supposition.js +4 -4
- package/lib/type.js +23 -27
- package/lib/utilities/collection.js +27 -13
- package/lib/utilities/node.js +3 -73
- package/lib/utilities/tokens.js +1 -8
- package/lib/variable.js +11 -10
- package/lib/verifier/node/statementAsCombinator.js +4 -1
- package/lib/verifier/node/termAsConstructor.js +4 -20
- package/lib/verifier/nodes/equality.js +169 -0
- package/lib/verifier/nodes/metastatementForMetavariable.js +6 -7
- package/lib/verifier/nodes/statement.js +12 -4
- package/lib/verifier/nodes/statementForMetavariable.js +6 -7
- package/lib/verifier/nodes/termForVariable.js +19 -20
- package/lib/verify/axiom.js +3 -8
- package/lib/verify/conclusion.js +2 -2
- package/lib/verify/conjecture.js +4 -9
- package/lib/verify/consequent.js +3 -3
- package/lib/verify/derivation.js +30 -13
- package/lib/verify/equality.js +17 -12
- package/lib/verify/givenType.js +32 -0
- package/lib/verify/lemma.js +4 -9
- package/lib/verify/metastatement.js +3 -3
- package/lib/verify/premises.js +28 -0
- package/lib/verify/rule.js +3 -8
- package/lib/verify/ruleDerivation.js +6 -8
- package/lib/verify/statement/qualified.js +135 -37
- package/lib/verify/statement.js +34 -42
- package/lib/verify/supposition.js +6 -7
- package/lib/verify/suppositions.js +28 -0
- package/lib/verify/term.js +25 -60
- package/lib/verify/termAndGivenType.js +39 -0
- package/lib/verify/termAsGivenVariable.js +36 -0
- package/lib/verify/theorem.js +3 -8
- package/lib/verify/typeAssertion.js +44 -27
- package/package.json +1 -1
- package/src/assignment/equality.js +5 -5
- package/src/assignment/metavariable.js +5 -5
- package/src/assignment/variable.js +7 -5
- package/src/collection.js +55 -5
- package/src/conclusion.js +6 -6
- package/src/consequent.js +4 -4
- package/src/constructor.js +2 -7
- package/src/context/file.js +16 -13
- package/src/context/local.js +39 -86
- package/src/context/localMeta.js +11 -7
- package/src/context/release.js +6 -9
- package/src/equality.js +25 -4
- package/src/metaType.js +10 -10
- package/src/metavariable.js +2 -7
- package/src/mixins/{file.js → context.js} +20 -2
- package/src/premise.js +10 -10
- package/src/ruleNames.js +2 -0
- package/src/supposition.js +3 -3
- package/src/type.js +27 -39
- package/src/utilities/collection.js +31 -11
- package/src/utilities/node.js +3 -81
- package/src/utilities/tokens.js +0 -8
- package/src/variable.js +9 -6
- package/src/verifier/node/statementAsCombinator.js +7 -1
- package/src/verifier/node/termAsConstructor.js +5 -26
- package/src/verifier/nodes/equality.js +47 -0
- package/src/verifier/nodes/metastatementForMetavariable.js +10 -10
- package/src/verifier/nodes/statement.js +1 -1
- package/src/verifier/nodes/statementForMetavariable.js +10 -10
- package/src/verifier/nodes/termForVariable.js +30 -30
- package/src/verify/axiom.js +2 -8
- package/src/verify/conclusion.js +1 -1
- package/src/verify/conjecture.js +3 -9
- package/src/verify/consequent.js +4 -4
- package/src/verify/derivation.js +39 -16
- package/src/verify/equality.js +20 -11
- package/src/verify/{standaloneType.js → givenType.js} +7 -7
- package/src/verify/lemma.js +3 -9
- package/src/verify/metastatement.js +2 -2
- package/src/verify/premises.js +17 -0
- package/src/verify/rule.js +2 -8
- package/src/verify/ruleDerivation.js +5 -7
- package/src/verify/statement/qualified.js +194 -39
- package/src/verify/statement.js +47 -47
- package/src/verify/supposition.js +10 -12
- package/src/verify/suppositions.js +17 -0
- package/src/verify/term.js +26 -64
- package/src/verify/termAndGivenType.js +37 -0
- package/src/verify/termAsGivenVariable.js +39 -0
- package/src/verify/theorem.js +2 -8
- package/src/verify/typeAssertion.js +59 -32
- package/lib/mixins/file.js +0 -83
- package/lib/mixins/logging.js +0 -39
- package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/metastatementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/termForVariable/consequent.js +0 -114
- package/lib/verifier/nodes/termForVariable/supposition.js +0 -114
- package/lib/verify/standaloneType.js +0 -32
- package/lib/verify/termAndStandaloneType.js +0 -39
- package/lib/verify/termAsVariableAndStandaloneType.js +0 -39
- package/src/mixins/logging.js +0 -24
- package/src/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/metastatementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/termForVariable/consequent.js +0 -11
- package/src/verifier/nodes/termForVariable/supposition.js +0 -11
- package/src/verify/termAndStandaloneType.js +0 -37
- package/src/verify/termAsVariableAndStandaloneType.js +0 -38
package/src/premise.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import statementForMetavariableNodesVerifier from "./verifier/nodes/statementForMetavariable";
|
|
4
|
+
import metastatementForMetavariableNodesVerifier from "./verifier/nodes/metastatementForMetavariable";
|
|
5
5
|
|
|
6
6
|
import { nodeAsString } from "./utilities/string";
|
|
7
7
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
@@ -46,7 +46,7 @@ export default class Premise {
|
|
|
46
46
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
47
47
|
fileContextA = fileContext, ///
|
|
48
48
|
localContextB = statementLocalContext, ///
|
|
49
|
-
nonTerminalNodeVerified =
|
|
49
|
+
nonTerminalNodeVerified = statementForMetavariableNodesVerifier.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 = statementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
|
|
71
71
|
const verifiedAhead = true;
|
|
72
72
|
|
|
73
73
|
return verifiedAhead;
|
|
@@ -77,7 +77,7 @@ export default class Premise {
|
|
|
77
77
|
return statementNodeMatches;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext,
|
|
80
|
+
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
81
81
|
let ruleSubproofNodeMatches = false;
|
|
82
82
|
|
|
83
83
|
const ruleSubproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
@@ -99,8 +99,8 @@ export default class Premise {
|
|
|
99
99
|
nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
100
100
|
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
101
101
|
fileContextA = fileContext, ///
|
|
102
|
-
|
|
103
|
-
nonTerminalNodeVerified =
|
|
102
|
+
localMetaContextB = metastatementLocalMetaContext, ///
|
|
103
|
+
nonTerminalNodeVerified = metastatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
|
|
104
104
|
const verifiedAhead = true;
|
|
105
105
|
|
|
106
106
|
return verifiedAhead;
|
|
@@ -116,12 +116,12 @@ export default class Premise {
|
|
|
116
116
|
return ruleSubproofNodeMatches;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
matchMetastatementNode(metastatementNode, substitutions, fileContext,
|
|
119
|
+
matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
120
120
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
121
121
|
nonTerminalNodeB = metastatementNode, ///
|
|
122
122
|
fileContextA = fileContext, ///
|
|
123
|
-
|
|
124
|
-
nonTerminalNodeVerified =
|
|
123
|
+
localMetaContextB = metastatementLocalMetaContext, ///
|
|
124
|
+
nonTerminalNodeVerified = metastatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
|
|
125
125
|
const verifiedAhead = true;
|
|
126
126
|
|
|
127
127
|
return verifiedAhead;
|
package/src/ruleNames.js
CHANGED
|
@@ -13,7 +13,9 @@ export const METASTATEMENT_RULE_NAME = "metastatement";
|
|
|
13
13
|
export const RULE_SUBPROOF_RULE_NAME = "ruleSubproof";
|
|
14
14
|
export const META_ARGUMENT_RULE_NAME = "metaArgument";
|
|
15
15
|
export const QUALIFIED_STATEMENT_RULE_NAME = "qualifiedStatement";
|
|
16
|
+
export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
|
|
16
17
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
17
18
|
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
|
18
19
|
export const QUALIFIED_METASTATEMENT_RULE_NAME = "qualifiedMetastatement";
|
|
20
|
+
export const METAVARIABLE_DECLARATION_RULE_NAME = "metavariableDeclaration";
|
|
19
21
|
export const UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
|
package/src/supposition.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import termForVariableNodesVerifier from "./verifier/nodes/termForVariable";
|
|
4
4
|
|
|
5
5
|
import { nodeAsString } from "./utilities/string";
|
|
6
6
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
@@ -43,7 +43,7 @@ export default class Supposition {
|
|
|
43
43
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
44
44
|
localContextA = localContext, ///
|
|
45
45
|
localContextB = statementLocalContext, ///
|
|
46
|
-
nonTerminalNodeVerified =
|
|
46
|
+
nonTerminalNodeVerified = termForVariableNodesVerifier.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 = termForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
68
68
|
const verifiedAhead = true;
|
|
69
69
|
|
|
70
70
|
return verifiedAhead;
|
package/src/type.js
CHANGED
|
@@ -58,29 +58,29 @@ export default class Type {
|
|
|
58
58
|
return superTypeOf;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
isComparableTo(type) {
|
|
62
62
|
const equalTo = this.isEqualTo(type),
|
|
63
63
|
subTypeOf = this.isSubTypeOf(type),
|
|
64
|
-
|
|
64
|
+
superTypeOf = this.isSuperTypeOf(type),
|
|
65
|
+
comparableTo = equalTo || subTypeOf || superTypeOf;
|
|
65
66
|
|
|
66
|
-
return
|
|
67
|
+
return comparableTo;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
isEqualToOrSubTypeOf(type) {
|
|
70
71
|
const equalTo = this.isEqualTo(type),
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
subTypeOf = this.isSubTypeOf(type),
|
|
73
|
+
equalToOrSubTypeOf = equalTo || subTypeOf;
|
|
73
74
|
|
|
74
|
-
return
|
|
75
|
+
return equalToOrSubTypeOf;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
isEqualToOrSuperTypeOf(type) {
|
|
78
79
|
const equalTo = this.isEqualTo(type),
|
|
79
|
-
subTypeOf = this.isSubTypeOf(type),
|
|
80
80
|
superTypeOf = this.isSuperTypeOf(type),
|
|
81
|
-
|
|
81
|
+
equalToOrSuperTypeOf = equalTo || superTypeOf;
|
|
82
82
|
|
|
83
|
-
return
|
|
83
|
+
return equalToOrSuperTypeOf;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
match(type) {
|
|
@@ -101,7 +101,7 @@ export default class Type {
|
|
|
101
101
|
return typeNameMatches;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
asString(tokens, noSuperType) {
|
|
104
|
+
asString(tokens, noSuperType = false) {
|
|
105
105
|
let string;
|
|
106
106
|
|
|
107
107
|
if (noSuperType) {
|
|
@@ -135,22 +135,6 @@ export default class Type {
|
|
|
135
135
|
return type;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
static fromJSONAndFileContext(json, fileContext) {
|
|
139
|
-
let type;
|
|
140
|
-
|
|
141
|
-
let { superType } = json;
|
|
142
|
-
|
|
143
|
-
const superTypeJSON = superType; ///
|
|
144
|
-
|
|
145
|
-
superType = superTypeFromSuperTypeJSONAndFileContext(superTypeJSON, fileContext);
|
|
146
|
-
|
|
147
|
-
const { name } = json;
|
|
148
|
-
|
|
149
|
-
type = new Type(name, superType);
|
|
150
|
-
|
|
151
|
-
return type;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
138
|
static fromTypeNameAndSuperType(typeName, superType) {
|
|
155
139
|
const name = typeName, ///
|
|
156
140
|
type = new Type(name, superType);
|
|
@@ -182,19 +166,23 @@ class ObjectType extends Type {
|
|
|
182
166
|
|
|
183
167
|
export const objectType = ObjectType.fromNothing();
|
|
184
168
|
|
|
185
|
-
function
|
|
186
|
-
let
|
|
169
|
+
export function typeFromJSONAndFileContext(json, fileContext) {
|
|
170
|
+
let type;
|
|
171
|
+
|
|
172
|
+
const { name } = json,
|
|
173
|
+
typeName = name; ///
|
|
187
174
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
type = fileContext.findTypeByTypeName(typeName);
|
|
175
|
+
type = fileContext.findTypeByTypeName(typeName);
|
|
176
|
+
|
|
177
|
+
if (type === null) {
|
|
178
|
+
let { superType } = json;
|
|
193
179
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
180
|
+
const superJSON = superType; ///
|
|
181
|
+
|
|
182
|
+
superType = typeFromJSONAndFileContext(superJSON, fileContext);
|
|
183
|
+
|
|
184
|
+
type = new Type(name, superType);
|
|
197
185
|
}
|
|
198
186
|
|
|
199
|
-
return
|
|
187
|
+
return type;
|
|
200
188
|
}
|
|
@@ -2,9 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
import { compress } from "../utilities/array";
|
|
4
4
|
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export function areTermNodesEqual(leftTermNode, rightTermNode, collections) {
|
|
6
|
+
let termNodesEqual;
|
|
7
|
+
|
|
8
|
+
const leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode);
|
|
9
|
+
|
|
10
|
+
if (leftTermNodeMatchesRightTermNode) {
|
|
11
|
+
termNodesEqual = true;
|
|
12
|
+
} else {
|
|
13
|
+
const termNodes = [
|
|
14
|
+
leftTermNode,
|
|
15
|
+
rightTermNode
|
|
16
|
+
],
|
|
17
|
+
collection = findCollectionByTermNodes(collections, termNodes);
|
|
18
|
+
|
|
19
|
+
termNodesEqual = (collection !== null);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return termNodesEqual;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function mergeCollections(collectionsA, collectionsB, localContext) {
|
|
26
|
+
const typesA = typesFromCollections(collectionsA, localContext),
|
|
27
|
+
typesB = typesFromCollections(collectionsB, localContext),
|
|
8
28
|
types = [
|
|
9
29
|
...typesA,
|
|
10
30
|
...typesB
|
|
@@ -19,8 +39,8 @@ export function mergeCollections(collectionsA, collectionsB) {
|
|
|
19
39
|
const collections = types.map((type) => {
|
|
20
40
|
let collection;
|
|
21
41
|
|
|
22
|
-
const collectionA = findCollectionByType(collectionsA, type),
|
|
23
|
-
collectionB = findCollectionByType(collectionsB, type);
|
|
42
|
+
const collectionA = findCollectionByType(collectionsA, type, localContext),
|
|
43
|
+
collectionB = findCollectionByType(collectionsB, type, localContext);
|
|
24
44
|
|
|
25
45
|
if ((collectionA !== null) && (collectionB !== null)) {
|
|
26
46
|
collection = Collection.fromCollections(collectionA, collectionB);
|
|
@@ -36,9 +56,9 @@ export function mergeCollections(collectionsA, collectionsB) {
|
|
|
36
56
|
return collections;
|
|
37
57
|
}
|
|
38
58
|
|
|
39
|
-
export function findCollectionByType(collections, type) {
|
|
59
|
+
export function findCollectionByType(collections, type, localContext) {
|
|
40
60
|
const collection = collections.find((collection) => {
|
|
41
|
-
const collectionMatchesType = collection.matchType(type);
|
|
61
|
+
const collectionMatchesType = collection.matchType(type, localContext);
|
|
42
62
|
|
|
43
63
|
if (collectionMatchesType) {
|
|
44
64
|
return true;
|
|
@@ -60,9 +80,9 @@ export function findCollectionByTerm(collections, term) {
|
|
|
60
80
|
return collection;
|
|
61
81
|
}
|
|
62
82
|
|
|
63
|
-
|
|
83
|
+
function findCollectionByTermNodes(collections, termNodes) {
|
|
64
84
|
const collection = collections.find((collection) => {
|
|
65
|
-
const collectionMatchesTerms = collection.
|
|
85
|
+
const collectionMatchesTerms = collection.matchTermNodes(termNodes);
|
|
66
86
|
|
|
67
87
|
if (collectionMatchesTerms) {
|
|
68
88
|
return true;
|
|
@@ -72,9 +92,9 @@ export function findCollectionByTerms(collections, terms) {
|
|
|
72
92
|
return collection;
|
|
73
93
|
}
|
|
74
94
|
|
|
75
|
-
function typesFromCollections(collections) {
|
|
95
|
+
function typesFromCollections(collections, localContext) {
|
|
76
96
|
const types = collections.map((collection) => {
|
|
77
|
-
const type = collection.getType();
|
|
97
|
+
const type = collection.getType(localContext);
|
|
78
98
|
|
|
79
99
|
return type;
|
|
80
100
|
});
|
package/src/utilities/node.js
CHANGED
|
@@ -4,19 +4,14 @@ import { parsersUtilities } from "occam-custom-grammars";
|
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
6
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
VARIABLE_RULE_NAME,
|
|
10
|
-
META_TYPE_RULE_NAME,
|
|
11
|
-
METAVARIABLE_RULE_NAME,
|
|
7
|
+
import { LABEL_RULE_NAME,
|
|
8
|
+
VARIABLE_DECLARATION_RULE_NAME,
|
|
12
9
|
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
13
10
|
CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
14
11
|
UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
15
12
|
import { labelTokensFromLabelString,
|
|
16
|
-
constructorDeclarationTokensFromTermString,
|
|
17
13
|
variableDeclarationTokensFromVariableString,
|
|
18
14
|
unqualifiedStatementTokensFromStatementString,
|
|
19
|
-
metavariableDeclarationTokensFromMetavariableString,
|
|
20
15
|
unqualifiedMetastatementTokensFromMetastatementString } from "../utilities/tokens";
|
|
21
16
|
|
|
22
17
|
const { florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
@@ -25,20 +20,10 @@ const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
|
25
20
|
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
26
21
|
|
|
27
22
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
28
|
-
typeNodeQuery = nodeQuery("/variableDeclaration/type!"),
|
|
29
23
|
variableNodeQuery = nodeQuery("/variableDeclaration/variable!"),
|
|
30
|
-
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType!"),
|
|
31
24
|
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
32
|
-
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable!"),
|
|
33
25
|
metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
|
|
34
26
|
|
|
35
|
-
export function termNodeFromTermString(termString, lexer, parser) {
|
|
36
|
-
const constructorDeclarationTokens = constructorDeclarationTokensFromTermString(termString, parser),
|
|
37
|
-
termNode = termNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser);
|
|
38
|
-
|
|
39
|
-
return termNode;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
27
|
export function labelNodeFromLabelString(labelString, lexer, parser) {
|
|
43
28
|
const labelTokens = labelTokensFromLabelString(labelString, lexer),
|
|
44
29
|
labelNode = labelNodeFromLabelTokens(labelTokens, parser);
|
|
@@ -46,13 +31,6 @@ export function labelNodeFromLabelString(labelString, lexer, parser) {
|
|
|
46
31
|
return labelNode;
|
|
47
32
|
}
|
|
48
33
|
|
|
49
|
-
export function typeNodeFromVariableString(variableString, lexer, parser) {
|
|
50
|
-
const variableDeclarationTokens = variableDeclarationTokensFromVariableString(variableString, lexer),
|
|
51
|
-
typeNode = typeNodeFromVariableVariableDeclarationTokens(variableDeclarationTokens, parser);
|
|
52
|
-
|
|
53
|
-
return typeNode;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
34
|
export function variableNodeFromVariableString(variableString, lexer, parser) {
|
|
57
35
|
const variableTDeclarationTokens = variableDeclarationTokensFromVariableString(variableString, lexer),
|
|
58
36
|
variableNode = variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser);
|
|
@@ -67,20 +45,6 @@ export function statementNodeFromStatementString(statementString, lexer, parser)
|
|
|
67
45
|
return statementNode;
|
|
68
46
|
}
|
|
69
47
|
|
|
70
|
-
export function metaTypeNodeFromMetavariableString(metavariableString, lexer, parser) {
|
|
71
|
-
const metavariableDeclarationTokens = metavariableDeclarationTokensFromMetavariableString(metavariableString, lexer),
|
|
72
|
-
metaTypeNode = metaTypeNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser);
|
|
73
|
-
|
|
74
|
-
return metaTypeNode;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function metavariableNodeFromMetavariableString(metavariableString, lexer, parser) {
|
|
78
|
-
const metavariableDeclarationTokens = metavariableDeclarationTokensFromMetavariableString(metavariableString, lexer),
|
|
79
|
-
metavariableNode = metavariableNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser);
|
|
80
|
-
|
|
81
|
-
return metavariableNode;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
48
|
export function metastatementNodeFromMetastatementString(metastatementString, lexer, parser) {
|
|
85
49
|
const unqualifiedMetastatementTokens = unqualifiedMetastatementTokensFromMetastatementString(metastatementString, lexer),
|
|
86
50
|
metastatementNode = metastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser);
|
|
@@ -102,27 +66,6 @@ export function statementNodeFromUnqualifiedStatementTokens(unqualifiedStatement
|
|
|
102
66
|
return statementNode;
|
|
103
67
|
}
|
|
104
68
|
|
|
105
|
-
export function typeNodeFromVariableVariableDeclarationTokens(variableDeclarationTokens, parser) {
|
|
106
|
-
const typeDeclarationNode = typeDeclarationNodeFromVariableDeclarationTokens(variableDeclarationTokens, parser),
|
|
107
|
-
typeNode = typeNodeQuery(typeDeclarationNode);
|
|
108
|
-
|
|
109
|
-
return typeNode;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function metaTypeNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
113
|
-
const metaTypeDeclarationNode = metaTypeDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser),
|
|
114
|
-
metaTypeNode = metaTypeNodeQuery(metaTypeDeclarationNode);
|
|
115
|
-
|
|
116
|
-
return metaTypeNode;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function metavariableNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
120
|
-
const metavariableDeclarationNode = metavariableDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser),
|
|
121
|
-
metavariableNode = metavariableNodeQuery(metavariableDeclarationNode);
|
|
122
|
-
|
|
123
|
-
return metavariableNode;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
69
|
export function variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
127
70
|
const variableDeclarationNode = variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser),
|
|
128
71
|
variableNode = variableNodeQuery(variableDeclarationNode);
|
|
@@ -144,15 +87,8 @@ export function labelNodeFromLabelTokens(labelTokens, parser) {
|
|
|
144
87
|
return labelNode;
|
|
145
88
|
}
|
|
146
89
|
|
|
147
|
-
export function typeDeclarationNodeFromVariableDeclarationTokens(variableDeclarationTokens, parser) {
|
|
148
|
-
const ruleName = TYPE_RULE_NAME,
|
|
149
|
-
typeDeclarationNode = nodeFromTokensRuleNameAndParser(variableDeclarationTokens, ruleName, parser);
|
|
150
|
-
|
|
151
|
-
return typeDeclarationNode;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
90
|
export function variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
155
|
-
const ruleName =
|
|
91
|
+
const ruleName = VARIABLE_DECLARATION_RULE_NAME,
|
|
156
92
|
variableDeclarationNode = nodeFromTokensRuleNameAndParser(variableTDeclarationTokens, ruleName, parser);
|
|
157
93
|
|
|
158
94
|
return variableDeclarationNode;
|
|
@@ -165,13 +101,6 @@ export function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifi
|
|
|
165
101
|
return unqualifiedStatementNode;
|
|
166
102
|
}
|
|
167
103
|
|
|
168
|
-
export function metaTypeDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
169
|
-
const ruleName = META_TYPE_RULE_NAME,
|
|
170
|
-
metaTypeDeclarationNode = nodeFromTokensRuleNameAndParser(metavariableDeclarationTokens, ruleName, parser);
|
|
171
|
-
|
|
172
|
-
return metaTypeDeclarationNode;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
104
|
export function constructorDeclarationNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser) {
|
|
176
105
|
const ruleName = CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
177
106
|
constructorDeclarationNode = nodeFromTokensRuleNameAndParser(constructorDeclarationTokens, ruleName, parser);
|
|
@@ -179,13 +108,6 @@ export function constructorDeclarationNodeFromConstructorDeclarationTokens(const
|
|
|
179
108
|
return constructorDeclarationNode;
|
|
180
109
|
}
|
|
181
110
|
|
|
182
|
-
export function metavariableDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
183
|
-
const ruleName = METAVARIABLE_RULE_NAME,
|
|
184
|
-
metavariableDeclarationNode = nodeFromTokensRuleNameAndParser(metavariableDeclarationTokens, ruleName, parser);
|
|
185
|
-
|
|
186
|
-
return metavariableDeclarationNode;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
111
|
export function unqualifiedMetastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser) {
|
|
190
112
|
const ruleName = UNQUALIFIED_METASTATEMENT_RULE_NAME,
|
|
191
113
|
unqualifiedMetastatementNode = nodeFromTokensRuleNameAndParser(unqualifiedMetastatementTokens, ruleName, parser);
|
package/src/utilities/tokens.js
CHANGED
|
@@ -40,14 +40,6 @@ export function unqualifiedStatementTokensFromStatementString(statementString, l
|
|
|
40
40
|
return unqualifiedStatementTokens;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export function metavariableDeclarationTokensFromMetavariableString(metavariableString, lexer) {
|
|
44
|
-
const metavariableDeclarationContent = `Metavariable ${metavariableString}
|
|
45
|
-
`,
|
|
46
|
-
metavariableDeclarationTokens = tokensFromContentAndLexer(metavariableDeclarationContent, lexer);
|
|
47
|
-
|
|
48
|
-
return metavariableDeclarationTokens;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
43
|
export function unqualifiedMetastatementTokensFromMetastatementString(metastatementString, lexer) {
|
|
52
44
|
const unqualifiedMetastatementContent = `${metastatementString}
|
|
53
45
|
`,
|
package/src/variable.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import Type from "./type";
|
|
4
|
-
|
|
5
3
|
import { nodeAsString } from "./utilities/string";
|
|
4
|
+
import { typeFromJSONAndFileContext } from "./type";
|
|
6
5
|
import { variableNodeFromVariableString } from "./utilities/node";
|
|
7
6
|
|
|
8
7
|
export default class Variable {
|
|
@@ -86,13 +85,17 @@ export default class Variable {
|
|
|
86
85
|
|
|
87
86
|
json = type; ///
|
|
88
87
|
|
|
89
|
-
type =
|
|
88
|
+
type = typeFromJSONAndFileContext(json, fileContext);
|
|
89
|
+
|
|
90
|
+
const variable = new Variable(node, type);
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
return variable;
|
|
93
|
+
}
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
static fromVariableAndType(variable, type) {
|
|
96
|
+
const node = variable.getNode();
|
|
94
97
|
|
|
95
|
-
|
|
98
|
+
variable = new Variable(node, type); ///
|
|
96
99
|
|
|
97
100
|
return variable;
|
|
98
101
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import NodeVerifier from "../../verifier/node";
|
|
4
4
|
import verifyStatement from "../../verify/statement";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { verifyType, verifyStandaloneTerm } from "./../../verifier/node/termAsConstructor";
|
|
7
7
|
import { TYPE_RULE_NAME, TERM_RULE_NAME, STATEMENT_RULE_NAME } from "../../ruleNames";
|
|
8
8
|
|
|
9
9
|
class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
@@ -14,6 +14,8 @@ class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
|
14
14
|
|
|
15
15
|
switch (ruleName) {
|
|
16
16
|
case TYPE_RULE_NAME: {
|
|
17
|
+
debugger
|
|
18
|
+
|
|
17
19
|
const typeNode = nonTerminalNode, ///
|
|
18
20
|
typeVerified = verifyType(typeNode, fileContext, verifyAhead),
|
|
19
21
|
typeNodeVerified = typeVerified; ///
|
|
@@ -24,6 +26,8 @@ class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
case TERM_RULE_NAME: {
|
|
29
|
+
debugger
|
|
30
|
+
|
|
27
31
|
const termNode = nonTerminalNode, ///
|
|
28
32
|
standaloneTermVerified = verifyStandaloneTerm(termNode, fileContext, verifyAhead),
|
|
29
33
|
termNodeVerified = standaloneTermVerified; ///
|
|
@@ -34,6 +38,8 @@ class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
case STATEMENT_RULE_NAME: {
|
|
41
|
+
debugger
|
|
42
|
+
|
|
37
43
|
const statementNode = nonTerminalNode, ///
|
|
38
44
|
standaloneStatementVerified = verifyStandaloneStatement(statementNode, fileContext, verifyAhead),
|
|
39
45
|
statementNodeVerified = standaloneStatementVerified; ///
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import verifyTerm from "../../verify/term";
|
|
4
4
|
import NodeVerifier from "../../verifier/node";
|
|
5
|
+
import verifyGivenType from "../../verify/givenType";
|
|
5
6
|
|
|
6
|
-
import { nodeQuery
|
|
7
|
+
import { nodeQuery } from "../../utilities/query";
|
|
7
8
|
import { TERM_RULE_NAME, ARGUMENT_RULE_NAME } from "../../ruleNames";
|
|
8
9
|
|
|
9
10
|
const typeNodeQuery = nodeQuery("/argument/type"),
|
|
@@ -71,29 +72,6 @@ export function verifyStandaloneTerm(termNode, fileContext, verifyAhead) {
|
|
|
71
72
|
return standaloneTermVerified;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
export function verifyType(typeNode, fileContext, verifyAhead) {
|
|
75
|
-
let typeVerified = false;
|
|
76
|
-
|
|
77
|
-
const typeString = fileContext.nodeAsString(typeNode);
|
|
78
|
-
|
|
79
|
-
fileContext.trace(`Verifying the '${typeString}' type...`, typeNode);
|
|
80
|
-
|
|
81
|
-
const typeName = typeNameFromTypeNode(typeNode),
|
|
82
|
-
typePresent = fileContext.isTypePresentByTypeName(typeName);
|
|
83
|
-
|
|
84
|
-
if (!typePresent) {
|
|
85
|
-
fileContext.debug(`The type '${typeName}' is not present.`, typeNode);
|
|
86
|
-
} else {
|
|
87
|
-
fileContext.debug(`...verified the '${typeString}' type.`, typeNode);
|
|
88
|
-
|
|
89
|
-
const verifiedAhead = verifyAhead();
|
|
90
|
-
|
|
91
|
-
typeVerified = verifiedAhead; ///
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return typeVerified;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
75
|
function verifyArgument(argumentNode, fileContext, verifyAhead) {
|
|
98
76
|
let argumentVerified;
|
|
99
77
|
|
|
@@ -105,9 +83,10 @@ function verifyArgument(argumentNode, fileContext, verifyAhead) {
|
|
|
105
83
|
termNode = termNodeQuery(argumentNode);
|
|
106
84
|
|
|
107
85
|
if (typeNode !== null) {
|
|
108
|
-
const
|
|
86
|
+
const types = [], ///
|
|
87
|
+
givenTypeVerified = verifyGivenType(typeNode, types, fileContext, verifyAhead);
|
|
109
88
|
|
|
110
|
-
argumentVerified =
|
|
89
|
+
argumentVerified = givenTypeVerified; ///
|
|
111
90
|
}
|
|
112
91
|
|
|
113
92
|
if (termNode !== null) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import NodesVerifier from "../../verifier/nodes";
|
|
4
|
+
|
|
5
|
+
import { TERM_RULE_NAME } from "../../ruleNames";
|
|
6
|
+
import { areTermNodesEqual } from "../../utilities/collection";
|
|
7
|
+
|
|
8
|
+
class EqualityNodesVerifier extends NodesVerifier {
|
|
9
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, collections, localContext, verifyAhead) {
|
|
10
|
+
let nonTerminalNodeVerified = false;
|
|
11
|
+
|
|
12
|
+
const ruleNameA = nonTerminalNodeA.getRuleName(), ///
|
|
13
|
+
ruleNameB = nonTerminalNodeB.getRuleName(); ///
|
|
14
|
+
|
|
15
|
+
if (ruleNameA === ruleNameB) {
|
|
16
|
+
switch (ruleNameA) {
|
|
17
|
+
case TERM_RULE_NAME: {
|
|
18
|
+
const leftTermNode = nonTerminalNodeA, ///
|
|
19
|
+
rightTermNode = nonTerminalNodeB, ///
|
|
20
|
+
termNodesEqual = areTermNodesEqual(leftTermNode, rightTermNode, collections);
|
|
21
|
+
|
|
22
|
+
if (termNodesEqual) {
|
|
23
|
+
const verifiedAhead = verifyAhead();
|
|
24
|
+
|
|
25
|
+
nonTerminalNodeVerified = verifiedAhead; ///
|
|
26
|
+
} else {
|
|
27
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, collections, localContext, verifyAhead);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
default: {
|
|
34
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, collections, localContext, verifyAhead);
|
|
35
|
+
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return nonTerminalNodeVerified;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const equalityNodesVerifier = new EqualityNodesVerifier();
|
|
46
|
+
|
|
47
|
+
export default equalityNodesVerifier;
|
|
@@ -8,7 +8,7 @@ import { METASTATEMENT_RULE_NAME } from "../../ruleNames";
|
|
|
8
8
|
|
|
9
9
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
class MetastatementForMetavariableNodesVerifier extends NodesVerifier {
|
|
12
12
|
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
|
|
13
13
|
let nonTerminalNodeVerified = false;
|
|
14
14
|
|
|
@@ -68,16 +68,12 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
68
68
|
|
|
69
69
|
metavariableNodeVerified = metastatementNodeMatches; ///
|
|
70
70
|
} else {
|
|
71
|
-
const
|
|
71
|
+
const metavariableNode = metavariableNodeA, ///
|
|
72
|
+
metastatementNode = metastatementNodeB, ///
|
|
73
|
+
metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode),
|
|
74
|
+
substitution = metastatementForMetavariableSubstitution; ///
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
const metavariableNode = metavariableNodeA, ///
|
|
75
|
-
metastatementNode = metastatementNodeB, ///
|
|
76
|
-
metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode),
|
|
77
|
-
substitution = metastatementForMetavariableSubstitution; ///
|
|
78
|
-
|
|
79
|
-
substitutions.push(substitution);
|
|
80
|
-
}
|
|
76
|
+
substitutions.push(substitution);
|
|
81
77
|
|
|
82
78
|
metavariableNodeVerified = true;
|
|
83
79
|
}
|
|
@@ -85,3 +81,7 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
85
81
|
return metavariableNodeVerified;
|
|
86
82
|
}
|
|
87
83
|
}
|
|
84
|
+
|
|
85
|
+
const metastatementForMetavariableNodesVerifier = new MetastatementForMetavariableNodesVerifier();
|
|
86
|
+
|
|
87
|
+
export default metastatementForMetavariableNodesVerifier;
|