occam-verify-cli 1.0.315 → 1.0.317

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.
@@ -19,22 +19,24 @@ import { typesFromJSON,
19
19
  axiomsToAxiomsJSON,
20
20
  conjecturesFromJSON,
21
21
  combinatorsFromJSON,
22
+ typePrefixesFromJSON,
22
23
  constructorsFromJSON,
23
24
  metatheoremsFromJSON,
24
25
  metavariablesFromJSON,
25
26
  metaLemmasFromNothing,
26
27
  theoremsToTheoremsJSON,
27
28
  variablesToVariablesJSON,
29
+ typePrefixesToTypePrefixesJSON,
28
30
  conjecturesToConjecturesJSON,
29
31
  combinatorsToCombinatorsJSON,
30
32
  constructorsToConstructorsJSON,
31
33
  metatheoremsToMetatheoremsJSON,
32
34
  metavariablesToMetavariablesJSON } from "../utilities/json";
33
35
 
34
- const { push, filter } = arrayUtilities;
36
+ const { push, first, filter } = arrayUtilities;
35
37
 
36
38
  export default class FileContext {
37
- constructor(releaseContext, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, constructors, metatheorems, metavariables) {
39
+ constructor(releaseContext, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables) {
38
40
  this.releaseContext = releaseContext;
39
41
  this.filePath = filePath;
40
42
  this.lineIndex = lineIndex;
@@ -49,6 +51,7 @@ export default class FileContext {
49
51
  this.metaLemmas = metaLemmas;
50
52
  this.conjectures = conjectures;
51
53
  this.combinators = combinators;
54
+ this.typePrefixes = typePrefixes;
52
55
  this.constructors = constructors;
53
56
  this.metatheorems = metatheorems;
54
57
  this.metavariables = metavariables;
@@ -274,6 +277,10 @@ export default class FileContext {
274
277
  return combinators;
275
278
  }
276
279
 
280
+ getTypePrefixes(includeRelease = true) {
281
+ return this.typePrefixes;
282
+ }
283
+
277
284
  getConstructors(includeRelease = true) {
278
285
  const constructors = [];
279
286
 
@@ -312,6 +319,20 @@ export default class FileContext {
312
319
  return fileContext;
313
320
  }
314
321
 
322
+ getTypePrefix() {
323
+ let typePrefix = null;
324
+
325
+ const typePrefixesLength = this.typePrefixes.length;
326
+
327
+ if (typePrefixesLength === 1) {
328
+ const firstTypePrefix = first(this.typePrefixes);
329
+
330
+ typePrefix = firstTypePrefix; ///
331
+ }
332
+
333
+ return typePrefix;
334
+ }
335
+
315
336
  addType(type) {
316
337
  this.types.push(type);
317
338
  }
@@ -862,6 +883,7 @@ export default class FileContext {
862
883
  this.metaLemmas = [];
863
884
  this.conjectures = [];
864
885
  this.combinators = [];
886
+ this.typePrefixes = [];
865
887
  this.constructors = [];
866
888
  this.metatheorems = [];
867
889
  this.metavariables = [];
@@ -907,6 +929,8 @@ export default class FileContext {
907
929
 
908
930
  this.combinators = combinatorsFromJSON(json, fileContext);
909
931
 
932
+ this.typePrefixes = typePrefixesFromJSON(json, fileContext);
933
+
910
934
  this.constructors = constructorsFromJSON(json, fileContext);
911
935
 
912
936
  this.metatheorems = metatheoremsFromJSON(json, fileContext);
@@ -922,6 +946,7 @@ export default class FileContext {
922
946
  variablesJSON = variablesToVariablesJSON(this.variables),
923
947
  conjecturesJSON = conjecturesToConjecturesJSON(this.conjectures),
924
948
  combinatorsJSON = combinatorsToCombinatorsJSON(this.combinators),
949
+ typePrefixesJSON = typePrefixesToTypePrefixesJSON(this.typePrefixes),
925
950
  constructorsJSON = constructorsToConstructorsJSON(this.constructors),
926
951
  metatheoremsJSON = metatheoremsToMetatheoremsJSON(this.metatheorems),
927
952
  metavariablesJSON = metavariablesToMetavariablesJSON(this.metavariables),
@@ -933,6 +958,7 @@ export default class FileContext {
933
958
  variables = variablesJSON, ///
934
959
  conjectures = conjecturesJSON, ///
935
960
  combinators = combinatorsJSON, ///
961
+ typePrefixes = typePrefixesJSON, ///
936
962
  constructors = constructorsJSON, ///
937
963
  metatheorems = metatheoremsJSON, ///
938
964
  metavariables = metavariablesJSON, ///
@@ -945,6 +971,7 @@ export default class FileContext {
945
971
  variables,
946
972
  conjectures,
947
973
  combinators,
974
+ typePrefixes,
948
975
  constructors,
949
976
  metatheorems,
950
977
  metavariables
@@ -967,10 +994,11 @@ export default class FileContext {
967
994
  metaLemmas = [],
968
995
  conjectures = [],
969
996
  combinators = [],
997
+ typePrefixes = [],
970
998
  constructors = [],
971
999
  metatheorems = [],
972
1000
  metavariables = [],
973
- fileContext = new FileContext(releaseContext, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, constructors, metatheorems, metavariables);
1001
+ fileContext = new FileContext(releaseContext, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables);
974
1002
 
975
1003
  return fileContext;
976
1004
  }
@@ -988,10 +1016,11 @@ export default class FileContext {
988
1016
  metaLemmas = null,
989
1017
  conjectures = null,
990
1018
  combinators = null,
1019
+ typePrefixes = null,
991
1020
  constructors = null,
992
1021
  metatheorems = null,
993
1022
  metavariables = null,
994
- fileContext = new FileContext(releaseContext, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, constructors, metatheorems, metavariables);
1023
+ fileContext = new FileContext(releaseContext, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables);
995
1024
 
996
1025
  fileContext.initialise(json);
997
1026
 
@@ -64,11 +64,12 @@ export default domAssigned(class TypeAssertion {
64
64
  verifyType(context) {
65
65
  let typeVerifies;
66
66
 
67
- const typeString = this.type.getString();
67
+ const typeName = this.type.getName(),
68
+ typeString = this.type.getString();
68
69
 
69
70
  context.trace(`Verifying the '${typeString}' type...`);
70
71
 
71
- const type = context.findTypeByTypeName(typeString);
72
+ const type = context.findTypeByTypeName(typeName);
72
73
 
73
74
  if (type !== null) {
74
75
  this.type = type;
@@ -92,11 +92,12 @@ export default domAssigned(class Variable {
92
92
  verifyType(context) {
93
93
  let typeVerifies = false;
94
94
 
95
- const typeString = this.type.getString();
95
+ const typeName = this.tyupe.getName(),
96
+ typeString = this.type.getString();
96
97
 
97
98
  context.trace(`Verifying the '${typeString}' type...`);
98
99
 
99
- const type = context.findTypeByTypeName(typeString);
100
+ const type = context.findTypeByTypeName(typeName);
100
101
 
101
102
  if (type === null) {
102
103
  context.debug(`The '${typeString}' type is not present.`);
package/src/node/type.js CHANGED
@@ -22,5 +22,24 @@ export default class TypeNode extends NonTerminalNode {
22
22
  return typeName;
23
23
  }
24
24
 
25
+ getTypePrefix() {
26
+ let typePrefix;
27
+
28
+ this.someChildNode((childNode) => {
29
+ const childNodeTerminalNode = childNode.isTerminalNode();
30
+
31
+ if (childNodeTerminalNode) {
32
+ const terminalNode = childNode, ///
33
+ content = terminalNode.getContent();
34
+
35
+ typePrefix = content; ///
36
+
37
+ return true;
38
+ }
39
+ });
40
+
41
+ return typePrefix;
42
+ }
43
+
25
44
  static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(TypeNode, ruleName, childNodes, opacity, precedence); }
26
45
  }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ import NonTerminalNode from "../node/nonTerminal";
4
+
5
+ export default class TypePrefixNode extends NonTerminalNode {
6
+ getTypePrefix() {
7
+ let typePrefix;
8
+
9
+ this.someChildNode((childNode) => {
10
+ const childNodeTerminalNode = childNode.isTerminalNode();
11
+
12
+ if (childNodeTerminalNode) {
13
+ const terminalNode = childNode, ///
14
+ content = terminalNode.getContent();
15
+
16
+ typePrefix = content; ///
17
+
18
+ return true;
19
+ }
20
+ });
21
+
22
+ return typePrefix;
23
+ }
24
+
25
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(TypePrefixNode, ruleName, childNodes, opacity, precedence); }
26
+ }
@@ -372,6 +372,22 @@ export function combinatorsFromJSON(json, context) {
372
372
  return combinators;
373
373
  }
374
374
 
375
+ export function typePrefixesFromJSON(json, context) {
376
+ let { typePrefixes } = json;
377
+
378
+ const { TypePrefix } = dom,
379
+ typePrefixesJSON = typePrefixes; ///
380
+
381
+ typePrefixes = typePrefixesJSON.map((typePrefixJSON) => {
382
+ const json = typePrefixJSON, ///
383
+ typePrefix = TypePrefix.fromJSON(json, context);
384
+
385
+ return typePrefix;
386
+ });
387
+
388
+ return typePrefixes;
389
+ }
390
+
375
391
  export function constructorsFromJSON(json, context) {
376
392
  let { constructors } = json;
377
393
 
@@ -680,6 +696,18 @@ export function propertiesToPropertiesJSON(properties) {
680
696
  return propertiesJSON;
681
697
  }
682
698
 
699
+ export function typePrefixesToTypePrefixesJSON(typePrefixes) {
700
+ const typePrefixesJSON = typePrefixes.map((typePrefix) => {
701
+ const typePrefixJSON = typePrefix.toJSON();
702
+
703
+ typePrefix = typePrefixJSON; ///
704
+
705
+ return typePrefix;
706
+ });
707
+
708
+ return typePrefixesJSON;
709
+ }
710
+
683
711
  export function conjecturesToConjecturesJSON(conjectures) {
684
712
  const conjecturesJSON = conjectures.map((conjecture) => {
685
713
  const conjectureJSON = conjecture.toJSON();