occam-verify-cli 0.0.374 → 0.0.376

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.
@@ -8,7 +8,7 @@ const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities,
8
8
  { florenceParserFromCombinedCustomGrammar } = parsersUtilities;
9
9
 
10
10
  export default class ReleaseContext {
11
- constructor(log, name, entries, callbacks, verified, customGrammar, florenceLexer, florenceParser, releaseContexts) {
11
+ constructor(log, name, entries, callbacks, verified, customGrammar, florenceLexer, florenceParser, dependencyReleaseContexts) {
12
12
  this.log = log;
13
13
  this.name = name;
14
14
  this.entries = entries;
@@ -17,7 +17,7 @@ export default class ReleaseContext {
17
17
  this.customGrammar = customGrammar;
18
18
  this.florenceLexer = florenceLexer;
19
19
  this.florenceParser = florenceParser;
20
- this.releaseContexts = releaseContexts;
20
+ this.dependencyReleaseContexts = dependencyReleaseContexts;
21
21
  }
22
22
 
23
23
  getLog() {
@@ -52,8 +52,8 @@ export default class ReleaseContext {
52
52
  return this.florenceParser;
53
53
  }
54
54
 
55
- getReleaseContexts() {
56
- return this.releaseContexts;
55
+ getDependencyReleaseContexts() {
56
+ return this.dependencyReleaseContexts;
57
57
  }
58
58
 
59
59
  getReleaseName() {
@@ -64,7 +64,7 @@ export default class ReleaseContext {
64
64
  }
65
65
 
66
66
  isInitialised() {
67
- const initialised = (this.releaseContexts !== null); ///
67
+ const initialised = (this.dependencyReleaseContexts !== null); ///
68
68
 
69
69
  return initialised;
70
70
  }
@@ -117,6 +117,6 @@ export default class ReleaseContext {
117
117
 
118
118
  this.florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
119
119
 
120
- this.releaseContexts = releaseContexts;
120
+ this.dependencyReleaseContexts = dependencyReleaseContexts;
121
121
  }
122
122
  }
package/src/kinds.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- export const RULE_KIND = "rule";
4
3
  export const TYPE_KIND = "type";
4
+ export const RULE_KIND = "rule";
5
5
  export const AXIOM_KIND = "axiom";
6
6
  export const COMBINATOR_KIND = "combinator";
7
7
  export const CONSTRUCTOR_KIND = "constructor";
package/src/label.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { nodeAsString } from "./utilities/string";
4
+ import { LABEL_RULE_NAME } from "./ruleNames";
4
5
  import { labelNameFromLabelNode } from "./utilities/query";
5
6
 
6
7
  export default class Label {
@@ -26,6 +27,22 @@ export default class Label {
26
27
  return string;
27
28
  }
28
29
 
30
+ toJSON() {
31
+ const string = nodeAsString(this.node),
32
+ json = string; ///
33
+
34
+ return json;
35
+ }
36
+
37
+ static fromJSON(json, callback) {
38
+ const content = json, ///
39
+ ruleName = LABEL_RULE_NAME,
40
+ node = callback(content, ruleName),
41
+ label = new Label(node);
42
+
43
+ return label;
44
+ }
45
+
29
46
  static fromLabelNode(labelNode) {
30
47
  const node = labelNode, ///
31
48
  variable = new Label(node);
package/src/premise.js CHANGED
@@ -70,6 +70,17 @@ export default class Premise {
70
70
  return json;
71
71
  }
72
72
 
73
+ static fromJSON(json, callback) {
74
+ const { metastatement } = json,
75
+ ruleName = METASTATEMENT_RULE_NAME,
76
+ content = metastatement, ///
77
+ node = callback(content, ruleName),
78
+ metastatementNode = node, ///
79
+ premise = new Premise(metastatementNode);
80
+
81
+ return premise;
82
+ }
83
+
73
84
  static fromMetastatementNode(metastatementNode) {
74
85
  const premise = new Premise(metastatementNode);
75
86
 
package/src/rule.js CHANGED
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ import Label from "./label";
4
+ import Premise from "./premise";
5
+ import Conclusion from "./conclusion";
6
+
3
7
  import { prune } from "./utilities/array";
4
8
  import { RULE_KIND } from "./kinds";
5
9
  import { someSubArray } from "./utilities/array";
@@ -62,29 +66,57 @@ export default class Rule {
62
66
  }
63
67
 
64
68
  toJSON() {
65
- const premisesJSON = this.premises.map((premise) => {
69
+ const labelsJSON = this.labels.map((label) => {
70
+ const labelJSON = label.toJSON();
71
+
72
+ return labelJSON;
73
+ }),
74
+ premisesJSON = this.premises.map((premise) => {
66
75
  const premiseJSON = premise.toJSON();
67
76
 
68
77
  return premiseJSON;
69
78
  }),
70
79
  conclusionJSON = this.conclusion.toJSON(),
71
80
  kind = RULE_KIND,
81
+ labels = labelsJSON, ///
72
82
  premises = premisesJSON, ///
73
83
  conclusion = conclusionJSON, ///
74
- json = this.labels.map((label) => {
75
- const labelString = label.asString();
84
+ json = {
85
+ kind,
86
+ labels,
87
+ premises,
88
+ conclusion
89
+ };
90
+
91
+ return json;
92
+ }
76
93
 
77
- label = labelString; ///
94
+ static fromJSON(json, callback) {
95
+ let { labels, premises, conclusion } = json;
78
96
 
79
- return ({
80
- kind,
81
- label,
82
- premises,
83
- conclusion
84
- });
85
- });
97
+ labels = labels.map((label) => {
98
+ const json = label; ///
86
99
 
87
- return json;
100
+ label = Label.fromJSON(json, callback);
101
+
102
+ return label;
103
+ });
104
+
105
+ premises = premises.map((premise) => {
106
+ const json = premise; ///
107
+
108
+ premise = Premise.fromJSON(json, callback);
109
+
110
+ return premise;
111
+ });
112
+
113
+ json = conclusion; ///
114
+
115
+ conclusion = Conclusion.fromJSON(json, callback);
116
+
117
+ const rule = new Rule(labels, premises, conclusion);
118
+
119
+ return rule;
88
120
  }
89
121
 
90
122
  static fromLabelsPremisesAndConclusion(labels, premises, conclusion) {
package/src/ruleNames.js CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  export const TERM_RULE_NAME = "term";
4
4
  export const TYPE_RULE_NAME = "type";
5
+ export const LABEL_RULE_NAME = "label";
5
6
  export const ARGUMENT_RULE_NAME = "argument";
7
+ export const STATEMENT_RULE_NAME = "statement";
6
8
  export const METAVARIABLE_RULE_NAME = "metavariable";
7
9
  export const METASTATEMENT_RULE_NAME = "metastatement";
8
10
  export const META_SUBPROOF_RULE_NAME = "metaSubproof";
package/src/type.js CHANGED
@@ -110,15 +110,32 @@ export default class Type {
110
110
  kind = TYPE_KIND,
111
111
  name = this.name,
112
112
  superType = superTypeJSON, ///
113
- json = [{
113
+ json = {
114
114
  kind,
115
115
  name,
116
116
  superType
117
- }];
117
+ };
118
118
 
119
119
  return json;
120
120
  }
121
121
 
122
+ static fromJSON(json) {
123
+ const { name } = json;
124
+
125
+ let { superType } = json;
126
+
127
+ if (superType !== null) {
128
+ json = superType; ///
129
+
130
+ superType = Type.fromJSON(json);
131
+ }
132
+
133
+ const type = new Type(name, superType);
134
+
135
+ return type;
136
+ }
137
+
138
+
122
139
  static fromTypeName(typeName) {
123
140
  const name = typeName, ///
124
141
  superType = null,
@@ -17,17 +17,15 @@ export default function verifyRelease(releaseName, releaseContextMap) {
17
17
  const releaseFilesVerified = verifyReleaseFiles(releaseContext);
18
18
 
19
19
  if (releaseFilesVerified) {
20
- releaseVerified = true;
21
- }
22
- }
23
- }
20
+ const verified = true;
24
21
 
25
- if (releaseVerified) {
26
- const verified = true;
22
+ releaseVerified = true;
27
23
 
28
- releaseContext.setVerified(verified);
24
+ releaseContext.setVerified(verified);
29
25
 
30
- releaseContext.info(`Verified the '${releaseName}' package.`);
26
+ releaseContext.info(`Verified the '${releaseName}' package.`);
27
+ }
28
+ }
31
29
  }
32
30
 
33
31
  return releaseVerified;