occam-verify-cli 0.0.270 → 0.0.271

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.
@@ -1,29 +1,49 @@
1
1
  "use strict";
2
2
 
3
+ const { matchBracketedMetastatementChildNode } = require("./utilities/metastatement");
4
+
3
5
  class MetaSubstitution {
4
- constructor(metavariableName, nonTerminalNode) {
6
+ constructor(metavariableName, nodes) {
5
7
  this.metavariableName = metavariableName;
6
- this.nonTerminalNode = nonTerminalNode;
8
+ this.nodes = nodes;
7
9
  }
8
10
 
9
11
  getMetavariableName() {
10
12
  return this.metavariableName;
11
13
  }
12
14
 
13
- getNonTerminalNode() {
14
- return this.nonTerminalNode;
15
+ getNodes() {
16
+ return this.nodes;
15
17
  }
16
18
 
17
- matchNonTerminalNode(nonTerminalNode) {
18
- const metaSubstitutionNonTerminalNode = this.nonTerminalNode,
19
- metaSubstitutionNonTerminalNodeMatches = matchMetaSubstitutionNonTerminalNode(metaSubstitutionNonTerminalNode, nonTerminalNode),
20
- nonTerminalNodeMatches = metaSubstitutionNonTerminalNodeMatches; ///
19
+ matchNodes(nodes) {
20
+ let matches;
21
+
22
+ const metaSubstitutionNodes = this.nodes, ///
23
+ metaSubstitutionNonTerminalNodeMatches = matchMetaSubstitutionNodes(metaSubstitutionNodes, nodes);
24
+
25
+ matches = metaSubstitutionNonTerminalNodeMatches; ///
26
+
27
+ if (!matches) {
28
+ const childNodes = nodes, ///
29
+ bracketedMetastatementChildNodeMatches = matchBracketedMetastatementChildNode(childNodes, (bracketedMetastatementChildNode) => {
30
+ const nonTerminalNode = bracketedMetastatementChildNode, ///
31
+ childNodes = nonTerminalNode.getChildNodes(),
32
+ nodes = childNodes, ///
33
+ metaAssertionNonTerminalNodeMatches = matchMetaSubstitutionNodes(metaSubstitutionNodes, nodes),
34
+ bracketedMetastatementChildNodeMatches = metaAssertionNonTerminalNodeMatches; ///
35
+
36
+ return bracketedMetastatementChildNodeMatches;
37
+ });
21
38
 
22
- return nonTerminalNodeMatches;
39
+ matches = bracketedMetastatementChildNodeMatches; ///
40
+ }
41
+
42
+ return matches;
23
43
  }
24
44
 
25
- static fromMetavariableNameAndNonTerminalNode(metavariableName, nonTerminalNode) {
26
- const metaSubstitution = new MetaSubstitution(metavariableName, nonTerminalNode);
45
+ static fromMetavariableNameAndNodes(metavariableName, nodes) {
46
+ const metaSubstitution = new MetaSubstitution(metavariableName, nodes);
27
47
 
28
48
  return metaSubstitution;
29
49
  }
@@ -56,17 +76,15 @@ function matchMetaSubstitutionNode(metaSubstitutionNode, node) {
56
76
  return metaSubstitutionNodeMatches;
57
77
  }
58
78
 
59
- function matchMetaSubstitutionChildNodes(metaSubstitutionChildNodes, childNodes) {
60
- let metaSubstitutionChildNodesMatches = false;
79
+ function matchMetaSubstitutionNodes(metaSubstitutionNodes, nodes) {
80
+ let metaSubstitutionNodesMatches = false;
61
81
 
62
- const childNodesLength = childNodes.length,
63
- metaSubstitutionChildNodesLength = metaSubstitutionChildNodes.length;
82
+ const nodesLength = nodes.length,
83
+ metaSubstitutionNodesLength = metaSubstitutionNodes.length;
64
84
 
65
- if (childNodesLength === metaSubstitutionChildNodesLength) {
66
- metaSubstitutionChildNodesMatches = childNodes.every((childNode, index) => {
67
- const metaSubstitutionChildNode = metaSubstitutionChildNodes[index],
68
- metaSubstitutionNode = metaSubstitutionChildNode, ///
69
- node = childNode, ///
85
+ if (nodesLength === metaSubstitutionNodesLength) {
86
+ metaSubstitutionNodesMatches = nodes.every((node, index) => {
87
+ const metaSubstitutionNode = metaSubstitutionNodes[index],
70
88
  metaSubstitutionNodeMatches = matchMetaSubstitutionNode(metaSubstitutionNode, node);
71
89
 
72
90
  if (metaSubstitutionNodeMatches) {
@@ -75,17 +93,12 @@ function matchMetaSubstitutionChildNodes(metaSubstitutionChildNodes, childNodes)
75
93
  })
76
94
  }
77
95
 
78
- return metaSubstitutionChildNodesMatches;
96
+ return metaSubstitutionNodesMatches;
79
97
  }
80
98
 
81
99
  function matchMetaSubstitutionTerminalNode(metaSubstitutionTerminalNode, terminalNode) {
82
- let metaSubstitutionTerminalNodeMatches = false;
83
-
84
- const matches = metaSubstitutionTerminalNode.match(terminalNode);
85
-
86
- if (matches) {
87
- metaSubstitutionTerminalNodeMatches = true;
88
- }
100
+ const matches = metaSubstitutionTerminalNode.match(terminalNode),
101
+ metaSubstitutionTerminalNodeMatches = matches; ///
89
102
 
90
103
  return metaSubstitutionTerminalNodeMatches;
91
104
  }
@@ -99,9 +112,11 @@ function matchMetaSubstitutionNonTerminalNode(metaSubstitutionNonTerminalNode, n
99
112
  if (ruleName === metaSubstitutionRuleName) {
100
113
  const childNodes = nonTerminalNode.getChildNodes(),
101
114
  metaSubstitutionChildNodes = metaSubstitutionNonTerminalNode.getChildNodes(),
102
- metaSubstitutionChildNodesMatches = matchMetaSubstitutionChildNodes(metaSubstitutionChildNodes, childNodes);
115
+ nodes = childNodes, ///
116
+ metaSubstitutionNodes = metaSubstitutionChildNodes, ///
117
+ metaSubstitutionNodesMatches = matchMetaSubstitutionNodes(metaSubstitutionNodes, nodes);
103
118
 
104
- metaSubstitutionNonTerminalNodeMatches = metaSubstitutionChildNodesMatches; ///
119
+ metaSubstitutionNonTerminalNodeMatches = metaSubstitutionNodesMatches; ///
105
120
  }
106
121
 
107
122
  return metaSubstitutionNonTerminalNodeMatches;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ [[0,1,2],[1,0,2],[1,2,0],[0,2,1],[2,0,1],[2,1,0],[0,1,3],[1,0,3],[1,3,0],[0,3,1],[3,0,1],[3,1,0],[0,1,4],[1,0,4],[1,4,0],[0,4,1],[4,0,1],[4,1,0],[0,2,3],[2,0,3],[2,3,0],[0,3,2],[3,0,2],[3,2,0],[0,2,4],[2,0,4],[2,4,0],[0,4,2],[4,0,2],[4,2,0],[0,3,4],[3,0,4],[3,4,0],[0,4,3],[4,0,3],[4,3,0],[1,2,3],[2,1,3],[2,3,1],[1,3,2],[3,1,2],[3,2,1],[1,2,4],[2,1,4],[2,4,1],[1,4,2],[4,1,2],[4,2,1],[1,3,4],[3,1,4],[3,4,1],[1,4,3],[4,1,3],[4,3,1],[2,3,4],[3,2,4],[3,4,2],[2,4,3],[4,2,3],[4,3,2]]