occam-verify-cli 0.0.1011 → 0.0.1012
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/combinator.js +9 -2
- package/lib/constructor/bracketed.js +52 -8
- package/lib/constructor.js +64 -18
- package/lib/declaration/constructor.js +90 -0
- package/lib/declaration/metavariable.js +15 -8
- package/lib/declaration/type.js +90 -0
- package/lib/error.js +70 -0
- package/lib/rule.js +8 -7
- package/lib/ruleNames.js +5 -1
- package/lib/statement.js +5 -5
- package/lib/term.js +97 -5
- package/lib/type.js +85 -18
- package/lib/utilities/node.js +10 -3
- package/lib/utilities/tokens.js +8 -1
- package/lib/verifier/termAsConstructor.js +3 -4
- package/lib/verifier/topLevel.js +10 -10
- package/package.json +1 -1
- package/src/combinator.js +13 -3
- package/src/constructor/bracketed.js +15 -12
- package/src/constructor.js +73 -17
- package/src/declaration/constructor.js +49 -0
- package/src/declaration/metavariable.js +12 -7
- package/src/declaration/type.js +49 -0
- package/src/error.js +35 -0
- package/src/rule.js +6 -6
- package/src/ruleNames.js +1 -0
- package/src/statement.js +4 -4
- package/src/term.js +119 -4
- package/src/type.js +113 -17
- package/src/utilities/node.js +20 -7
- package/src/utilities/tokens.js +7 -0
- package/src/verifier/termAsConstructor.js +7 -6
- package/src/verifier/topLevel.js +12 -9
- package/lib/tokens/combinatorFrame/bracketed.js +0 -17
- package/lib/verify/declaration/combinator.js +0 -19
- package/lib/verify/declaration/constructor.js +0 -32
- package/lib/verify/declaration/type.js +0 -65
- package/lib/verify/error.js +0 -18
- package/src/tokens/combinatorFrame/bracketed.js +0 -10
- package/src/verify/declaration/combinator.js +0 -6
- package/src/verify/declaration/constructor.js +0 -36
- package/src/verify/declaration/type.js +0 -85
- package/src/verify/error.js +0 -11
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Type from "../type";
|
|
4
|
+
|
|
5
|
+
export default class TypeDeclaration {
|
|
6
|
+
constructor(fileContext, type) {
|
|
7
|
+
this.fileContext = fileContext;
|
|
8
|
+
this.type = type;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getFileContext() {
|
|
12
|
+
return this.fileContext;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getType() {
|
|
16
|
+
return this.type;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getString() { return this.type.getString(); }
|
|
20
|
+
|
|
21
|
+
verify() {
|
|
22
|
+
let verified = false;
|
|
23
|
+
|
|
24
|
+
const typeDeclarationString = this.getString(); ///
|
|
25
|
+
|
|
26
|
+
this.fileContext.trace(`Verifying the '${typeDeclarationString}' type declaration...`);
|
|
27
|
+
|
|
28
|
+
const typeVerified = this.type.verify(this.fileContext);
|
|
29
|
+
|
|
30
|
+
if (typeVerified) {
|
|
31
|
+
this.fileContext.addType(this.type);
|
|
32
|
+
|
|
33
|
+
verified = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (verified) {
|
|
37
|
+
this.fileContext.debug(`...verified the '${typeDeclarationString}' type declaration.`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return verified;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static fromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
44
|
+
const type = Type.fromTypeDeclarationNode(typeDeclarationNode, fileContext),
|
|
45
|
+
typeDeclaration = new TypeDeclaration(fileContext, type);
|
|
46
|
+
|
|
47
|
+
return typeDeclaration;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/error.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default class Error {
|
|
4
|
+
constructor(fileContext, string) {
|
|
5
|
+
this.fileContext = fileContext;
|
|
6
|
+
this.string = string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getFileContext() {
|
|
10
|
+
return this.fileContext;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getString() {
|
|
14
|
+
return this.string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
verify(errorNode) {
|
|
18
|
+
let verified = false;
|
|
19
|
+
|
|
20
|
+
const errorString = this.string; ///
|
|
21
|
+
|
|
22
|
+
this.fileContext.debug(`The '${errorString}' error cannot be verified.`, errorNode);
|
|
23
|
+
|
|
24
|
+
return verified;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static fromErrorNode(errorNode, fileContext) {
|
|
28
|
+
const node = errorNode, ///
|
|
29
|
+
string = fileContext.nodeAsString(node),
|
|
30
|
+
error = new Error(fileContext, string);
|
|
31
|
+
|
|
32
|
+
return error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
package/src/rule.js
CHANGED
|
@@ -90,15 +90,15 @@ export default class Rule {
|
|
|
90
90
|
return proofStepsUnified;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
verify(
|
|
93
|
+
verify() {
|
|
94
94
|
let verified = false;
|
|
95
95
|
|
|
96
96
|
const labelsString = labelsStringFromLabels(this.labels);
|
|
97
97
|
|
|
98
|
-
fileContext.trace(`Verifying the '${labelsString}' rule...`);
|
|
98
|
+
this.fileContext.trace(`Verifying the '${labelsString}' rule...`);
|
|
99
99
|
|
|
100
100
|
const labelsVerified = this.labels.every((label) => {
|
|
101
|
-
const labelVVerified = label.verify(fileContext);
|
|
101
|
+
const labelVVerified = label.verify(this.fileContext);
|
|
102
102
|
|
|
103
103
|
if (labelVVerified) {
|
|
104
104
|
return true;
|
|
@@ -106,7 +106,7 @@ export default class Rule {
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
if (labelsVerified) {
|
|
109
|
-
const localContext = LocalContext.fromFileContext(fileContext),
|
|
109
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
110
110
|
premisesVerified = this.premises.every((premise) => {
|
|
111
111
|
const premiseVerified = premise.verify(localContext);
|
|
112
112
|
|
|
@@ -130,7 +130,7 @@ export default class Rule {
|
|
|
130
130
|
if (proofVerified) {
|
|
131
131
|
const rule = this; ///
|
|
132
132
|
|
|
133
|
-
fileContext.addRule(rule);
|
|
133
|
+
this.fileContext.addRule(rule);
|
|
134
134
|
|
|
135
135
|
verified = true;
|
|
136
136
|
}
|
|
@@ -139,7 +139,7 @@ export default class Rule {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
if (verified) {
|
|
142
|
-
fileContext.debug(`...verified the '${labelsString}' rule.`);
|
|
142
|
+
this.fileContext.debug(`...verified the '${labelsString}' rule.`);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
return verified;
|
package/src/ruleNames.js
CHANGED
package/src/statement.js
CHANGED
|
@@ -75,18 +75,18 @@ class Statement {
|
|
|
75
75
|
return unifiedWithMetaType;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
verifyAsCombinator(
|
|
78
|
+
verifyAsCombinator(fileContext) {
|
|
79
79
|
let verifiedAsCombinator;
|
|
80
80
|
|
|
81
81
|
const statementNode = this.node, ///
|
|
82
82
|
statementString = this.string; ///
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
fileContext.trace(`Verifying the '${statementString}' statement as a combinator...`);
|
|
85
85
|
|
|
86
|
-
verifiedAsCombinator = statementAsCombinatorVerifier.verifyStatement(statementNode,
|
|
86
|
+
verifiedAsCombinator = statementAsCombinatorVerifier.verifyStatement(statementNode, fileContext);
|
|
87
87
|
|
|
88
88
|
if (verifiedAsCombinator) {
|
|
89
|
-
|
|
89
|
+
fileContext.debug(`...verified the '${statementString}' statement as a combinator.`, statementNode);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
return verifiedAsCombinator;
|
package/src/term.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
import termAsConstructorVerifier from "./verifier/termAsConstructor";
|
|
5
|
+
|
|
3
6
|
import { filter } from "./utilities/array";
|
|
4
7
|
import { nodesQuery } from "./utilities/query"
|
|
8
|
+
import { termNodeFromTermString } from "./utilities/node";
|
|
5
9
|
|
|
6
10
|
const variableNodesQuery = nodesQuery("//variable");
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
constructor(node, type) {
|
|
12
|
+
class Term {
|
|
13
|
+
constructor(string, node, type) {
|
|
14
|
+
this.string = string;
|
|
10
15
|
this.node = node;
|
|
11
16
|
this.type = type;
|
|
12
17
|
}
|
|
13
18
|
|
|
19
|
+
getString() {
|
|
20
|
+
return this.string;
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
getNode() {
|
|
15
24
|
return this.node;
|
|
16
25
|
}
|
|
@@ -81,10 +90,116 @@ export default class Term {
|
|
|
81
90
|
return implicitlyGrounded;
|
|
82
91
|
}
|
|
83
92
|
|
|
84
|
-
|
|
93
|
+
verify(localContext, verifyAhead) {
|
|
94
|
+
let verified = false;
|
|
95
|
+
|
|
96
|
+
debugger
|
|
97
|
+
|
|
98
|
+
return verified;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
verifyType(fileContext) {
|
|
102
|
+
let typeVerified;
|
|
103
|
+
|
|
104
|
+
if (this.type === null) {
|
|
105
|
+
typeVerified = true;
|
|
106
|
+
} else {
|
|
107
|
+
const typeName = this.type.getName();
|
|
108
|
+
|
|
109
|
+
fileContext.trace(`Verifying the '${typeName}' type...`);
|
|
110
|
+
|
|
111
|
+
const type = fileContext.findTypeByTypeName(typeName);
|
|
112
|
+
|
|
113
|
+
if (type === null) {
|
|
114
|
+
fileContext.debug(`The '${typeName}' type is missing.`);
|
|
115
|
+
} else {
|
|
116
|
+
this.type = type; ///
|
|
117
|
+
|
|
118
|
+
typeVerified = true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (typeVerified) {
|
|
122
|
+
fileContext.debug(`...verified the '${typeName}' type.`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return typeVerified;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
verifyAsConstructor(fileContext) {
|
|
130
|
+
let verifiedAsConstructor;
|
|
131
|
+
|
|
132
|
+
const termNode = this.node, ///
|
|
133
|
+
termString = this.string; ///
|
|
134
|
+
|
|
135
|
+
fileContext.trace(`Verifying the '${termString}' term as a constructor...`);
|
|
136
|
+
|
|
137
|
+
verifiedAsConstructor = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
|
|
138
|
+
|
|
139
|
+
if (verifiedAsConstructor) {
|
|
140
|
+
fileContext.debug(`...verified the '${termString}' term as a constructor.`, termNode);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return verifiedAsConstructor;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
toJSON() {
|
|
147
|
+
const typeJSON = (this.type !== null) ?
|
|
148
|
+
this.type.toJSON() :
|
|
149
|
+
null,
|
|
150
|
+
string = this.string,
|
|
151
|
+
type = typeJSON, ///
|
|
152
|
+
json = {
|
|
153
|
+
string,
|
|
154
|
+
type
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
return json;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static fromJSON(json, fileContext) {
|
|
161
|
+
const { string } = json,
|
|
162
|
+
termString = string, ///
|
|
163
|
+
lexer = fileContext.getLexer(),
|
|
164
|
+
parser = fileContext.getParser(),
|
|
165
|
+
termNode = termNodeFromTermString(termString, lexer, parser),
|
|
166
|
+
node = termNode;
|
|
167
|
+
|
|
168
|
+
let { type } = json;
|
|
169
|
+
|
|
170
|
+
const typeJSON = type; ///
|
|
171
|
+
|
|
172
|
+
json = typeJSON; ///
|
|
173
|
+
|
|
174
|
+
type = (json !== null) ?
|
|
175
|
+
Type.fromJSON(json, fileContext) :
|
|
176
|
+
null;
|
|
177
|
+
|
|
178
|
+
const term = new Term(string, node, type);
|
|
179
|
+
|
|
180
|
+
return term;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static fromTermNode(termNode, fileContext) {
|
|
184
|
+
const node = termNode, ///
|
|
185
|
+
string = fileContext.nodeAsString(node),
|
|
186
|
+
type = null,
|
|
187
|
+
term = new Term(string, node, type);
|
|
188
|
+
|
|
189
|
+
return term;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static fromTermNodeAndType(termNode, type, fileContext) {
|
|
85
193
|
const node = termNode, ///
|
|
86
|
-
|
|
194
|
+
string = fileContext.nodeAsString(node),
|
|
195
|
+
term = new Term(string, node, type);
|
|
87
196
|
|
|
88
197
|
return term;
|
|
89
198
|
}
|
|
90
199
|
}
|
|
200
|
+
|
|
201
|
+
Object.assign(shim, {
|
|
202
|
+
Term
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
export default Term;
|
package/src/type.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
4
|
|
|
5
|
+
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
import { OBJECT_TYPE_NAME } from "./typeNames";
|
|
5
7
|
import { typeNameFromTypeNode } from "./utilities/name";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
const typeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
|
|
10
|
+
superTypeNodeQuery = nodeQuery("/typeDeclaration/type[1]");
|
|
11
|
+
|
|
12
|
+
class Type {
|
|
13
|
+
constructor(string, name, superType) {
|
|
14
|
+
this.string = string;
|
|
9
15
|
this.name = name;
|
|
10
16
|
this.superType = superType;
|
|
11
17
|
}
|
|
12
18
|
|
|
19
|
+
getString() {
|
|
20
|
+
return this.string;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
getName() {
|
|
14
24
|
return this.name;
|
|
15
25
|
}
|
|
@@ -111,36 +121,122 @@ export default class Type {
|
|
|
111
121
|
return typeNodeMatches;
|
|
112
122
|
}
|
|
113
123
|
|
|
114
|
-
|
|
115
|
-
let
|
|
124
|
+
verify(fileContext) {
|
|
125
|
+
let verified = false;
|
|
116
126
|
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
const typeString = this.string; ///
|
|
128
|
+
|
|
129
|
+
fileContext.trace(`Verifying the '${typeString}' type...`);
|
|
130
|
+
|
|
131
|
+
const typePresent = fileContext.isTypePresentByTypeName(this.name);
|
|
132
|
+
|
|
133
|
+
if (typePresent) {
|
|
134
|
+
fileContext.debug(`The type '${typeString}' is already present.`);
|
|
119
135
|
} else {
|
|
120
|
-
|
|
136
|
+
if (this.superType === null) {
|
|
137
|
+
verified = true;
|
|
138
|
+
} else {
|
|
139
|
+
const name = this.superType.getName(),
|
|
140
|
+
superTypePresent = fileContext.isTypePresentByTypeName(name);
|
|
141
|
+
|
|
142
|
+
if (superTypePresent) {
|
|
143
|
+
verified = true;
|
|
144
|
+
} else {
|
|
145
|
+
const superTypeString = this.superType.getString();
|
|
146
|
+
|
|
147
|
+
fileContext.debug(`The super-type '${superTypeString}' is not present.`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
121
151
|
|
|
122
|
-
|
|
152
|
+
if (verified) {
|
|
153
|
+
fileContext.debug(`...verified the '${typeString}' type.`);
|
|
123
154
|
}
|
|
124
155
|
|
|
125
|
-
return
|
|
156
|
+
return verified;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
toJSON() {
|
|
160
|
+
const superTypeJSON = (this.superType !== null) ?
|
|
161
|
+
this.superType.toJSON() :
|
|
162
|
+
null,
|
|
163
|
+
name = this.name,
|
|
164
|
+
superType = superTypeJSON, ///
|
|
165
|
+
json = {
|
|
166
|
+
name,
|
|
167
|
+
superType
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return json;
|
|
126
171
|
}
|
|
127
172
|
|
|
128
|
-
static
|
|
129
|
-
const name =
|
|
130
|
-
|
|
131
|
-
|
|
173
|
+
static fromJSON(json, fileContext) {
|
|
174
|
+
const { name } = json;
|
|
175
|
+
|
|
176
|
+
let { superType } = json;
|
|
177
|
+
|
|
178
|
+
const superTypeJSON = superType; ///
|
|
179
|
+
|
|
180
|
+
json = superTypeJSON; ///
|
|
181
|
+
|
|
182
|
+
superType = (json !== null) ?
|
|
183
|
+
Type.fromJSON(json, fileContext) :
|
|
184
|
+
null;
|
|
185
|
+
|
|
186
|
+
const typeName = name, ///
|
|
187
|
+
string = stringFromTypeNameAndSuperType(typeName, superType),
|
|
188
|
+
type = new Type(string, name, superType);
|
|
189
|
+
|
|
190
|
+
return type;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static fromTypeNode(typeNode) {
|
|
194
|
+
let type = null;
|
|
195
|
+
|
|
196
|
+
if (typeNode !== null) {
|
|
197
|
+
const typeName = typeNameFromTypeNode(typeNode),
|
|
198
|
+
name = typeName, ///
|
|
199
|
+
string = name, ///
|
|
200
|
+
superType = null;
|
|
201
|
+
|
|
202
|
+
type = new Type(string, name, superType);
|
|
203
|
+
}
|
|
132
204
|
|
|
133
205
|
return type;
|
|
134
206
|
}
|
|
135
207
|
|
|
136
|
-
static
|
|
137
|
-
const
|
|
138
|
-
|
|
208
|
+
static fromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
209
|
+
const typeNode = typeNodeQuery(typeDeclarationNode),
|
|
210
|
+
superTypeNode = superTypeNodeQuery(typeDeclarationNode),
|
|
211
|
+
typeName = typeNameFromTypeNode(typeNode),
|
|
212
|
+
superType = Type.fromTypeNode(superTypeNode),
|
|
213
|
+
string = stringFromTypeNameAndSuperType(typeName, superType),
|
|
214
|
+
name = typeName, ///
|
|
215
|
+
type = new Type(string, name, superType);
|
|
139
216
|
|
|
140
217
|
return type;
|
|
141
218
|
}
|
|
142
219
|
}
|
|
143
220
|
|
|
221
|
+
function stringFromTypeNameAndSuperType(typeName, superType) {
|
|
222
|
+
let string = typeName; ///
|
|
223
|
+
|
|
224
|
+
if (superType !== null) {
|
|
225
|
+
const typeString = string, ///
|
|
226
|
+
superTypeString = superType.getString();
|
|
227
|
+
|
|
228
|
+
string = `${typeString}:${superTypeString}`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
Object.assign(shim, {
|
|
235
|
+
Type
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
export default Type;
|
|
239
|
+
|
|
144
240
|
class ObjectType extends Type {
|
|
145
241
|
static fromNothing() {
|
|
146
242
|
const name = OBJECT_TYPE_NAME,
|
package/src/utilities/node.js
CHANGED
|
@@ -6,21 +6,26 @@ import { nodeQuery } from "../utilities/query";
|
|
|
6
6
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
7
|
import { TERM_RULE_NAME,
|
|
8
8
|
METAVARIABLE_RULE_NAME,
|
|
9
|
-
UNQUALIFIED_STATEMENT_RULE_NAME
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
unqualifiedStatementTokensFromUnqualifiedStatementString
|
|
9
|
+
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
10
|
+
CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
11
|
+
import { metavariableTokensFromMetavariableString,
|
|
12
|
+
unqualifiedStatementTokensFromUnqualifiedStatementString,
|
|
13
|
+
constructorDeclarationTokensFromConstructorDeclarationString } from "../utilities/tokens";
|
|
13
14
|
|
|
14
15
|
const { nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
15
16
|
|
|
16
17
|
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
17
18
|
nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
18
19
|
|
|
19
|
-
const
|
|
20
|
+
const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
|
|
21
|
+
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement");
|
|
20
22
|
|
|
21
23
|
export function termNodeFromTermString(termString, lexer, parser) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
+
const constructorDeclarationString = `Constructor ${termString}
|
|
25
|
+
`,
|
|
26
|
+
constructorDeclarationTokens = constructorDeclarationTokensFromConstructorDeclarationString(constructorDeclarationString, lexer),
|
|
27
|
+
constructorDeclarationNode = constructorDeclarationNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser),
|
|
28
|
+
termNode = termNodeQuery(constructorDeclarationNode, constructorDeclarationNode);
|
|
24
29
|
|
|
25
30
|
return termNode;
|
|
26
31
|
}
|
|
@@ -72,6 +77,14 @@ export function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifi
|
|
|
72
77
|
return unqualifiedStatementNode;
|
|
73
78
|
}
|
|
74
79
|
|
|
80
|
+
export function constructorDeclarationNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser) {
|
|
81
|
+
const tokens = constructorDeclarationTokens, ///
|
|
82
|
+
ruleName = CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
83
|
+
constructorDeclarationNode = nodeFromTokensRuleNameAndParser(tokens, ruleName, parser);
|
|
84
|
+
|
|
85
|
+
return constructorDeclarationNode;
|
|
86
|
+
}
|
|
87
|
+
|
|
75
88
|
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser = nominalParser) {
|
|
76
89
|
const ruleMap = parser.getRuleMap(),
|
|
77
90
|
rule = ruleMap[ruleName],
|
package/src/utilities/tokens.js
CHANGED
|
@@ -30,6 +30,13 @@ export function unqualifiedStatementTokensFromUnqualifiedStatementString(unquali
|
|
|
30
30
|
return unqualifiedStatementTokens;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export function constructorDeclarationTokensFromConstructorDeclarationString(constructorDeclarationString, lexer) {
|
|
34
|
+
const content = constructorDeclarationString, ///
|
|
35
|
+
constructorDeclarationTokens = tokensFromContentAndLexer(content, lexer);
|
|
36
|
+
|
|
37
|
+
return constructorDeclarationTokens;
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
function tokensFromContentAndLexer(content, lexer = nominalLexer) {
|
|
34
41
|
const tokens = lexer.tokenise(content);
|
|
35
42
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Verifier from "../verifier";
|
|
5
|
-
import verifyType from "../verify/type";
|
|
6
5
|
import LocalContext from "../context/local";
|
|
7
6
|
|
|
8
7
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -31,10 +30,10 @@ class TermAsConstructorVerifier extends Verifier {
|
|
|
31
30
|
{
|
|
32
31
|
nodeQuery: termNodeQuery,
|
|
33
32
|
verify: (termNode, fileContext, verifyAhead) => {
|
|
34
|
-
const {
|
|
35
|
-
|
|
33
|
+
const { Term } = shim,
|
|
34
|
+
term = Term.fromTermNode(termNode, fileContext),
|
|
36
35
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
37
|
-
termVerified =
|
|
36
|
+
termVerified = term.verify(localContext, verifyAhead);
|
|
38
37
|
|
|
39
38
|
return termVerified;
|
|
40
39
|
}
|
|
@@ -42,8 +41,10 @@ class TermAsConstructorVerifier extends Verifier {
|
|
|
42
41
|
{
|
|
43
42
|
nodeQuery: typeNodeQuery,
|
|
44
43
|
verify: (typeNode, fileContext, verifyAhead) => {
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
const { Type } = shim,
|
|
45
|
+
type = Type.fromTypeNode(typeNode, fileContext),
|
|
46
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
47
|
+
typeVerified = type.verify(localContext, verifyAhead);
|
|
47
48
|
|
|
48
49
|
return typeVerified;
|
|
49
50
|
}
|
package/src/verifier/topLevel.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Rule from "../rule";
|
|
4
|
+
import Error from "../error";
|
|
5
|
+
import TypeDeclaration from "../declaration/type";
|
|
4
6
|
import CombinatorDeclaration from "../declaration/combinator";
|
|
7
|
+
import ConstructorDeclaration from "../declaration/constructor";
|
|
5
8
|
import MetavariableDeclaration from "../declaration/metavariable";
|
|
6
9
|
|
|
7
10
|
import Verifier from "../verifier";
|
|
8
|
-
import verifyError from "../verify/error";
|
|
9
11
|
import verifyAxiom from "../verify/axiom";
|
|
10
12
|
import verifyLemma from "../verify/lemma";
|
|
11
13
|
import verifyTheorem from "../verify/theorem";
|
|
12
14
|
import verifyMetaLemma from "../verify/metaLemma";
|
|
13
15
|
import verifyConjecture from "../verify/conjecture";
|
|
14
16
|
import verifyMetatheorem from "../verify/metatheorem";
|
|
15
|
-
import verifyTypeDeclaration from "../verify/declaration/type";
|
|
16
17
|
import verifyVariableDeclaration from "../verify/declaration/variable";
|
|
17
|
-
import verifyConstructorDeclaration from "../verify/declaration/constructor";
|
|
18
18
|
|
|
19
19
|
import { nodeQuery } from "../utilities/query";
|
|
20
20
|
|
|
@@ -48,7 +48,8 @@ class TopLevelVerifier extends Verifier {
|
|
|
48
48
|
{
|
|
49
49
|
nodeQuery: errorNodeQuery,
|
|
50
50
|
verify: (errorNode, fileContext) => {
|
|
51
|
-
const
|
|
51
|
+
const error = Error.fromErrorNode(errorNode, fileContext),
|
|
52
|
+
errorVerified = error.verify();
|
|
52
53
|
|
|
53
54
|
return errorVerified;
|
|
54
55
|
}
|
|
@@ -57,7 +58,7 @@ class TopLevelVerifier extends Verifier {
|
|
|
57
58
|
nodeQuery: ruleNodeQuery,
|
|
58
59
|
verify: (ruleNode, fileContext) => {
|
|
59
60
|
const rule = Rule.fromRuleNode(ruleNode, fileContext),
|
|
60
|
-
ruleVerified = rule.verify(
|
|
61
|
+
ruleVerified = rule.verify();
|
|
61
62
|
|
|
62
63
|
return ruleVerified;
|
|
63
64
|
}
|
|
@@ -113,7 +114,8 @@ class TopLevelVerifier extends Verifier {
|
|
|
113
114
|
{
|
|
114
115
|
nodeQuery: typeDeclarationNodeQuery,
|
|
115
116
|
verify: (typeDeclarationNode, fileContext) => {
|
|
116
|
-
const
|
|
117
|
+
const typeDeclaration = TypeDeclaration.fromTypeDeclarationNode(typeDeclarationNode, fileContext),
|
|
118
|
+
typeDeclarationVerified = typeDeclaration.verify();
|
|
117
119
|
|
|
118
120
|
return typeDeclarationVerified;
|
|
119
121
|
}
|
|
@@ -130,7 +132,7 @@ class TopLevelVerifier extends Verifier {
|
|
|
130
132
|
nodeQuery: combinatorDeclarationNodeQuery,
|
|
131
133
|
verify: (combinatorDeclarationNode, fileContext) => {
|
|
132
134
|
const combinatorDeclaration = CombinatorDeclaration.fromCombinatorDeclarationNode(combinatorDeclarationNode, fileContext),
|
|
133
|
-
combinatorDeclarationVerified = combinatorDeclaration.verify(
|
|
135
|
+
combinatorDeclarationVerified = combinatorDeclaration.verify();
|
|
134
136
|
|
|
135
137
|
return combinatorDeclarationVerified;
|
|
136
138
|
}
|
|
@@ -138,7 +140,8 @@ class TopLevelVerifier extends Verifier {
|
|
|
138
140
|
{
|
|
139
141
|
nodeQuery: constructorDeclarationNodeQuery,
|
|
140
142
|
verify: (constructorDeclarationNode, fileContext) => {
|
|
141
|
-
const
|
|
143
|
+
const constructorDeclaration = ConstructorDeclaration.fromConstructorDeclarationNode(constructorDeclarationNode, fileContext),
|
|
144
|
+
constructorDeclarationVerified = constructorDeclaration.verify();
|
|
142
145
|
|
|
143
146
|
return constructorDeclarationVerified;
|
|
144
147
|
}
|
|
@@ -147,7 +150,7 @@ class TopLevelVerifier extends Verifier {
|
|
|
147
150
|
nodeQuery: metavariableDeclarationNodeQuery,
|
|
148
151
|
verify: (metavariableDeclarationNode, fileContext) => {
|
|
149
152
|
const metavariableDeclaration = MetavariableDeclaration.fromMetavariableDeclarationNode(metavariableDeclarationNode, fileContext),
|
|
150
|
-
metavariableDeclarationVerified = metavariableDeclaration.verify(
|
|
153
|
+
metavariableDeclarationVerified = metavariableDeclaration.verify();
|
|
151
154
|
|
|
152
155
|
return metavariableDeclarationVerified;
|
|
153
156
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _metaTypeNames = require("../../metaTypeNames");
|
|
12
|
-
var _tokens = require("../../utilities/tokens");
|
|
13
|
-
var bracketedCombinatorFrameString = "(".concat(_metaTypeNames.FRAME_META_TYPE_NAME, ")");
|
|
14
|
-
var bracketedCombinatorFrameTokens = (0, _tokens.fromTokensFromFrameString)(bracketedCombinatorFrameString);
|
|
15
|
-
var _default = bracketedCombinatorFrameTokens;
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90b2tlbnMvY29tYmluYXRvckZyYW1lL2JyYWNrZXRlZC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuaW1wb3J0IHsgRlJBTUVfTUVUQV9UWVBFX05BTUUgfSBmcm9tIFwiLi4vLi4vbWV0YVR5cGVOYW1lc1wiO1xuaW1wb3J0IHsgZnJvbVRva2Vuc0Zyb21GcmFtZVN0cmluZyB9IGZyb20gXCIuLi8uLi91dGlsaXRpZXMvdG9rZW5zXCI7XG5cbmNvbnN0IGJyYWNrZXRlZENvbWJpbmF0b3JGcmFtZVN0cmluZyA9IGAoJHtGUkFNRV9NRVRBX1RZUEVfTkFNRX0pYDtcblxuY29uc3QgYnJhY2tldGVkQ29tYmluYXRvckZyYW1lVG9rZW5zID0gZnJvbVRva2Vuc0Zyb21GcmFtZVN0cmluZyhicmFja2V0ZWRDb21iaW5hdG9yRnJhbWVTdHJpbmcpXG5cbmV4cG9ydCBkZWZhdWx0IGJyYWNrZXRlZENvbWJpbmF0b3JGcmFtZVRva2VucztcbiJdLCJuYW1lcyI6WyJicmFja2V0ZWRDb21iaW5hdG9yRnJhbWVTdHJpbmciLCJGUkFNRV9NRVRBX1RZUEVfTkFNRSIsImJyYWNrZXRlZENvbWJpbmF0b3JGcmFtZVRva2VucyIsImZyb21Ub2tlbnNGcm9tRnJhbWVTdHJpbmciXSwibWFwcGluZ3MiOiJBQUFBOzs7OytCQVNBOzs7ZUFBQTs7OzZCQVBxQztzQkFDSztBQUUxQyxJQUFNQSxpQ0FBaUMsQUFBQyxJQUF3QixPQUFyQkMsbUNBQW9CLEVBQUM7QUFFaEUsSUFBTUMsaUNBQWlDQyxJQUFBQSxpQ0FBeUIsRUFBQ0g7SUFFakUsV0FBZUUifQ==
|