occam-verify-cli 1.0.650 → 1.0.655

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 (97) hide show
  1. package/lib/action/verify.js +1 -2
  2. package/lib/context/ephemeral.js +42 -1
  3. package/lib/context/file/nominal.js +26 -33
  4. package/lib/element/assertion/contained.js +24 -1
  5. package/lib/element/assertion/defined.js +24 -1
  6. package/lib/element/assertion/property.js +24 -1
  7. package/lib/element/assertion/satisfies.js +24 -1
  8. package/lib/element/assertion/subproof.js +37 -1
  9. package/lib/element/assertion/type.js +27 -1
  10. package/lib/element/assumption.js +2 -7
  11. package/lib/element/combinator.js +16 -3
  12. package/lib/element/conclusion.js +18 -3
  13. package/lib/element/constructor.js +8 -2
  14. package/lib/element/declaration/complexType.js +52 -52
  15. package/lib/element/declaration/constructor.js +38 -38
  16. package/lib/element/declaration/metavariable.js +35 -35
  17. package/lib/element/declaration/simpleType.js +42 -42
  18. package/lib/element/declaration/typePrefix.js +32 -32
  19. package/lib/element/declaration/variable.js +39 -39
  20. package/lib/element/deduction.js +2 -4
  21. package/lib/element/equivalences.js +3 -3
  22. package/lib/element/frame.js +2 -9
  23. package/lib/element/hypothesis.js +18 -24
  24. package/lib/element/label.js +14 -3
  25. package/lib/element/metavariable.js +10 -3
  26. package/lib/element/parameter.js +2 -3
  27. package/lib/element/procedureCall.js +2 -3
  28. package/lib/element/procedureReference.js +2 -3
  29. package/lib/element/proofAssertion/premise.js +54 -49
  30. package/lib/element/proofAssertion/step.js +86 -86
  31. package/lib/element/proofAssertion/supposition.js +39 -49
  32. package/lib/element/property.js +2 -3
  33. package/lib/element/reference.js +2 -3
  34. package/lib/element/rule.js +2 -4
  35. package/lib/element/section.js +14 -14
  36. package/lib/element/signature.js +2 -3
  37. package/lib/element/statement.js +8 -2
  38. package/lib/element/subproof.js +8 -8
  39. package/lib/element/substitution/statement.js +2 -2
  40. package/lib/element/term.js +15 -29
  41. package/lib/element/topLevelAssertion/axiom.js +63 -63
  42. package/lib/element/topLevelMetaAssertion.js +15 -15
  43. package/lib/element/type.js +2 -3
  44. package/lib/element/typePrefix.js +2 -3
  45. package/lib/element/variable.js +2 -2
  46. package/lib/process/instantiate.js +38 -2
  47. package/lib/utilities/equivalence.js +27 -0
  48. package/lib/utilities/json.js +197 -30
  49. package/package.json +4 -4
  50. package/src/action/verify.js +0 -2
  51. package/src/context/ephemeral.js +84 -0
  52. package/src/context/file/nominal.js +30 -44
  53. package/src/element/assertion/contained.js +25 -0
  54. package/src/element/assertion/defined.js +25 -0
  55. package/src/element/assertion/property.js +25 -0
  56. package/src/element/assertion/satisfies.js +25 -0
  57. package/src/element/assertion/subproof.js +46 -0
  58. package/src/element/assertion/type.js +32 -0
  59. package/src/element/assumption.js +1 -12
  60. package/src/element/combinator.js +33 -3
  61. package/src/element/conclusion.js +33 -3
  62. package/src/element/constructor.js +17 -4
  63. package/src/element/declaration/complexType.js +49 -49
  64. package/src/element/declaration/constructor.js +32 -32
  65. package/src/element/declaration/metavariable.js +26 -26
  66. package/src/element/declaration/simpleType.js +34 -34
  67. package/src/element/declaration/typePrefix.js +35 -35
  68. package/src/element/declaration/variable.js +30 -30
  69. package/src/element/deduction.js +1 -6
  70. package/src/element/equivalences.js +1 -1
  71. package/src/element/frame.js +1 -15
  72. package/src/element/hypothesis.js +23 -34
  73. package/src/element/label.js +22 -5
  74. package/src/element/metavariable.js +20 -2
  75. package/src/element/parameter.js +1 -6
  76. package/src/element/procedureCall.js +1 -7
  77. package/src/element/procedureReference.js +1 -6
  78. package/src/element/proofAssertion/premise.js +54 -39
  79. package/src/element/proofAssertion/step.js +62 -62
  80. package/src/element/proofAssertion/supposition.js +27 -44
  81. package/src/element/property.js +1 -6
  82. package/src/element/reference.js +1 -6
  83. package/src/element/rule.js +3 -11
  84. package/src/element/section.js +12 -12
  85. package/src/element/signature.js +1 -7
  86. package/src/element/statement.js +13 -1
  87. package/src/element/subproof.js +6 -6
  88. package/src/element/substitution/statement.js +1 -1
  89. package/src/element/term.js +16 -24
  90. package/src/element/topLevelAssertion/axiom.js +45 -45
  91. package/src/element/topLevelMetaAssertion.js +19 -19
  92. package/src/element/type.js +1 -10
  93. package/src/element/typePrefix.js +1 -6
  94. package/src/element/variable.js +1 -1
  95. package/src/process/instantiate.js +26 -2
  96. package/src/utilities/equivalence.js +26 -0
  97. package/src/utilities/json.js +233 -37
@@ -27,6 +27,55 @@ export default define(class ComplexTypeDeclaration extends Declaration {
27
27
  return complexTypeDeclarationNode;
28
28
  }
29
29
 
30
+ async verify() {
31
+ let verifies = false;
32
+
33
+ const context = this.getContext();
34
+
35
+ await this.break(context);
36
+
37
+ const complexTypeDeclarationString = this.getString(); ///
38
+
39
+ context.trace(`Verifying the '${complexTypeDeclarationString}' complex type declaration...`);
40
+
41
+ if (this.prefixed) {
42
+ const typeString = this.type.getString();
43
+
44
+ context.trace(`The '${typeString}' type is prefixed.`);
45
+ } else {
46
+ const typeVerifies = this.verifyType();
47
+
48
+ if (typeVerifies) {
49
+ const superTypesVerify = this.verifySuperTypes();
50
+
51
+ if (superTypesVerify) {
52
+ const propertiesVerify = this.verifyProperties();
53
+
54
+ if (propertiesVerify) {
55
+ const typePrefix = context.getTypePrefix();
56
+
57
+ if (typePrefix !== null) {
58
+ const typePrefixName = typePrefix.getName(),
59
+ prefixName = typePrefixName; ///
60
+
61
+ this.type.setPrefixName(prefixName);
62
+ }
63
+
64
+ context.addType(this.type);
65
+
66
+ verifies = true;
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ if (verifies) {
73
+ context.debug(`...verified the '${complexTypeDeclarationString}' complex type declaration.`);
74
+ }
75
+
76
+ return verifies;
77
+ }
78
+
30
79
  verifyType() {
31
80
  let typeVerifies = false;
32
81
 
@@ -263,54 +312,5 @@ export default define(class ComplexTypeDeclaration extends Declaration {
263
312
  return propertyNominalTypeNameVerifies;
264
313
  }
265
314
 
266
- async verify() {
267
- let verifies = false;
268
-
269
- const context = this.getContext();
270
-
271
- await this.break(context);
272
-
273
- const complexTypeDeclarationString = this.getString(); ///
274
-
275
- context.trace(`Verifying the '${complexTypeDeclarationString}' complex type declaration...`);
276
-
277
- if (this.prefixed) {
278
- const typeString = this.type.getString();
279
-
280
- context.trace(`The '${typeString}' type is prefixed.`);
281
- } else {
282
- const typeVerifies = this.verifyType();
283
-
284
- if (typeVerifies) {
285
- const superTypesVerify = this.verifySuperTypes();
286
-
287
- if (superTypesVerify) {
288
- const propertiesVerify = this.verifyProperties();
289
-
290
- if (propertiesVerify) {
291
- const typePrefix = context.getTypePrefix();
292
-
293
- if (typePrefix !== null) {
294
- const typePrefixName = typePrefix.getName(),
295
- prefixName = typePrefixName; ///
296
-
297
- this.type.setPrefixName(prefixName);
298
- }
299
-
300
- context.addType(this.type);
301
-
302
- verifies = true;
303
- }
304
- }
305
- }
306
- }
307
-
308
- if (verifies) {
309
- context.debug(`...verified the '${complexTypeDeclarationString}' complex type declaration.`);
310
- }
311
-
312
- return verifies;
313
- }
314
-
315
315
  static name = "ComplexTypeDeclaration";
316
316
  });
@@ -32,6 +32,38 @@ export default define(class ConstructorDeclaration extends Declaration {
32
32
  return constructorDeclarationNode;
33
33
  }
34
34
 
35
+ async verify() {
36
+ let verifies = false;
37
+
38
+ const context = this.getContext();
39
+
40
+ await this.break(context);
41
+
42
+ const constructorDeclarationString = this.getString(); ///
43
+
44
+ context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration...`);
45
+
46
+ const typeVerified = this.verifyType();
47
+
48
+ if (typeVerified) {
49
+ const constructorVerifies = this.verifyConstructor();
50
+
51
+ if (constructorVerifies) {
52
+ this.constructor.setType(this.type);
53
+
54
+ context.addConstructor(this.constructor);
55
+
56
+ verifies = true;
57
+ }
58
+ }
59
+
60
+ if (verifies) {
61
+ context.debug(`...verified the '${constructorDeclarationString}' constructor declaration.`);
62
+ }
63
+
64
+ return verifies;
65
+ }
66
+
35
67
  verifyType() {
36
68
  let typeVerifies = false;
37
69
 
@@ -86,37 +118,5 @@ export default define(class ConstructorDeclaration extends Declaration {
86
118
  return constructorVerifies;
87
119
  }
88
120
 
89
- async verify() {
90
- let verifies = false;
91
-
92
- const context = this.getContext();
93
-
94
- await this.break(context);
95
-
96
- const constructorDeclarationString = this.getString(); ///
97
-
98
- context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration...`);
99
-
100
- const typeVerified = this.verifyType();
101
-
102
- if (typeVerified) {
103
- const constructorVerifies = this.verifyConstructor();
104
-
105
- if (constructorVerifies) {
106
- this.constructor.setType(this.type);
107
-
108
- context.addConstructor(this.constructor);
109
-
110
- verifies = true;
111
- }
112
- }
113
-
114
- if (verifies) {
115
- context.debug(`...verified the '${constructorDeclarationString}' constructor declaration.`);
116
- }
117
-
118
- return verifies;
119
- }
120
-
121
121
  static name = "ConstructorDeclaration";
122
122
  });
@@ -20,6 +20,32 @@ export default define(class MetavariableDeclaration extends Declaration {
20
20
  return this.metavariable;
21
21
  }
22
22
 
23
+ async verify() {
24
+ let verifies;
25
+
26
+ const context = this.getContext();
27
+
28
+ await this.break(context);
29
+
30
+ const metavariableDeclarationString = this.getString(); ///
31
+
32
+ context.trace(`Verifying the '${metavariableDeclarationString}' metavariable declaration...`);
33
+
34
+ const metavariableVerifies = this.verifyMetavariable();
35
+
36
+ if (metavariableVerifies) {
37
+ context.addMetavariable(this.metavariable);
38
+
39
+ verifies = true;
40
+ }
41
+
42
+ if (verifies) {
43
+ context.debug(`...verified the '${metavariableDeclarationString}' metavariable declaration.`);
44
+ }
45
+
46
+ return verifies;
47
+ }
48
+
23
49
  verifyMetavariable() {
24
50
  let metavariableVerifies = false;
25
51
 
@@ -91,31 +117,5 @@ export default define(class MetavariableDeclaration extends Declaration {
91
117
  return metavariableTypeVerified;
92
118
  }
93
119
 
94
- async verify() {
95
- let verifies;
96
-
97
- const context = this.getContext();
98
-
99
- await this.break(context);
100
-
101
- const metavariableDeclarationString = this.getString(); ///
102
-
103
- context.trace(`Verifying the '${metavariableDeclarationString}' metavariable declaration...`);
104
-
105
- const metavariableVerifies = this.verifyMetavariable();
106
-
107
- if (metavariableVerifies) {
108
- context.addMetavariable(this.metavariable);
109
-
110
- verifies = true;
111
- }
112
-
113
- if (verifies) {
114
- context.debug(`...verified the '${metavariableDeclarationString}' metavariable declaration.`);
115
- }
116
-
117
- return verifies;
118
- }
119
-
120
120
  static name = "MetavariableDeclaration";
121
121
  });
@@ -34,6 +34,40 @@ export default define(class SimpleTypeDeclaration extends Declaration {
34
34
  return simpleTypeDeclarationNode;
35
35
  }
36
36
 
37
+ async verify() {
38
+ let verifies = false;
39
+
40
+ const context = this.getContext();
41
+
42
+ await this.break(context);
43
+
44
+ const simpleTypeDeclarationString = this.getString(); ///
45
+
46
+ context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration...`);
47
+
48
+ const typeVerifies = this.verifyType();
49
+
50
+ if (typeVerifies) {
51
+ const superTypesVerify = this.verifySuperTypes();
52
+
53
+ if (superTypesVerify) {
54
+ const typePrefixVerifies = this.verifyTypePrefix();
55
+
56
+ if (typePrefixVerifies) {
57
+ context.addType(this.type);
58
+
59
+ verifies = true;
60
+ }
61
+ }
62
+ }
63
+
64
+ if (verifies) {
65
+ context.debug(`...verified the '${simpleTypeDeclarationString}' simple type declaration.`);
66
+ }
67
+
68
+ return verifies;
69
+ }
70
+
37
71
  verifyType() {
38
72
  let typeVerifies = false;
39
73
 
@@ -168,39 +202,5 @@ export default define(class SimpleTypeDeclaration extends Declaration {
168
202
  return typePrefixVerifies;
169
203
  }
170
204
 
171
- async verify() {
172
- let verifies = false;
173
-
174
- const context = this.getContext();
175
-
176
- await this.break(context);
177
-
178
- const simpleTypeDeclarationString = this.getString(); ///
179
-
180
- context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration...`);
181
-
182
- const typeVerifies = this.verifyType();
183
-
184
- if (typeVerifies) {
185
- const superTypesVerify = this.verifySuperTypes();
186
-
187
- if (superTypesVerify) {
188
- const typePrefixVerifies = this.verifyTypePrefix();
189
-
190
- if (typePrefixVerifies) {
191
- context.addType(this.type);
192
-
193
- verifies = true;
194
- }
195
- }
196
- }
197
-
198
- if (verifies) {
199
- context.debug(`...verified the '${simpleTypeDeclarationString}' simple type declaration.`);
200
- }
201
-
202
- return verifies;
203
- }
204
-
205
205
  static name = "SimpleTypeDeclaration";
206
206
  });
@@ -22,6 +22,41 @@ export default define(class TypePrefixDeclaration extends Declaration {
22
22
  return typePrefixDeclarationNode;
23
23
  }
24
24
 
25
+ async verify() {
26
+ let verifies = false;
27
+
28
+ const context = this.getContext();
29
+
30
+ await this.break(context);
31
+
32
+ const typePrefixDeclarationString = this.getString(); ///
33
+
34
+ context.trace(`Verifying the '${typePrefixDeclarationString}' type prefix declaration...`);
35
+
36
+ const includeRelease = true,
37
+ includeDependencies = false,
38
+ types = context.getTypes(includeRelease, includeDependencies),
39
+ typesLength = types.length;
40
+
41
+ if (typesLength === 0) {
42
+ const typePrefixVerifies = this.verifyTypePrefix();
43
+
44
+ if (typePrefixVerifies) {
45
+ context.addTypePrefix(this.typePrefix);
46
+
47
+ verifies = true;
48
+ }
49
+ } else {
50
+ context.debug(`Unable to verify the '${typePrefixDeclarationString}' type prefix declaration because types have already been declared.`);
51
+ }
52
+
53
+ if (verifies) {
54
+ context.debug(`...verified the '${typePrefixDeclarationString}' type prefix declaration.`);
55
+ }
56
+
57
+ return verifies;
58
+ }
59
+
25
60
  verifyTypePrefix() {
26
61
  let typePrefixVerifies = false;
27
62
 
@@ -60,40 +95,5 @@ export default define(class TypePrefixDeclaration extends Declaration {
60
95
  return typePrefixVerifies;
61
96
  }
62
97
 
63
- async verify() {
64
- let verifies = false;
65
-
66
- const context = this.getContext();
67
-
68
- await this.break(context);
69
-
70
- const typePrefixDeclarationString = this.getString(); ///
71
-
72
- context.trace(`Verifying the '${typePrefixDeclarationString}' type prefix declaration...`);
73
-
74
- const includeRelease = true,
75
- includeDependencies = false,
76
- types = context.getTypes(includeRelease, includeDependencies),
77
- typesLength = types.length;
78
-
79
- if (typesLength > 0) {
80
- context.debug(`Unable to verify the '${typePrefixDeclarationString}' type prefix declaration because types have already been declared.`);
81
- } else {
82
- const typePrefixVerifies = this.verifyTypePrefix();
83
-
84
- if (typePrefixVerifies) {
85
- context.addTypePrefix(this.typePrefix);
86
-
87
- verifies = true;
88
- }
89
- }
90
-
91
- if (verifies) {
92
- context.debug(`...verified the '${typePrefixDeclarationString}' type prefix declaration.`);
93
- }
94
-
95
- return verifies;
96
- }
97
-
98
98
  static name = "TypePrefixDeclaration";
99
99
  });
@@ -32,6 +32,36 @@ export default define(class VariableDeclaration extends Declaration {
32
32
  return typePrefixDeclarationNode;
33
33
  }
34
34
 
35
+ async verify() {
36
+ let verifies = false;
37
+
38
+ const context = this.getContext();
39
+
40
+ await this.break(context);
41
+
42
+ const variableDeclarationString = this.getString(); ///
43
+
44
+ context.trace(`Verifying the '${variableDeclarationString}' variable declaration...`);
45
+
46
+ const typeVerifies = this.verifyType();
47
+
48
+ if (typeVerifies) {
49
+ const variableVerifies = this.verifyVariable();
50
+
51
+ if (variableVerifies) {
52
+ context.addVariable(this.variable);
53
+
54
+ verifies = true;
55
+ }
56
+ }
57
+
58
+ if (verifies) {
59
+ context.debug(`...verified the '${variableDeclarationString}' variable declaration.`);
60
+ }
61
+
62
+ return verifies;
63
+ }
64
+
35
65
  verifyType() {
36
66
  let typeVerifies = false;
37
67
 
@@ -94,35 +124,5 @@ export default define(class VariableDeclaration extends Declaration {
94
124
  return variableVerifies;
95
125
  }
96
126
 
97
- async verify() {
98
- let verifies = false;
99
-
100
- const context = this.getContext();
101
-
102
- await this.break(context);
103
-
104
- const variableDeclarationString = this.getString(); ///
105
-
106
- context.trace(`Verifying the '${variableDeclarationString}' variable declaration...`);
107
-
108
- const typeVerifies = this.verifyType();
109
-
110
- if (typeVerifies) {
111
- const variableVerifies = this.verifyVariable();
112
-
113
- if (variableVerifies) {
114
- context.addVariable(this.variable);
115
-
116
- verifies = true;
117
- }
118
- }
119
-
120
- if (verifies) {
121
- context.debug(`...verified the '${variableDeclarationString}' variable declaration.`);
122
- }
123
-
124
- return verifies;
125
- }
126
-
127
127
  static name = "VariableDeclaration";
128
128
  });
@@ -140,11 +140,6 @@ export default define(class Deduction extends Element {
140
140
  static name = "Deduction";
141
141
 
142
142
  static fromJSON(json, context) {
143
- const statement = statementFromJSON(json, context),
144
- string = statement.getString();
145
-
146
- const deduction = new Deduction(context, string, statement);
147
-
148
- return deduction;
143
+ debugger
149
144
  }
150
145
  });
@@ -5,7 +5,7 @@ import { arrayUtilities } from "necessary";
5
5
 
6
6
  import { define } from "../elements";
7
7
  import { EMPTY_STRING } from "../constants";
8
- import { variablesFromTerm } from "./term";
8
+ import { variablesFromTerm } from "../utilities/equivalence";
9
9
 
10
10
  const { push, separate } = arrayUtilities;
11
11
 
@@ -363,20 +363,6 @@ export default define(class Frame extends Element {
363
363
  static name = "Frame";
364
364
 
365
365
  static fromJSON(json, context) {
366
- let frame = null;
367
-
368
- if (json !== null) {
369
- const { Assumption } =elements,
370
- assumption = Assumption.fromJSON(json, context),
371
- assumptions = [
372
- assumption
373
- ],
374
- string = null,
375
- node = null;
376
-
377
- frame = new Frame(string, node, assumptions);
378
- }
379
-
380
- return frame;
366
+ debugger
381
367
  }
382
368
  });
@@ -23,6 +23,28 @@ export default define(class Hypothesis extends Element {
23
23
  return hypothesisNode;
24
24
  }
25
25
 
26
+ compareProofAssertion(proofAssertion, context) {
27
+ let comparesToProofAssertion = false;
28
+
29
+ const hypothesisString = this.getString(), ///
30
+ proofAssertionString = proofAssertion.getString();
31
+
32
+ context.trace(`Is the '${hypothesisString}' hypothesis equal to the '${proofAssertionString}' proof assertion...`);
33
+
34
+ const proofAssertionStatement = proofAssertion.getStatement(),
35
+ statementEqualToStepStatement = this.statement.isEqualTo(proofAssertionStatement);
36
+
37
+ if (statementEqualToStepStatement) {
38
+ comparesToProofAssertion = true;
39
+ }
40
+
41
+ if (comparesToProofAssertion) {
42
+ context.trace(`...the '${hypothesisString}' hypothesis is equal to the '${proofAssertionString}' proof assertion.`);
43
+ }
44
+
45
+ return comparesToProofAssertion;
46
+ }
47
+
26
48
  async verify(context) {
27
49
  let verifies = false;
28
50
 
@@ -64,28 +86,6 @@ export default define(class Hypothesis extends Element {
64
86
  return verifies;
65
87
  }
66
88
 
67
- compareProofAssertion(proofAssertion, context) {
68
- let comparesToProofAssertion = false;
69
-
70
- const hypothesisString = this.getString(), ///
71
- proofAssertionString = proofAssertion.getString();
72
-
73
- context.trace(`Is the '${hypothesisString}' hypothesis equal to the '${proofAssertionString}' proof assertion...`);
74
-
75
- const proofAssertionStatement = proofAssertion.getStatement(),
76
- statementEqualToStepStatement = this.statement.isEqualTo(proofAssertionStatement);
77
-
78
- if (statementEqualToStepStatement) {
79
- comparesToProofAssertion = true;
80
- }
81
-
82
- if (comparesToProofAssertion) {
83
- context.trace(`...the '${hypothesisString}' hypothesis is equal to the '${proofAssertionString}' proof assertion.`);
84
- }
85
-
86
- return comparesToProofAssertion;
87
- }
88
-
89
89
  toJSON() {
90
90
  const statementJSON = statementToStatementJSON(this.statement),
91
91
  statement = statementJSON, ///
@@ -99,17 +99,6 @@ export default define(class Hypothesis extends Element {
99
99
  static name = "Hypothesis";
100
100
 
101
101
  static fromJSON(json, context) {
102
- const statement = statementFromJSON(json, context);
103
-
104
- let string;
105
-
106
- if (statement !== null) {
107
- string = statement.getString();
108
- }
109
-
110
- const node = null,
111
- hypothesis = new Hypothesis(context, string, node, statement);
112
-
113
- return hypothesis;
102
+ debugger
114
103
  }
115
104
  });
@@ -3,7 +3,10 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
6
+ import { literally } from "../utilities/context";
7
+ import { instantiateLabel } from "../process/instantiate";
8
+ import { metavariableToMetavariableJSON } from "../utilities/json";
9
+ import { metavariableFromMetavariableNode } from "../utilities/element";
7
10
 
8
11
  export default define(class Label extends Element {
9
12
  constructor(context, string, node, metavariable) {
@@ -75,7 +78,9 @@ export default define(class Label extends Element {
75
78
  toJSON() {
76
79
  const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
77
80
  metavariable = metavariableJSON, ///
81
+ string = this.getString(),
78
82
  json = {
83
+ string,
79
84
  metavariable
80
85
  };
81
86
 
@@ -85,11 +90,23 @@ export default define(class Label extends Element {
85
90
  static name = "Label";
86
91
 
87
92
  static fromJSON(json, context) {
88
- const metavariable = metavariableFromJSON(json, context),
89
- string = metavariable.getString(),
90
- node = metavariable.getNode(),
91
- label = new Label(context, string, node, metavariable);
93
+ const label = literally((context) => {
94
+ const { string } = json,
95
+ labelNode = instantiateLabel(string, context),
96
+ metavariable = metavariableFromLabelNode(labelNode, context),
97
+ node = labelNode, ///
98
+ label = new Label(context, string, node, metavariable);
99
+
100
+ return label;
101
+ }, context);
92
102
 
93
103
  return label;
94
104
  }
95
105
  });
106
+
107
+ function metavariableFromLabelNode(labelNode, context) {
108
+ const metavariableNode = labelNode.getMetavariableNode(),
109
+ metavariable = metavariableFromMetavariableNode(metavariableNode, context);
110
+
111
+ return metavariable;
112
+ }