occam-verify-cli 1.0.126 → 1.0.127

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.
Files changed (66) hide show
  1. package/lib/context/file.js +4 -4
  2. package/lib/context/local.js +4 -4
  3. package/lib/dom/assertion/contained.js +22 -12
  4. package/lib/dom/assertion/defined.js +22 -12
  5. package/lib/dom/assertion/property.js +3 -3
  6. package/lib/dom/assertion/subproof.js +3 -26
  7. package/lib/dom/assertion/type.js +4 -8
  8. package/lib/dom/axiom.js +13 -5
  9. package/lib/dom/combinator.js +2 -10
  10. package/lib/dom/conjecture.js +4 -4
  11. package/lib/dom/constructor/bracketed.js +3 -3
  12. package/lib/dom/constructor.js +17 -21
  13. package/lib/dom/declaration.js +14 -8
  14. package/lib/dom/derivation.js +10 -2
  15. package/lib/dom/frame.js +29 -25
  16. package/lib/dom/judgement.js +9 -11
  17. package/lib/dom/lemma.js +4 -4
  18. package/lib/dom/metaLemma.js +4 -4
  19. package/lib/dom/metaType.js +14 -4
  20. package/lib/dom/metatheorem.js +4 -4
  21. package/lib/dom/metavariable.js +39 -7
  22. package/lib/dom/procedureCall.js +9 -5
  23. package/lib/dom/property.js +30 -18
  24. package/lib/dom/propertyRelation.js +212 -0
  25. package/lib/dom/reference.js +8 -8
  26. package/lib/dom/statement.js +40 -16
  27. package/lib/dom/term.js +52 -14
  28. package/lib/dom/theorem.js +4 -4
  29. package/lib/dom/type.js +33 -29
  30. package/lib/dom/variable.js +19 -8
  31. package/lib/index.js +3 -3
  32. package/lib/verifier/topLevel.js +6 -6
  33. package/package.json +1 -1
  34. package/src/context/file.js +4 -3
  35. package/src/context/local.js +4 -3
  36. package/src/dom/assertion/contained.js +23 -11
  37. package/src/dom/assertion/defined.js +23 -11
  38. package/src/dom/assertion/property.js +3 -7
  39. package/src/dom/assertion/subproof.js +3 -44
  40. package/src/dom/assertion/type.js +6 -17
  41. package/src/dom/axiom.js +3 -3
  42. package/src/dom/combinator.js +1 -8
  43. package/src/dom/conjecture.js +1 -1
  44. package/src/dom/constructor/bracketed.js +3 -4
  45. package/src/dom/constructor.js +17 -17
  46. package/src/dom/declaration.js +20 -14
  47. package/src/dom/derivation.js +12 -3
  48. package/src/dom/frame.js +33 -36
  49. package/src/dom/judgement.js +7 -22
  50. package/src/dom/lemma.js +1 -1
  51. package/src/dom/metaLemma.js +1 -1
  52. package/src/dom/metaType.js +16 -6
  53. package/src/dom/metatheorem.js +1 -1
  54. package/src/dom/metavariable.js +35 -15
  55. package/src/dom/procedureCall.js +15 -13
  56. package/src/dom/property.js +49 -32
  57. package/src/dom/{relation/property.js → propertyRelation.js} +9 -10
  58. package/src/dom/reference.js +6 -6
  59. package/src/dom/statement.js +50 -15
  60. package/src/dom/term.js +69 -24
  61. package/src/dom/theorem.js +1 -1
  62. package/src/dom/type.js +48 -51
  63. package/src/dom/variable.js +33 -35
  64. package/src/index.js +1 -1
  65. package/src/verifier/topLevel.js +10 -5
  66. package/lib/dom/relation/property.js +0 -212
@@ -6,7 +6,7 @@ import dom from "../dom";
6
6
 
7
7
  import { domAssigned } from "../dom";
8
8
  import { nodeQuery, nodesQuery } from "../utilities/query";
9
- import {parametersFromJSON, parametersToParametersJSON, referenceFromJSON} from "../utilities/json";
9
+ import { referenceFromJSON, parametersFromJSON, parametersToParametersJSON } from "../utilities/json";
10
10
 
11
11
  const parameterNodesQuery = nodesQuery("/procedureCall/parameter"),
12
12
  premiseProcedureCallNodeQuery = nodeQuery("/premise/procedureCall"),
@@ -129,13 +129,9 @@ export default domAssigned(class ProcedureCall {
129
129
  const premiseProcedureCallNode = premiseProcedureCallNodeQuery(premiseNode);
130
130
 
131
131
  if (premiseProcedureCallNode !== null) {
132
- const { Reference } = dom,
133
- procedureCallNode = premiseProcedureCallNode, ///
134
- parameters = parametersFromProcedureCallNode(procedureCallNode, context),
135
- reference = Reference.fromProcedureCallNode(procedureCallNode, context),
136
- string = stringFromReferenceAndParameters(reference, parameters);
132
+ const procedureCallNode = premiseProcedureCallNode; ///
137
133
 
138
- procedureCall = new ProcedureCall(string, reference, parameters);
134
+ procedureCall = procedureCallFromProcedureCallNode(procedureCallNode, context);
139
135
  }
140
136
 
141
137
  return procedureCall;
@@ -147,19 +143,25 @@ export default domAssigned(class ProcedureCall {
147
143
  const suppositionProcedureCallNode = suppositionProcedureCallNodeQuery(suppositionNode);
148
144
 
149
145
  if (suppositionProcedureCallNode !== null) {
150
- const { Reference } = dom,
151
- procedureCallNode = suppositionProcedureCallNode, ///
152
- parameters = parametersFromProcedureCallNode(procedureCallNode, context),
153
- reference = Reference.fromProcedureCallNode(procedureCallNode, context),
154
- string = stringFromReferenceAndParameters(reference, parameters);
146
+ const procedureCallNode = suppositionProcedureCallNode; ///
155
147
 
156
- procedureCall = new ProcedureCall(string, reference, parameters);
148
+ procedureCall = procedureCallFromProcedureCallNode(procedureCallNode, context);
157
149
  }
158
150
 
159
151
  return procedureCall;
160
152
  }
161
153
  });
162
154
 
155
+ function procedureCallFromProcedureCallNode(procedureCallNode, context) {
156
+ const { Reference, ProcedureCall } = dom,
157
+ parameters = parametersFromProcedureCallNode(procedureCallNode, context),
158
+ reference = Reference.fromProcedureCallNode(procedureCallNode, context),
159
+ string = stringFromReferenceAndParameters(reference, parameters),
160
+ procedureCall = new ProcedureCall(string, reference, parameters);
161
+
162
+ return procedureCall;
163
+ }
164
+
163
165
  function parametersFromProcedureCallNode(procedureCallNode, context) {
164
166
  const { Parameter } = dom,
165
167
  parameterNodes = parameterNodesQuery(procedureCallNode),
@@ -11,8 +11,9 @@ import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
11
11
 
12
12
  const { match } = arrayUtilities;
13
13
 
14
- const propertyNodeQuery = nodeQuery("/propertyDeclaration/property"),
15
- nameTerminalNodesQuery = nodesQuery("/property/@name");
14
+ const nameTerminalNodesQuery = nodesQuery("/property/@name"),
15
+ propertyRelationPropertyNodeQuery = nodeQuery("/propertyRelation/property"),
16
+ propertyDeclarationPropertyNodeQuery = nodeQuery("/propertyDeclaration/property");
16
17
 
17
18
  export default domAssigned(class Property {
18
19
  constructor(string, names, type) {
@@ -71,40 +72,57 @@ export default domAssigned(class Property {
71
72
  }
72
73
 
73
74
  static fromPropertyNode(propertyNode, fileContext) {
74
- const node = propertyNode, ///
75
- names = namesFromPropertyNode(propertyNode),
76
- type = null,
77
- string = fileContext.nodeAsString(node),
78
- property = new Property(string, names, type);
75
+ const property = propertyFromPropertyNode(propertyNode, fileContext)
76
+
77
+ return property;
78
+ }
79
+
80
+ static fromPropertyRelationNode(propertyRelationNode, fileContext) {
81
+ const propertyRelationPropertyNode = propertyRelationPropertyNodeQuery(propertyRelationNode),
82
+ propertyNode = propertyRelationPropertyNode, ///
83
+ property = propertyFromPropertyNode(propertyNode, fileContext);
79
84
 
80
85
  return property;
81
86
  }
82
87
 
83
88
  static fromPropertyDeclarationNode(propertyDeclarationNode, fileContext) {
84
89
  const { Type } = dom,
85
- propertyNode = propertyNodeQuery(propertyDeclarationNode),
86
- node = propertyDeclarationNode, ///
87
- names = namesFromPropertyNode(propertyNode),
88
90
  type = Type.fromPropertyDeclarationNode(propertyDeclarationNode),
89
- string = fileContext.nodeAsString(node),
90
- property = new Property(string, names, type);
91
+ propertyDeclarationPropertyNode = propertyDeclarationPropertyNodeQuery(propertyDeclarationNode),
92
+ propertyNode = propertyDeclarationPropertyNode, ///
93
+ property = propertyFromPropertyNode(propertyNode, fileContext);
94
+
95
+ property.setType(type);
91
96
 
92
97
  return property;
93
98
  }
94
99
  });
95
100
 
96
- function namesStringFromNames(names) {
97
- const namesString = names.reduce((namesString, name) => {
98
- const nameString = name; ///
101
+ function propertyFromPropertyNode(propertyNode, fileContext) {
102
+ const { Property } = dom,
103
+ node = propertyNode, ///
104
+ names = namesFromPropertyNode(propertyNode),
105
+ type = null,
106
+ string = fileContext.nodeAsString(node),
107
+ property = new Property(string, names, type);
99
108
 
100
- namesString = (namesString === null) ?
101
- nameString : ///
102
- `${namesString} ${nameString}`;
109
+ return property;
110
+ }
103
111
 
104
- return namesString;
105
- }, null);
112
+ function stringFromNamesAndType(names, type) {
113
+ let string;
106
114
 
107
- return namesString;
115
+ const namesString = namesStringFromNames(names);
116
+
117
+ if (type === objectType) {
118
+ string = namesString; ///
119
+ } else {
120
+ const typeName = type.getName();
121
+
122
+ string = `${namesString}:${typeName}`;
123
+ }
124
+
125
+ return string;
108
126
  }
109
127
 
110
128
  function namesFromPropertyNode(propertyNode, fileContext) {
@@ -119,18 +137,17 @@ function namesFromPropertyNode(propertyNode, fileContext) {
119
137
  return names;
120
138
  }
121
139
 
122
- function stringFromNamesAndType(names, type) {
123
- let string;
124
-
125
- const namesString = namesStringFromNames(names);
140
+ function namesStringFromNames(names) {
141
+ const namesString = names.reduce((namesString, name) => {
142
+ const nameString = name; ///
126
143
 
127
- if (type === objectType) {
128
- string = namesString; ///
129
- } else {
130
- const typeName = type.getName();
144
+ namesString = (namesString === null) ?
145
+ nameString : ///
146
+ `${namesString} ${nameString}`;
131
147
 
132
- string = `${namesString}:${typeName}`;
133
- }
148
+ return namesString;
149
+ }, null);
134
150
 
135
- return string;
151
+ return namesString;
136
152
  }
153
+
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
 
3
- import dom from "../../dom";
3
+ import dom from "../dom";
4
4
 
5
- import { nodeQuery } from "../../utilities/query";
6
- import { domAssigned } from "../../dom";
5
+ import { nodeQuery } from "../utilities/query";
6
+ import { domAssigned } from "../dom";
7
7
 
8
- const termNodeQuery = nodeQuery("/propertyRelation/term"),
9
- propertyNodeQuery = nodeQuery("/propertyRelation/property");
8
+ const propertyAssertionPropertyRelationNodeQuery = nodeQuery("/propertyAssertion/propertyRelation");
10
9
 
11
10
  export default domAssigned(class PropertyRelation {
12
11
  constructor(string, node, tokens, property, term) {
@@ -130,15 +129,15 @@ export default domAssigned(class PropertyRelation {
130
129
 
131
130
  static name = "PropertyRelation";
132
131
 
133
- static fromPropertyRelationNode(propertyRelationNode, context) {
132
+ static fromPropertyAssertionNode(propertyAssertionNode, context) {
134
133
  const { Term, Property } = dom,
134
+ propertyAssertionPropertyRelationNode = propertyAssertionPropertyRelationNodeQuery(propertyAssertionNode),
135
+ propertyRelationNode = propertyAssertionPropertyRelationNode, ///
135
136
  node = propertyRelationNode, ///
136
137
  string = context.nodeAsString(node),
137
138
  tokens = context.nodeAsTokens(node),
138
- propertyNode = propertyNodeQuery(propertyRelationNode),
139
- termNode = termNodeQuery(propertyRelationNode),
140
- property = Property.fromPropertyNode(propertyNode, context),
141
- term = Term.fromTermNode(termNode, context),
139
+ property = Property.fromPropertyRelationNode(propertyRelationNode, context),
140
+ term = Term.fromPropertyRelationNode(propertyRelationNode, context),
142
141
  propertyRelation = new PropertyRelation(string, node, tokens, property, term);
143
142
 
144
143
  return propertyRelation;
@@ -180,12 +180,6 @@ export default domAssigned(class Reference {
180
180
  return reference;
181
181
  }
182
182
 
183
- static fromReferenceNode(referenceNode, fileContext) {
184
- const reference = referenceFromReferenceNode(referenceNode, fileContext);
185
-
186
- return reference;
187
- }
188
-
189
183
  static fromStepNode(stepNode, fileContext) {
190
184
  let reference = null;
191
185
 
@@ -200,6 +194,12 @@ export default domAssigned(class Reference {
200
194
  return reference;
201
195
  }
202
196
 
197
+ static fromReferenceNode(referenceNode, fileContext) {
198
+ const reference = referenceFromReferenceNode(referenceNode, fileContext);
199
+
200
+ return reference;
201
+ }
202
+
203
203
  static fromDeclarationNode(declarationNode, fileContext) {
204
204
  const declarationMetavariableNode = declarationMetavariableNodeQuery(declarationNode),
205
205
  metavariableNode = declarationMetavariableNode, ///
@@ -11,6 +11,7 @@ import { domAssigned } from "../dom";
11
11
  import { unifyStatement } from "../utilities/unification";
12
12
  import { nodeQuery, nodesQuery } from "../utilities/query";
13
13
  import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
14
+ import { stripBracketsFromStatementNode } from "../utilities/brackets";
14
15
  import { definedAssertionFromStatement, containedAssertionFromStatement, subproofAssertionFromStatement } from "../utilities/context";
15
16
 
16
17
  const { match, backwardsSome } = arrayUtilities;
@@ -22,7 +23,9 @@ const stepStatementNodeQuery = nodeQuery("/step/statement"),
22
23
  deductionStatementNodeQuery = nodeQuery("/deduction/statement"),
23
24
  conclusionStatementNodeQuery = nodeQuery("/conclusion/statement"),
24
25
  suppositionStatementNodeQuery = nodeQuery("/supposition/statement"),
25
- containedAssertionStatementNodeQuery = nodeQuery("/containedAssertion/statement");
26
+ declarationStatementNodeQuery = nodeQuery("/declaration/statement"),
27
+ containedAssertionStatementNodeQuery = nodeQuery("/containedAssertion/statement"),
28
+ combinatorDeclarationStatementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
26
29
 
27
30
  export default domAssigned(class Statement {
28
31
  constructor(string, node, tokens) {
@@ -271,31 +274,31 @@ export default domAssigned(class Statement {
271
274
  return statement;
272
275
  }
273
276
 
274
- static fromPremiseNode(premiseNode, fileContext) {
277
+ static fromStepNode(stepNode, fileContext) {
275
278
  let statement = null;
276
279
 
277
- const premiseStatementNode = premiseStatementNodeQuery(premiseNode);
280
+ const stepStatementNode = stepStatementNodeQuery(stepNode);
278
281
 
279
- if (premiseStatementNode !== null) {
280
- const statementNode = premiseStatementNode, ///
281
- localContext = LocalContext.fromFileContext(fileContext),
282
- context = localContext; ///
282
+ if (stepStatementNode !== null) {
283
+ const statementNode = stepStatementNode; ///
283
284
 
284
- statement = statementFromStatementNode(statementNode, context);
285
+ statement = statementFromStatementNode(statementNode, fileContext);
285
286
  }
286
287
 
287
288
  return statement;
288
289
  }
289
290
 
290
- static fromStepNode(stepNode, fileContext) {
291
+ static fromPremiseNode(premiseNode, fileContext) {
291
292
  let statement = null;
292
293
 
293
- const stepStatementNode = stepStatementNodeQuery(stepNode);
294
+ const premiseStatementNode = premiseStatementNodeQuery(premiseNode);
294
295
 
295
- if (stepStatementNode !== null) {
296
- const statementNode = stepStatementNode; ///
296
+ if (premiseStatementNode !== null) {
297
+ const statementNode = premiseStatementNode, ///
298
+ localContext = LocalContext.fromFileContext(fileContext),
299
+ context = localContext; ///
297
300
 
298
- statement = statementFromStatementNode(statementNode, fileContext);
301
+ statement = statementFromStatementNode(statementNode, context);
299
302
  }
300
303
 
301
304
  return statement;
@@ -355,10 +358,26 @@ export default domAssigned(class Statement {
355
358
  return statement;
356
359
  }
357
360
 
358
- static fromContainedAssertionNode(suppositionNode, fileContext) {
361
+ static fromDeclarationNode(declarationNode, fileContext) {
362
+ let statementNode;
363
+
364
+ const declarationStatementNode = declarationStatementNodeQuery(declarationNode);
365
+
366
+ statementNode = declarationStatementNode; ///
367
+
368
+ statementNode = stripBracketsFromStatementNode(statementNode); ///
369
+
370
+ const localContext = LocalContext.fromFileContext(fileContext),
371
+ context = localContext, ///
372
+ statement = statementFromStatementNode(statementNode, context);
373
+
374
+ return statement;
375
+ }
376
+
377
+ static fromContainedAssertionNode(containedAssertionNode, fileContext) {
359
378
  let statement = null;
360
379
 
361
- const containedAssertionStatementNode = containedAssertionStatementNodeQuery(suppositionNode);
380
+ const containedAssertionStatementNode = containedAssertionStatementNodeQuery(containedAssertionNode);
362
381
 
363
382
  if (containedAssertionStatementNode !== null) {
364
383
  const statementNode = containedAssertionStatementNode, ///
@@ -370,6 +389,22 @@ export default domAssigned(class Statement {
370
389
 
371
390
  return statement;
372
391
  }
392
+
393
+ static fromCombinatorDeclarationNode(combinatorDeclarationNode, fileContext) {
394
+ let statement = null;
395
+
396
+ const combinatorDeclarationStatementNode = combinatorDeclarationStatementNodeQuery(combinatorDeclarationNode);
397
+
398
+ if (combinatorDeclarationStatementNode !== null) {
399
+ const statementNode = combinatorDeclarationStatementNode, ///
400
+ localContext = LocalContext.fromFileContext(fileContext),
401
+ context = localContext; ///
402
+
403
+ statement = statementFromStatementNode(statementNode, context);
404
+ }
405
+
406
+ return statement;
407
+ }
373
408
  });
374
409
 
375
410
  function statementFromStatementNode(statementNode, context) {
package/src/dom/term.js CHANGED
@@ -15,8 +15,12 @@ const { filter, compress } = arrayUtilities;
15
15
 
16
16
  const variableNodesQuery = nodesQuery("//variable"),
17
17
  termVariableNodeQuery = nodeQuery("/term/variable!"),
18
+ typeAssertionTermNodeQuery = nodeQuery("/typeAssertion/term"),
18
19
  definedAssertionTermNodeQuery = nodeQuery("/definedAssertion/term"),
19
- containedAssertionTermNodeQuery = nodeQuery("/containedAssertion/term");
20
+ propertyRelationTermNodeQuery = nodeQuery("/propertyRelation/term"),
21
+ propertyAssertionTermNodeQuery = nodeQuery("/propertyAssertion/term"),
22
+ containedAssertionTermNodeQuery = nodeQuery("/containedAssertion/term"),
23
+ constructorDeclarationTermNodeQuery = nodeQuery("/constructorDeclaration/term");
20
24
 
21
25
  export default domAssigned(class Term {
22
26
  constructor(string, node, type) {
@@ -82,6 +86,13 @@ export default domAssigned(class Term {
82
86
  return equalTo;
83
87
  }
84
88
 
89
+ isSimple() {
90
+ const termVariableNode = termVariableNodeQuery(this.node),
91
+ simple = (termVariableNode !== null);
92
+
93
+ return simple;
94
+ }
95
+
85
96
  isGrounded(definedVariables, context) {
86
97
  const variables = this.getVariables(context);
87
98
 
@@ -199,11 +210,7 @@ export default domAssigned(class Term {
199
210
  let term = null;
200
211
 
201
212
  if (termNode !== null) {
202
- const node = termNode, ///
203
- string = context.nodeAsString(node),
204
- type = null;
205
-
206
- term = new Term(string, node, type);
213
+ term = termFromTermNode(termNode, context);
207
214
  }
208
215
 
209
216
  return term;
@@ -217,45 +224,83 @@ export default domAssigned(class Term {
217
224
  return term;
218
225
  }
219
226
 
227
+ static fromTypeAssertionNode(typeAssertionNode, context) {
228
+ let term = null;
229
+
230
+ const typeAssertionTermNode = typeAssertionTermNodeQuery(typeAssertionNode);
231
+
232
+ if (typeAssertionTermNode !== null) {
233
+ const termNode = typeAssertionTermNode; ///
234
+
235
+ term = termFromTermNode(termNode, context);
236
+ }
237
+
238
+ return term;
239
+ }
240
+
220
241
  static fromDefinedAssertionNode(definedAssertionNode, context) {
221
242
  let term = null;
222
243
 
223
244
  const definedAssertionTermNode = definedAssertionTermNodeQuery(definedAssertionNode);
224
245
 
225
246
  if (definedAssertionTermNode !== null) {
226
- const termNode = definedAssertionTermNode, ///
227
- termVariableNode = termVariableNodeQuery(termNode);
228
-
229
- if (termVariableNode !== null) {
230
- const node = termNode, ///
231
- string = context.nodeAsString(node),
232
- type = null;
247
+ const termNode = definedAssertionTermNode; ///
233
248
 
234
- term = new Term(string, node, type);
235
- }
249
+ term = termFromTermNode(termNode, context);
236
250
  }
237
251
 
238
252
  return term;
239
253
  }
240
254
 
255
+ static fromPropertyRelationNode(propertyRelationNode, context) {
256
+ const propertyRelationTermNode = propertyRelationTermNodeQuery(propertyRelationNode),
257
+ termNode = propertyRelationTermNode, ///
258
+ term = termFromTermNode(termNode, context);
259
+
260
+ return term;
261
+ }
262
+
263
+ static fromPropertyAssertionNode(propertyAssertionNode, context) {
264
+ const propertyAssertionTermNode = propertyAssertionTermNodeQuery(propertyAssertionNode),
265
+ termNode = propertyAssertionTermNode,
266
+ term = termFromTermNode(termNode, context);
267
+
268
+ return term;
269
+ }
270
+
241
271
  static fromContainedAssertionNode(containedAssertionNode, context) {
242
272
  let term = null;
243
273
 
244
274
  const containedAssertionTermNode = containedAssertionTermNodeQuery(containedAssertionNode);
245
275
 
246
276
  if (containedAssertionTermNode !== null) {
247
- const termNode = containedAssertionTermNode, ///
248
- termVariableNode = termVariableNodeQuery(termNode);
249
-
250
- if (termVariableNode !== null) {
251
- const node = termNode, ///
252
- string = context.nodeAsString(node),
253
- type = null;
277
+ const termNode = containedAssertionTermNode;
254
278
 
255
- term = new Term(string, node, type);
256
- }
279
+ term = termFromTermNode(termNode, context);
257
280
  }
258
281
 
259
282
  return term;
260
283
  }
284
+
285
+ static fromConstructorDeclarationNode(constructorDeclarationNode, context) {
286
+ const { Type } = dom,
287
+ constructorDeclarationTermNode = constructorDeclarationTermNodeQuery(constructorDeclarationNode),
288
+ termNode = constructorDeclarationTermNode, ///
289
+ term = termFromTermNode(termNode, context),
290
+ type = Type.fromConstructorDeclarationNode(constructorDeclarationNode, context);
291
+
292
+ term.setType(type);
293
+
294
+ return term;
295
+ }
261
296
  });
297
+
298
+ function termFromTermNode(termNode, context) {
299
+ const { Term } = dom,
300
+ node = termNode, ///
301
+ string = context.nodeAsString(node),
302
+ type = null,
303
+ term = new Term(string, node, type);
304
+
305
+ return term;
306
+ }
@@ -30,5 +30,5 @@ export default domAssigned(class Theorem extends TopLevelAssertion {
30
30
 
31
31
  static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Theorem, json, fileContext); }
32
32
 
33
- static fromTheoremNode(metaLemmaNode, fileContext) { return TopLevelAssertion.fromNode(Theorem, metaLemmaNode, fileContext); }
33
+ static fromNode(node, fileContext) { return TopLevelAssertion.fromNode(Theorem, node, fileContext); }
34
34
  });
package/src/dom/type.js CHANGED
@@ -13,12 +13,14 @@ import { superTypesFromJSON, propertiesFromJSON, superTypesToSuperTypesJSON, pro
13
13
 
14
14
  const { push, first } = arrayUtilities;
15
15
 
16
- const typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/type"),
16
+ const typeAssertionTypeNodeQuery = nodeQuery("/typeAssertion/type"),
17
+ typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/type"),
17
18
  propertyDeclarationNodesQuery = nodesQuery("/complexTypeDeclaration/propertyDeclaration"),
18
19
  propertyDeclarationTypeNodeQuery = nodeQuery("/propertyDeclaration/type"),
19
20
  typeDeclarationSuperTypeNodesQuery = nodesQuery("/typeDeclaration|complexTypeDeclaration/types/type"),
20
21
  firstPrimaryKeywordTerminalNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/@primary-keyword[0]"),
21
- variableDeclarationSuperTypeNodeQuery = nodeQuery("/variableDeclaration/type");
22
+ variableDeclarationSuperTypeNodeQuery = nodeQuery("/variableDeclaration/type"),
23
+ constructorDeclarationSuperTypeNodeQuery = nodeQuery("/constructorDeclaration/type");
22
24
 
23
25
  class Type {
24
26
  constructor(string, name, superTypes, properties, provisional) {
@@ -238,26 +240,21 @@ class Type {
238
240
  return type;
239
241
  }
240
242
 
241
- static fromTypeNode(typeNode) {
242
- let type;
243
+ static fromTypeNode(typeNode, fileContext) {
244
+ const type = typeFromTypeNode(typeNode, fileContext);
243
245
 
244
- if (typeNode === null) {
245
- type = objectType;
246
- } else {
247
- const typeName = typeNameFromTypeNode(typeNode),
248
- name = typeName, ///
249
- string = name, ///
250
- superTypes = null,
251
- properties = null,
252
- provisional = null;
253
-
254
- type = new Type(string, name, superTypes, properties, provisional);
255
- }
246
+ return type;
247
+ }
248
+
249
+ static fromTypeAssertionNode(typeAssertionNode, fileContext) {
250
+ const typeAssertionTypeNode = typeAssertionTypeNodeQuery(typeAssertionNode),
251
+ typeNode = typeAssertionTypeNode, ///
252
+ type = typeFromTypeNode(typeNode, fileContext);
256
253
 
257
254
  return type;
258
255
  }
259
256
 
260
- static fromTypeAndProvisional(type, provisional, context) {
257
+ static fromTypeAndProvisional(type, provisional) {
261
258
  const name = type.getName(),
262
259
  superType = type, ///
263
260
  superTypes = [
@@ -283,45 +280,25 @@ class Type {
283
280
  }
284
281
 
285
282
  static fromPropertyDeclarationNode(propertyDeclarationNode, fileContext) {
286
- let type;
287
-
288
- const propertyDeclarationTypeNode = propertyDeclarationTypeNodeQuery(propertyDeclarationNode);
289
-
290
- if (propertyDeclarationTypeNode === null) {
291
- type = objectType;
292
- } else {
293
- const typeNode = propertyDeclarationTypeNode, ///
294
- typeName = typeNameFromTypeNode(typeNode),
295
- name = typeName, ///
296
- string = name, ///
297
- superTypes = null,
298
- properties = null,
299
- provisional = null;
300
-
301
- type = new Type(string, name, superTypes, properties, provisional);
302
- }
283
+ const propertyDeclarationTypeNode = propertyDeclarationTypeNodeQuery(propertyDeclarationNode),
284
+ typeNode = propertyDeclarationTypeNode, ///
285
+ type = typeFromTypeNode(typeNode, fileContext);
303
286
 
304
287
  return type;
305
288
  }
306
289
 
307
290
  static fromVariableDeclarationNode(variableDeclarationNode, fileContext) {
308
- let type;
291
+ const variableDeclarationSuperTypeNode = variableDeclarationSuperTypeNodeQuery(variableDeclarationNode),
292
+ typeNode = variableDeclarationSuperTypeNode, ///
293
+ type = typeFromTypeNode(typeNode, fileContext);
309
294
 
310
- const variableDeclarationSuperTypeNode = variableDeclarationSuperTypeNodeQuery(variableDeclarationNode);
295
+ return type;
296
+ }
311
297
 
312
- if (variableDeclarationSuperTypeNode === null) {
313
- type = objectType;
314
- } else {
315
- const typeNode = variableDeclarationSuperTypeNode, ///
316
- typeName = typeNameFromTypeNode(typeNode),
317
- name = typeName, ///
318
- string = name, ///
319
- superTypes = null,
320
- properties = null,
321
- provisional = null;
322
-
323
- type = new Type(string, name, superTypes, properties, provisional);
324
- }
298
+ static fromConstructorDeclarationNode(constructorDeclarationNode, fileContext) {
299
+ const constructorDeclarationSuperTypeNode = constructorDeclarationSuperTypeNodeQuery(constructorDeclarationNode),
300
+ typeNode = constructorDeclarationSuperTypeNode, ///
301
+ type = typeFromTypeNode(typeNode, fileContext);
325
302
 
326
303
  return type;
327
304
  }
@@ -340,6 +317,26 @@ class Type {
340
317
 
341
318
  export default domAssigned(Type);
342
319
 
320
+ function typeFromTypeNode(typeNode, fileContext) {
321
+ let type;
322
+
323
+ if (typeNode === null) {
324
+ type = objectType;
325
+ } else {
326
+ const { Type } = dom,
327
+ typeName = typeNameFromTypeNode(typeNode),
328
+ name = typeName, ///
329
+ string = name, ///
330
+ superTypes = null,
331
+ properties = null,
332
+ provisional = null;
333
+
334
+ type = new Type(string, name, superTypes, properties, provisional);
335
+ }
336
+
337
+ return type;
338
+ }
339
+
343
340
  function stringFromNameAndSuperTypes(name, superTypes) {
344
341
  let string = name; ///
345
342
 
@@ -381,7 +378,7 @@ function superTypesFromTypeDeclarationNode(typeDeclarationNode, fileContext) {
381
378
  const typeDeclarationSuperTypeNodes = typeDeclarationSuperTypeNodesQuery(typeDeclarationNode),
382
379
  superTypes = typeDeclarationSuperTypeNodes.map((typeDeclarationSuperTypeNode) => {
383
380
  const superTypeNode = typeDeclarationSuperTypeNode, ///
384
- superType = Type.fromTypeNode(superTypeNode);
381
+ superType = Type.fromTypeNode(superTypeNode, fileContext);
385
382
 
386
383
  return superType;
387
384
  }),
@@ -416,7 +413,7 @@ function superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fi
416
413
  const typeDeclarationSuperTypeNodes = typeDeclarationSuperTypeNodesQuery(complexTypeDeclarationNode),
417
414
  superTypes = typeDeclarationSuperTypeNodes.map((typeDeclarationSuperTypeNode) => {
418
415
  const superTypeNode = typeDeclarationSuperTypeNode, ///
419
- superType = Type.fromTypeNode(superTypeNode);
416
+ superType = Type.fromTypeNode(superTypeNode, fileContext);
420
417
 
421
418
  return superType;
422
419
  }),