occam-verify-cli 1.0.638 → 1.0.641

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "occam-verify-cli",
3
3
  "author": "James Smith",
4
- "version": "1.0.638",
4
+ "version": "1.0.641",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/occam-verify-cli",
7
7
  "description": "Occam's Verifier",
@@ -13,13 +13,13 @@
13
13
  "argumentative": "^2.0.36",
14
14
  "necessary": "^17.0.9",
15
15
  "occam-file-system": "^6.0.505",
16
- "occam-furtle": "^3.0.116",
17
- "occam-grammars": "^1.3.510",
18
- "occam-languages": "^0.0.88",
16
+ "occam-furtle": "^3.0.119",
17
+ "occam-grammars": "^1.3.512",
18
+ "occam-languages": "^0.0.90",
19
19
  "occam-lexers": "^23.1.34",
20
- "occam-model": "^1.0.494",
21
- "occam-nominal": "^1.0.42",
22
- "occam-parsers": "^23.1.37"
20
+ "occam-model": "^1.0.496",
21
+ "occam-nominal": "^1.0.44",
22
+ "occam-parsers": "^23.1.42"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@swc/core": "1.13.20",
package/src/context.js CHANGED
@@ -179,6 +179,13 @@ export default class Context extends ContextBase {
179
179
  return reference;
180
180
  }
181
181
 
182
+ findSubstitutionBySubstitutionNode(substitutionNode) {
183
+ const context = this.getContext(),
184
+ substitution = context.findSubstitutionBySubstitutionNode(substitutionNode);
185
+
186
+ return substitution;
187
+ }
188
+
182
189
  findVariableByVariableIdentifier(variableIdentifier) {
183
190
  const context = this.getContext(),
184
191
  variable = context.findVariableByVariableIdentifier(variableIdentifier);
@@ -113,7 +113,7 @@ export default define(class Assumption extends Element {
113
113
  }
114
114
 
115
115
  if (validates) {
116
- const assumption = this; ///
116
+ assumption = this; ///
117
117
 
118
118
  context.addAssumption(assumption);
119
119
 
@@ -25,16 +25,15 @@ export default define(class Combinator extends Element {
25
25
  return combinatorNode;
26
26
  }
27
27
 
28
- verify() {
28
+ verify(context) {
29
29
  let verifies;
30
30
 
31
- const context = this.getContext(),
32
- combinatorString = this.getString(); ///
31
+ const combinatorString = this.getString(); ///
33
32
 
34
33
  context.trace(`Verifying the '${combinatorString}' combinator...`);
35
34
 
36
35
  const combinator = this, ///
37
- combinatorVerifies = verifyCombinator(combinator, context);
36
+ combinatorVerifies = verifyCombinator(combinator);
38
37
 
39
38
  if (combinatorVerifies) {
40
39
  verifies = true;
@@ -30,7 +30,7 @@ export default define(class CombinatorDeclaration extends Declaration {
30
30
 
31
31
  context.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration...`);
32
32
 
33
- const combinatorVerifies = this.combinator.verify();
33
+ const combinatorVerifies = this.verifyCombinator();
34
34
 
35
35
  if (combinatorVerifies) {
36
36
  context.addCombinator(this.combinator);
@@ -45,5 +45,23 @@ export default define(class CombinatorDeclaration extends Declaration {
45
45
  return verifies;
46
46
  }
47
47
 
48
+ verifyCombinator() {
49
+ let combinatorVerifies;
50
+
51
+ const context = this.getContext(),
52
+ combinatorString = this.combinator.getString(),
53
+ combinatorDeclarationString = this.getString(); ///
54
+
55
+ context.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration's '${combinatorString}' combinator...`);
56
+
57
+ combinatorVerifies = this.combinator.verify(context);
58
+
59
+ if (combinatorVerifies) {
60
+ context.debug(`...verified the '${combinatorDeclarationString}' combinator declaration's '${combinatorString}' combinator.`);
61
+ }
62
+
63
+ return combinatorVerifies;
64
+ }
65
+
48
66
  static name = "CombinatorDeclaration";
49
67
  });
@@ -3,77 +3,81 @@
3
3
  import Declaration from "../declaration";
4
4
 
5
5
  import { define } from "../../elements";
6
- import { validateTerm } from "../../process/validate";
7
6
 
8
7
  export default define(class ConstructorDeclaration extends Declaration {
9
- constructor(context, string, node, constructor) {
8
+ constructor(context, string, node, type, provisional, constructor) {
10
9
  super(context, string, node);
11
10
 
11
+ this.type = type;
12
+ this.provisional = provisional;
12
13
  this.constructor = constructor;
13
14
  }
14
15
 
16
+ getType() {
17
+ return this.type;
18
+ }
19
+
20
+ isProvisinal() {
21
+ return this.provisional;
22
+ }
23
+
15
24
  getConstructor() {
16
25
  return this.constructor;
17
26
  }
18
27
 
19
28
  getConstructorDeclarationNode() {
20
29
  const node = this.getNode(),
21
- constructorDeclarationNode = node; ///
30
+ constructorDeclarationNode = node; ///
22
31
 
23
32
  return constructorDeclarationNode;
24
33
  }
25
34
 
26
- verifyConstructor() {
27
- let constructorValidates = false;
35
+ async verify() {
36
+ let verifies = false;
28
37
 
29
38
  const context = this.getContext(),
30
- constructorString = this.constructor.getString();
39
+ constructorDeclarationString = this.getString(); ///
40
+
41
+ context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration...`);
31
42
 
32
- context.trace(`Verifying the '${constructorString}' constructor...`);
43
+ const typeVerified = this.verifyType();
33
44
 
34
- const term = this.constructor.getTerm(),
35
- termNode = term.getNode(),
36
- termValidates = validateTerm(termNode, context, () => {
37
- const validatesFormards = true;
45
+ if (typeVerified) {
46
+ const constructorVerifies = this.verifyConstructor();
38
47
 
39
- return validatesFormards;
40
- });
48
+ if (constructorVerifies) {
49
+ const constructorTypeVerifies = this.verifyConstructorType();
41
50
 
42
- if (termValidates) {
43
- constructorValidates = true;
51
+ if (constructorTypeVerifies) {
52
+ context.addConstructor(this.constructor);
53
+
54
+ verifies = true;
55
+ }
56
+ }
44
57
  }
45
58
 
46
- if (constructorValidates) {
47
- context.debug(`...verified the '${constructorString}' constructor.`);
59
+ if (verifies) {
60
+ context.debug(`...verified the '${constructorDeclarationString}' constructor declaration.`);
48
61
  }
49
62
 
50
- return constructorValidates;
63
+ return verifies;
51
64
  }
52
65
 
53
- verifyConstructorType() {
54
- let constructorTypeVerifies = false;
55
-
56
- const context = this.getContext();
57
-
58
- let type;
66
+ verifyType() {
67
+ let typeVerifies = false;
59
68
 
60
- type = this.constructor.getType();
61
-
62
- const typeString = type.getString();
63
-
64
- context.trace(`Verifying the '${typeString}' type...`);
65
-
66
- const nominalTypeName = type.getNominalTypeName();
69
+ const context = this.getContext(),
70
+ typeString = this.type.getString(),
71
+ constructorDeclarationString = this.getString(); ///
67
72
 
68
- type = context.findTypeByNominalTypeName(nominalTypeName);
73
+ context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration's '${typeString}' type...`);
69
74
 
70
- const typePresent = (type !== null)
75
+ const nominalTypeName = this.type.getNominalTypeName(),
76
+ type = context.findTypeByNominalTypeName(nominalTypeName);
71
77
 
72
- if (!typePresent) {
73
- context.debug(`The '${typeString}' type is not present.`);
74
- } else {
78
+ if (type !== null) {
75
79
  const includeSupertypes = false,
76
- provisional = type.isProvisional(includeSupertypes),
80
+ provisional = this.isProvisional(includeSupertypes),
77
81
  typeComparesToProvisional = type.compareProvisional(provisional);
78
82
 
79
83
  if (!typeComparesToProvisional) {
@@ -81,45 +85,104 @@ export default define(class ConstructorDeclaration extends Declaration {
81
85
  context.debug(`The '${typeString}' type is present but not provisional.`) :
82
86
  context.debug(`The '${typeString}' type is present but provisional.`);
83
87
  } else {
84
- this.constructor.setType(type);
88
+ this.type = type;
85
89
 
86
- constructorTypeVerifies = true;
90
+ typeVerifies = true;
87
91
  }
92
+ } else {
93
+ context.debug(`The '${typeString}' type is not present.`);
88
94
  }
89
95
 
90
- if (constructorTypeVerifies) {
91
- context.debug(`...verified the '${typeString}' type.`);
96
+ if (typeVerifies) {
97
+ context.debug(`...verified the '${constructorDeclarationString}' constructor declaration's '${typeString}' type.`);
92
98
  }
93
99
 
94
- return constructorTypeVerifies;
100
+ return typeVerifies;
95
101
  }
96
102
 
97
- async verify() {
98
- let verifies;
103
+ verifyConstructor() {
104
+ let constructorVerifies;
99
105
 
100
106
  const context = this.getContext(),
101
- constructorDeclarationString = this.getString(); ///
102
-
103
- context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration...`);
104
-
105
- const constructorTypeVerifies = this.verifyConstructorType();
107
+ constructorString = this.constructor.getString(),
108
+ constructorDeclarationString = this.getString(); ///
106
109
 
107
- if (constructorTypeVerifies) {
108
- const constructorValidates = this.verifyConstructor();
110
+ context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration's '${constructorString}' constructor...`);
109
111
 
110
- if (constructorValidates) {
111
- context.addConstructor(this.constructor);
112
+ constructorVerifies = this.constructor.verify(context);
112
113
 
113
- verifies = true;
114
- }
115
- }
116
-
117
- if (verifies) {
118
- context.debug(`...verified the '${constructorDeclarationString}' constructor declaration.`);
114
+ if (constructorVerifies) {
115
+ context.debug(`...verified the '${constructorDeclarationString}' constructor declaration's '${constructorString}' constructor.`);
119
116
  }
120
117
 
121
- return verifies;
118
+ return constructorVerifies;
122
119
  }
123
120
 
121
+ // verifyConstructorType() {
122
+ // let constructorTypeVerifies = false;
123
+ //
124
+ // const context = this.getContext(),
125
+ // constructorType = this,
126
+ // constructorTypeString = constructorType.getString(),
127
+ // constructorDeclarationString = this.getString(); ///
128
+ //
129
+ // context.trace(`Verifying the '${constructorDeclarationString}' constructor declaration's '${constructorTypeString}' type...`);
130
+ //
131
+ // const nominalTypeName = this.type.getNominalTypeName(),
132
+ // typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
133
+ //
134
+ // if (!typePresent) {
135
+ // context.debug(`The '${typeString}' type is not present.`);
136
+ // } else {
137
+ // const includeSupertypes = false,
138
+ // provisional = type.isProvisional(includeSupertypes),
139
+ // typeComparesToProvisional = type.compareProvisional(provisional);
140
+ //
141
+ // if (!typeComparesToProvisional) {
142
+ // provisional ?
143
+ // context.debug(`The '${typeString}' type is present but not provisional.`) :
144
+ // context.debug(`The '${typeString}' type is present but provisional.`);
145
+ // } else {
146
+ // this.constructor.setType(type);
147
+ //
148
+ // constructorTypeVerifies = true;
149
+ // }
150
+ // }
151
+ //
152
+ // if (constructorTypeVerifies) {
153
+ // context.debug(`...verified the '${constructorDeclarationString}' constructor declaration's '${typeString}' type.`);
154
+ // }
155
+ //
156
+ // return constructorTypeVerifies;
157
+ // }
158
+
124
159
  static name = "ConstructorDeclaration";
125
160
  });
161
+
162
+
163
+ // verifyConstructor() {
164
+ // let constructorValidates = false;
165
+ //
166
+ // const context = this.getContext(),
167
+ // constructorString = this.constructor.getString();
168
+ //
169
+ // context.trace(`Verifying the '${constructorString}' constructor...`);
170
+ //
171
+ // const term = this.constructor.getTerm(),
172
+ // termNode = term.getNode(),
173
+ // termValidates = validateTerm(termNode, context, () => {
174
+ // const validatesFormards = true;
175
+ //
176
+ // return validatesFormards;
177
+ // });
178
+ //
179
+ // if (termValidates) {
180
+ // constructorValidates = true;
181
+ // }
182
+ //
183
+ // if (constructorValidates) {
184
+ // context.debug(`...verified the '${constructorString}' constructor.`);
185
+ // }
186
+ //
187
+ // return constructorValidates;
188
+ // }
@@ -120,13 +120,13 @@ export default define(class Equality extends Element {
120
120
  }
121
121
 
122
122
  validate(stated, context) {
123
- let equality = false;
123
+ let equality = null;
124
124
 
125
125
  const equalityString = this.getString(); ///
126
126
 
127
127
  context.trace(`Validating the '${equalityString}' equality...`);
128
128
 
129
- const validEquality = this.isValid(context);
129
+ const validEquality = this.findValidEquality(context);
130
130
 
131
131
  if (validEquality !== null) {
132
132
  equality = validEquality; ///
@@ -153,7 +153,7 @@ export default define(class Equality extends Element {
153
153
  }
154
154
 
155
155
  if (validates) {
156
- const equality = this; ///
156
+ equality = this; ///
157
157
 
158
158
  this.assign(stated, context);
159
159
 
@@ -174,38 +174,36 @@ export default define(class Equality extends Element {
174
174
  context.trace(`Validating the '${equalityString}' equality's terms...`);
175
175
 
176
176
  let leftTerm,
177
- rightTerm = null;
177
+ rightTerm;
178
178
 
179
179
  leftTerm = this.leftTerm.validate(context, () => {
180
- let validatesForwards;
180
+ let validatesForwards = false;
181
181
 
182
182
  rightTerm = this.rightTerm.validate(context, () => {
183
- let validatesForwards;
184
-
185
- const leftTermType = this.leftTerm.getType(),
186
- rightTermType = this.rightTerm.getType(),
187
- leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
188
-
189
- validatesForwards = leftTermTypeComparableToRightTermType; ///
183
+ const validatesForwards = true;
190
184
 
191
185
  return validatesForwards;
192
186
  });
193
187
 
194
- const rightTermValidates = (rightTerm !== null);
195
-
196
- validatesForwards = rightTermValidates; ///
188
+ if (rightTerm !== null) {
189
+ validatesForwards = true;
190
+ }
197
191
 
198
192
  return validatesForwards;
199
193
  });
200
194
 
201
- const leftTermValidates = (leftTerm !== null);
195
+ if (leftTerm !== null) {
196
+ const leftTermType = leftTerm.getType(),
197
+ rightTermType = rightTerm.getType(),
198
+ leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
202
199
 
203
- if (leftTermValidates) {
204
- this.leftTerm = leftTerm;
200
+ if (leftTermTypeComparableToRightTermType) {
201
+ this.leftTerm = leftTerm;
205
202
 
206
- this.rightTerm = rightTerm;
203
+ this.rightTerm = rightTerm;
207
204
 
208
- termsValidate = true;
205
+ termsValidate = true;
206
+ }
209
207
  }
210
208
 
211
209
  if (termsValidate) {
@@ -64,7 +64,6 @@ export default define(class Frame extends Element {
64
64
  return validFrame;
65
65
  }
66
66
 
67
-
68
67
  isEqualTo(frame) {
69
68
  const frameNode = frame.getNode(),
70
69
  frameNodeMatches = this.matchFrameNode(frameNode),
@@ -97,7 +97,7 @@ export default define(class Judgement extends Element {
97
97
  }
98
98
 
99
99
  if (validates) {
100
- const judgement = this; ///
100
+ judgement = this; ///
101
101
 
102
102
  context.addJudgement(judgement)
103
103
 
@@ -144,7 +144,7 @@ export default define(class Reference extends Element {
144
144
  }
145
145
 
146
146
  if (validates) {
147
- const reference = this; ///
147
+ reference = this; ///
148
148
 
149
149
  context.addReference(reference);
150
150
 
@@ -196,7 +196,7 @@ export default define(class Statement extends Element {
196
196
  });
197
197
 
198
198
  if (validates) {
199
- const statement = this; ///
199
+ statement = this; ///
200
200
 
201
201
  context.addStatement(statement);
202
202
 
@@ -159,9 +159,13 @@ export default define(class Term extends Element {
159
159
  valid = (validTerm !== null);
160
160
 
161
161
  if (valid) {
162
- term = validTerm; ///
162
+ const validatesForward = validateForwards();
163
163
 
164
- context.debug(`...the '${termString}' term is already valid.`);
164
+ if (validatesForward) {
165
+ term = validTerm; ///
166
+
167
+ context.debug(`...the '${termString}' term is already valid.`);
168
+ }
165
169
  } else {
166
170
  const validates = validateTerms.some((validateTerm) => { ///
167
171
  const term = this, ///
@@ -173,7 +177,7 @@ export default define(class Term extends Element {
173
177
  });
174
178
 
175
179
  if (validates) {
176
- term = null; ///
180
+ term = this; ///
177
181
 
178
182
  context.addTerm(term);
179
183