occam-verify-cli 0.0.526 → 0.0.529
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/README.md +4 -0
- package/bin/abbreviations.js +5 -1
- package/bin/action/help.js +4 -0
- package/bin/action/verify.js +35 -13
- package/bin/actions.js +11 -6
- package/bin/defaults.js +4 -0
- package/bin/options.js +4 -0
- package/bin/utilities/releaseContext.js +5 -7
- package/lib/assertion/type.js +10 -40
- package/lib/axiom.js +8 -8
- package/lib/axiomLemmaTheoremConjecture.js +190 -0
- package/lib/combinator.js +4 -3
- package/lib/conclusion.js +8 -7
- package/lib/conjecture.js +141 -0
- package/lib/consequence.js +6 -5
- package/lib/constants.js +11 -27
- package/lib/constructor.js +5 -4
- package/lib/context/file.js +88 -73
- package/lib/context/metaproof.js +51 -20
- package/lib/context/proof.js +48 -114
- package/lib/context/release/directory.js +25 -6
- package/lib/context/release/file.js +38 -25
- package/lib/context/release.js +32 -51
- package/lib/equality.js +79 -51
- package/lib/index.js +4 -16
- package/lib/kinds.js +5 -1
- package/lib/label.js +4 -3
- package/lib/lemma.js +8 -8
- package/lib/log.js +146 -0
- package/lib/matcher.js +25 -75
- package/lib/metaTypeNames.js +13 -0
- package/lib/mixins/file.js +62 -2
- package/lib/mixins/logging.js +13 -13
- package/lib/node/metastatement/bracketed.js +16 -0
- package/lib/node/statement/bracketed.js +16 -0
- package/lib/node/statement/combinator/bracketed.js +17 -0
- package/lib/node/statement/combinator/equality.js +17 -0
- package/lib/node/statement/equality.js +16 -0
- package/lib/ocmbinator/bracketed.js +3 -4
- package/lib/ocmbinator/equality.js +3 -4
- package/lib/premise.js +13 -12
- package/lib/rule.js +5 -5
- package/lib/ruleNames.js +1 -9
- package/lib/step/metaproof.js +28 -25
- package/lib/step/proof.js +23 -1
- package/lib/substitution/metastatementForMetavariable.js +16 -13
- package/lib/substitution/statementForMetavariable.js +16 -13
- package/lib/substitution/termForVariable.js +76 -0
- package/lib/supposition.js +7 -6
- package/lib/theorem.js +8 -8
- package/lib/type.js +12 -5
- package/lib/utilities/metaproof.js +60 -0
- package/lib/utilities/node.js +56 -0
- package/lib/utilities/proof.js +60 -0
- package/lib/utilities/releaseContext.js +24 -12
- package/lib/utilities/string.js +3 -38
- package/lib/variable.js +4 -38
- package/lib/{matcher → verifier}/metastatementForMetavariable/conclusion.js +12 -12
- package/lib/{matcher → verifier}/metastatementForMetavariable/premise.js +12 -12
- package/lib/verifier/metastatementForMetavariable.js +198 -0
- package/lib/{matcher → verifier}/statementForMetavariable/conclusion.js +12 -12
- package/lib/{matcher → verifier}/statementForMetavariable/premise.js +12 -12
- package/lib/verifier/statementForMetavariable.js +203 -0
- package/lib/{matcher/statementForVariable → verifier/termForVariable}/consequence.js +13 -13
- package/lib/{matcher/statementForVariable → verifier/termForVariable}/supposition.js +13 -13
- package/lib/verifier/termForVariable.js +198 -0
- package/lib/verifier.js +92 -0
- package/lib/verify/assertion/type.js +62 -41
- package/lib/verify/axiom.js +3 -6
- package/lib/verify/conclusion.js +2 -4
- package/lib/verify/conjecture.js +54 -0
- package/lib/verify/consequence.js +2 -4
- package/lib/verify/declaration/combinator.js +1 -3
- package/lib/verify/declaration/constructor.js +1 -3
- package/lib/verify/declaration/topLevel.js +7 -5
- package/lib/verify/declaration/type.js +1 -3
- package/lib/verify/declaration/variable.js +1 -3
- package/lib/verify/derivation.js +1 -5
- package/lib/verify/label.js +1 -3
- package/lib/verify/lemma.js +3 -6
- package/lib/verify/metastatement/qualified.js +2 -5
- package/lib/verify/metastatement/unqualified.js +2 -5
- package/lib/verify/metastatement.js +1 -3
- package/lib/verify/premise.js +2 -4
- package/lib/verify/proof.js +3 -5
- package/lib/verify/rule.js +3 -6
- package/lib/verify/ruleDerivation.js +1 -5
- package/lib/verify/ruleProof.js +3 -5
- package/lib/verify/statement/qualified.js +40 -13
- package/lib/verify/statement/unqualified.js +2 -5
- package/lib/verify/statement.js +56 -62
- package/lib/verify/statementAsCombinator.js +4 -6
- package/lib/verify/supposition.js +2 -4
- package/lib/verify/term.js +4 -10
- package/lib/verify/termAsConstructor.js +6 -9
- package/lib/verify/theorem.js +3 -6
- package/lib/verify/type.js +5 -9
- package/lib/verify/variable.js +5 -9
- package/package.json +1 -1
- package/src/assertion/type.js +7 -32
- package/src/axiom.js +4 -4
- package/src/{axiomLemmaTheorem.js → axiomLemmaTheoremConjecture.js} +9 -9
- package/src/combinator.js +3 -3
- package/src/conclusion.js +7 -7
- package/src/conjecture.js +13 -0
- package/src/consequence.js +5 -5
- package/src/constants.js +3 -7
- package/src/constructor.js +4 -4
- package/src/context/file.js +85 -65
- package/src/context/metaproof.js +55 -15
- package/src/context/proof.js +53 -50
- package/src/context/release/directory.js +31 -7
- package/src/context/release/file.js +47 -31
- package/src/context/release.js +23 -32
- package/src/equality.js +108 -61
- package/src/index.js +2 -4
- package/src/kinds.js +1 -0
- package/src/label.js +3 -3
- package/src/lemma.js +4 -4
- package/src/log.js +116 -0
- package/src/matcher.js +32 -24
- package/src/metaTypeNames.js +3 -0
- package/src/mixins/file.js +46 -1
- package/src/mixins/logging.js +6 -6
- package/src/node/metastatement/bracketed.js +9 -0
- package/src/node/statement/bracketed.js +9 -0
- package/src/node/statement/combinator/bracketed.js +10 -0
- package/src/node/statement/combinator/equality.js +11 -0
- package/src/node/statement/equality.js +10 -0
- package/src/ocmbinator/bracketed.js +2 -5
- package/src/ocmbinator/equality.js +2 -5
- package/src/premise.js +13 -13
- package/src/rule.js +4 -4
- package/src/ruleNames.js +0 -2
- package/src/step/metaproof.js +32 -29
- package/src/step/proof.js +28 -0
- package/src/substitution/metastatementForMetavariable.js +10 -15
- package/src/substitution/statementForMetavariable.js +11 -16
- package/src/substitution/termForVariable.js +36 -0
- package/src/supposition.js +6 -6
- package/src/theorem.js +4 -4
- package/src/type.js +17 -7
- package/src/utilities/metaproof.js +62 -0
- package/src/utilities/node.js +73 -0
- package/src/utilities/proof.js +62 -0
- package/src/utilities/releaseContext.js +30 -12
- package/src/utilities/string.js +4 -53
- package/src/variable.js +4 -37
- package/src/verifier/metastatementForMetavariable/conclusion.js +9 -0
- package/src/verifier/metastatementForMetavariable/premise.js +9 -0
- package/src/verifier/metastatementForMetavariable.js +89 -0
- package/src/verifier/statementForMetavariable/conclusion.js +9 -0
- package/src/verifier/statementForMetavariable/premise.js +9 -0
- package/src/verifier/statementForMetavariable.js +105 -0
- package/src/verifier/termForVariable/consequence.js +9 -0
- package/src/verifier/termForVariable/supposition.js +9 -0
- package/src/verifier/termForVariable.js +89 -0
- package/src/verifier.js +74 -0
- package/src/verify/assertion/type.js +74 -74
- package/src/verify/axiom.js +2 -9
- package/src/verify/conclusion.js +1 -7
- package/src/verify/conjecture.js +67 -0
- package/src/verify/consequence.js +1 -7
- package/src/verify/declaration/combinator.js +0 -6
- package/src/verify/declaration/constructor.js +0 -6
- package/src/verify/declaration/topLevel.js +7 -6
- package/src/verify/declaration/type.js +0 -6
- package/src/verify/declaration/variable.js +0 -6
- package/src/verify/derivation.js +0 -12
- package/src/verify/label.js +0 -6
- package/src/verify/lemma.js +4 -11
- package/src/verify/metastatement/qualified.js +1 -8
- package/src/verify/metastatement/unqualified.js +1 -8
- package/src/verify/metastatement.js +0 -6
- package/src/verify/premise.js +1 -7
- package/src/verify/proof.js +1 -7
- package/src/verify/rule.js +2 -9
- package/src/verify/ruleDerivation.js +0 -12
- package/src/verify/ruleProof.js +1 -7
- package/src/verify/statement/qualified.js +54 -20
- package/src/verify/statement/unqualified.js +1 -8
- package/src/verify/statement.js +65 -95
- package/src/verify/statementAsCombinator.js +3 -9
- package/src/verify/supposition.js +1 -7
- package/src/verify/term.js +3 -21
- package/src/verify/termAsConstructor.js +5 -13
- package/src/verify/theorem.js +2 -9
- package/src/verify/type.js +4 -13
- package/src/verify/variable.js +4 -13
- package/bin/callbacks.js +0 -48
- package/lib/axiomLemmaTheorem.js +0 -190
- package/lib/callbacks.js +0 -75
- package/lib/context/release/combinator.js +0 -64
- package/lib/jsonTypes.js +0 -30
- package/lib/matcher/metastatementForMetavariable.js +0 -201
- package/lib/matcher/statementForMetavariable.js +0 -201
- package/lib/matcher/statementForVariable.js +0 -201
- package/lib/mixins/callbacks.js +0 -27
- package/lib/substitution/statementForVariable.js +0 -86
- package/lib/utilities/json.js +0 -187
- package/lib/utilities/substitution.js +0 -61
- package/lib/utilities/version.js +0 -32
- package/lib/versionChanges.js +0 -34
- package/src/callbacks.js +0 -39
- package/src/context/release/combinator.js +0 -39
- package/src/jsonTypes.js +0 -6
- package/src/matcher/metastatementForMetavariable/conclusion.js +0 -9
- package/src/matcher/metastatementForMetavariable/premise.js +0 -9
- package/src/matcher/metastatementForMetavariable.js +0 -99
- package/src/matcher/statementForMetavariable/conclusion.js +0 -9
- package/src/matcher/statementForMetavariable/premise.js +0 -9
- package/src/matcher/statementForMetavariable.js +0 -99
- package/src/matcher/statementForVariable/consequence.js +0 -9
- package/src/matcher/statementForVariable/supposition.js +0 -9
- package/src/matcher/statementForVariable.js +0 -99
- package/src/mixins/callbacks.js +0 -15
- package/src/substitution/statementForVariable.js +0 -64
- package/src/utilities/json.js +0 -264
- package/src/utilities/substitution.js +0 -79
- package/src/utilities/version.js +0 -30
- package/src/versionChanges.js +0 -11
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import Matcher from "../matcher";
|
|
4
|
-
import StatementForMetavariableSubstitution from "../substitution/statementForMetavariable";
|
|
5
|
-
|
|
6
|
-
import { first } from "../utilities/array";
|
|
7
|
-
import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
8
|
-
import { METAVARIABLE_RULE_NAME, METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
9
|
-
|
|
10
|
-
export default class StatementForMetavariableMatcher extends Matcher {
|
|
11
|
-
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
12
|
-
let nonTerminalNodeMatches = false;
|
|
13
|
-
|
|
14
|
-
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
15
|
-
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
16
|
-
nonTerminalNodeARuleNameMetastatementRuleName = (nonTerminalNodeARuleName === METASTATEMENT_RULE_NAME),
|
|
17
|
-
nonTerminalNodeBRuleNameStatementRuleName = (nonTerminalNodeBRuleName === STATEMENT_RULE_NAME);
|
|
18
|
-
|
|
19
|
-
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameStatementRuleName) {
|
|
20
|
-
const metastatementNodeA = nonTerminalNodeA, ///
|
|
21
|
-
statementNodeB = nonTerminalNodeB, ///
|
|
22
|
-
statementNodeMatches = this.matchStatementNode(metastatementNodeA, statementNodeB, substitutions);
|
|
23
|
-
|
|
24
|
-
if (statementNodeMatches) {
|
|
25
|
-
nonTerminalNodeMatches = true; ///
|
|
26
|
-
} else {
|
|
27
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
28
|
-
}
|
|
29
|
-
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
30
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return nonTerminalNodeMatches;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
matchStatementNode(metastatementNodeA, statementNodeB, substitutions) {
|
|
37
|
-
let statementNodeMatches = false;
|
|
38
|
-
|
|
39
|
-
const nonTerminalNodeA = metastatementNodeA, ///
|
|
40
|
-
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
41
|
-
nonTerminalNodeAChildNodesLength = nonTerminalNodeAChildNodes.length;
|
|
42
|
-
|
|
43
|
-
if (nonTerminalNodeAChildNodesLength === 1) {
|
|
44
|
-
const firstNonTerminalNodeAChildNode = first(nonTerminalNodeAChildNodes),
|
|
45
|
-
cChildNodeA = firstNonTerminalNodeAChildNode, ///
|
|
46
|
-
cChildNodeANonTerminalNode = cChildNodeA.isNonTerminalNode();
|
|
47
|
-
|
|
48
|
-
if (cChildNodeANonTerminalNode) {
|
|
49
|
-
const nonTerminalNodeA = cChildNodeA, ///
|
|
50
|
-
nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
51
|
-
nonTerminalNodeARuleNameMetavariableRuleName = (nonTerminalNodeARuleName === METAVARIABLE_RULE_NAME);
|
|
52
|
-
|
|
53
|
-
if (nonTerminalNodeARuleNameMetavariableRuleName) {
|
|
54
|
-
const metavariableNodeA = nonTerminalNodeA, ///
|
|
55
|
-
metaVariableNodeMatches = this.matchMetavariableNode(metavariableNodeA, statementNodeB, substitutions);
|
|
56
|
-
|
|
57
|
-
statementNodeMatches = metaVariableNodeMatches; ///
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return statementNodeMatches;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
matchMetavariableNode(metavariableNodeA, statementNodeB, substitutions) {
|
|
66
|
-
let metavariableNodeMatches;
|
|
67
|
-
|
|
68
|
-
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
69
|
-
substitution = substitutions.find((substitution) => {
|
|
70
|
-
const metavariableName = substitution.getMetavariableName();
|
|
71
|
-
|
|
72
|
-
if (metavariableName === metavariableNameA) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}) || null;
|
|
76
|
-
|
|
77
|
-
if (substitution !== null) {
|
|
78
|
-
const statementNode = statementNodeB, ///
|
|
79
|
-
substitutionNodesMatch = substitution.matchStatementNode(statementNode);
|
|
80
|
-
|
|
81
|
-
metavariableNodeMatches = substitutionNodesMatch; ///
|
|
82
|
-
} else {
|
|
83
|
-
const { createSubstitutions } = this.constructor;
|
|
84
|
-
|
|
85
|
-
if (createSubstitutions) {
|
|
86
|
-
const metavariableName = metavariableNameA, ///
|
|
87
|
-
statementNode = statementNodeB, ///
|
|
88
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNameAndStatementNode(metavariableName, statementNode),
|
|
89
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
90
|
-
|
|
91
|
-
substitutions.push(substitution);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
metavariableNodeMatches = true;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return metavariableNodeMatches;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import StatementForVariableMatcher from "../../matcher/statementForVariable";
|
|
4
|
-
|
|
5
|
-
class ConsequenceStatementForVariableMatcher extends StatementForVariableMatcher {
|
|
6
|
-
static createSubstitutions = false;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const consequenceStatementForVariableMatcher = new ConsequenceStatementForVariableMatcher();
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import StatementForVariableMatcher from "../../matcher/statementForVariable";
|
|
4
|
-
|
|
5
|
-
class SuppositionStatementForVariableMatcher extends StatementForVariableMatcher {
|
|
6
|
-
static createSubstitutions = true;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const suppositionStatementForVariableMatcher = new SuppositionStatementForVariableMatcher();
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import Matcher from "../matcher";
|
|
4
|
-
import StatementForVariableSubstitution from "../substitution/statementForVariable";
|
|
5
|
-
|
|
6
|
-
import { first } from "../utilities/array";
|
|
7
|
-
import { variableNameFromVariableNode } from "../utilities/query";
|
|
8
|
-
import { VARIABLE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
9
|
-
|
|
10
|
-
export default class StatementForVariableMatcher extends Matcher {
|
|
11
|
-
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
12
|
-
let nonTerminalNodeMatches = false;
|
|
13
|
-
|
|
14
|
-
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
15
|
-
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
16
|
-
nonTerminalNodeARuleNameMetastatementRuleName = (nonTerminalNodeARuleName === STATEMENT_RULE_NAME),
|
|
17
|
-
nonTerminalNodeBRuleNameMetastatementRuleName = (nonTerminalNodeBRuleName === STATEMENT_RULE_NAME);
|
|
18
|
-
|
|
19
|
-
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
|
|
20
|
-
const statementNodeA = nonTerminalNodeA, ///
|
|
21
|
-
statementNodeB = nonTerminalNodeB, ///
|
|
22
|
-
statementNodeMatches = this.matchStatementNode(statementNodeA, statementNodeB, substitutions);
|
|
23
|
-
|
|
24
|
-
if (statementNodeMatches) {
|
|
25
|
-
nonTerminalNodeMatches = true; ///
|
|
26
|
-
} else {
|
|
27
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
28
|
-
}
|
|
29
|
-
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
30
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return nonTerminalNodeMatches;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
matchStatementNode(statementNodeA, statementNodeB, substitutions) {
|
|
37
|
-
let statementNodeMatches = false;
|
|
38
|
-
|
|
39
|
-
const nonTerminalNodeA = statementNodeA, ///
|
|
40
|
-
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
41
|
-
nonTerminalNodeAChildNodesLength = nonTerminalNodeAChildNodes.length;
|
|
42
|
-
|
|
43
|
-
if (nonTerminalNodeAChildNodesLength === 1) {
|
|
44
|
-
const firstNonTerminalNodeAChildNode = first(nonTerminalNodeAChildNodes),
|
|
45
|
-
childNodeA = firstNonTerminalNodeAChildNode, ///
|
|
46
|
-
childNodeANonTerminalNode = childNodeA.isNonTerminalNode();
|
|
47
|
-
|
|
48
|
-
if (childNodeANonTerminalNode) {
|
|
49
|
-
const nonTerminalNodeA = childNodeA, ///
|
|
50
|
-
nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
51
|
-
nonTerminalNodeARuleNameVariableRuleName = (nonTerminalNodeARuleName === VARIABLE_RULE_NAME);
|
|
52
|
-
|
|
53
|
-
if (nonTerminalNodeARuleNameVariableRuleName) {
|
|
54
|
-
const variableNodeA = nonTerminalNodeA, ///
|
|
55
|
-
variableMatches = this.matchVariableNode(variableNodeA, statementNodeB, substitutions);
|
|
56
|
-
|
|
57
|
-
statementNodeMatches = variableMatches; ///
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return statementNodeMatches;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
matchVariableNode(variableNodeB, statementNodeB, substitutions) {
|
|
66
|
-
let variableMatches;
|
|
67
|
-
|
|
68
|
-
const variableNameA = variableNameFromVariableNode(variableNodeB),
|
|
69
|
-
substitution = substitutions.find((substitution) => {
|
|
70
|
-
const variableName = substitution.getVariableName();
|
|
71
|
-
|
|
72
|
-
if (variableName === variableNameA) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}) || null;
|
|
76
|
-
|
|
77
|
-
if (substitution !== null) {
|
|
78
|
-
const statementNode = statementNodeB, ///
|
|
79
|
-
substitutionNodesMatch = substitution.matchStatementNode(statementNode);
|
|
80
|
-
|
|
81
|
-
variableMatches = substitutionNodesMatch; ///
|
|
82
|
-
} else {
|
|
83
|
-
const { createSubstitutions } = this.constructor;
|
|
84
|
-
|
|
85
|
-
if (createSubstitutions) {
|
|
86
|
-
const variableName = variableNameA, ///
|
|
87
|
-
statementNode = statementNodeB, ///
|
|
88
|
-
statementForVariableSubstitution = StatementForVariableSubstitution.fromVariableNameAndStatementNode(variableName, statementNode),
|
|
89
|
-
substitution = statementForVariableSubstitution; ///
|
|
90
|
-
|
|
91
|
-
substitutions.push(substitution);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
variableMatches = true;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return variableMatches;
|
|
98
|
-
}
|
|
99
|
-
}
|
package/src/mixins/callbacks.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function halt(node) { this.context.halt(node); }
|
|
4
|
-
|
|
5
|
-
function begin(node) { this.context.begin(node); }
|
|
6
|
-
|
|
7
|
-
function complete(node) { this.context.complete(node); }
|
|
8
|
-
|
|
9
|
-
const callbacksMixins = {
|
|
10
|
-
halt,
|
|
11
|
-
begin,
|
|
12
|
-
complete
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default callbacksMixins;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { matcher } from "../matcher";
|
|
4
|
-
import { STATEMENT_RULE_NAME } from "../ruleNames";
|
|
5
|
-
import { bracketedNonTerminalChildNodeFromChildNodes } from "../utilities/substitution";
|
|
6
|
-
|
|
7
|
-
export default class StatementForVariableSubstitution {
|
|
8
|
-
constructor(variableName, statementNode) {
|
|
9
|
-
this.variableName = variableName;
|
|
10
|
-
this.statementNode = statementNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
getVariableName() {
|
|
14
|
-
return this.variableName;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getStatementNode() {
|
|
18
|
-
return this.statementNode;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
matchStatementNode(statementNode) {
|
|
22
|
-
let matchesStatementNode;
|
|
23
|
-
|
|
24
|
-
const nodeA = this.statementNode, ///
|
|
25
|
-
nodeB = statementNode,
|
|
26
|
-
nodeMatches = matcher.matchNode(nodeA, nodeB);
|
|
27
|
-
|
|
28
|
-
matchesStatementNode = nodeMatches; ///
|
|
29
|
-
|
|
30
|
-
if (!matchesStatementNode) {
|
|
31
|
-
const nonTerminalNode = statementNode, ///
|
|
32
|
-
childNodes = nonTerminalNode.getChildNodes(), ///
|
|
33
|
-
ruleName = STATEMENT_RULE_NAME;
|
|
34
|
-
|
|
35
|
-
statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
|
|
36
|
-
|
|
37
|
-
if (statementNode !== null) {
|
|
38
|
-
const nodeA = this.statementNode, ///
|
|
39
|
-
nodeB = statementNode,
|
|
40
|
-
nodeMatches = matchNode(nodeA, nodeB);
|
|
41
|
-
|
|
42
|
-
matchesStatementNode = nodeMatches; ///
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return matchesStatementNode;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static fromVariableNameAndStatementNode(variableName, statementNode) {
|
|
50
|
-
let statementForVariableSubstitution = new StatementForVariableSubstitution(variableName, statementNode);
|
|
51
|
-
|
|
52
|
-
const nonTerminalNode = statementNode, ///
|
|
53
|
-
childNodes = nonTerminalNode.getChildNodes(),
|
|
54
|
-
ruleName = STATEMENT_RULE_NAME;
|
|
55
|
-
|
|
56
|
-
statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
|
|
57
|
-
|
|
58
|
-
if (statementNode !== null) {
|
|
59
|
-
statementForVariableSubstitution = new StatementForVariableSubstitution(variableName, statementNode);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return statementForVariableSubstitution;
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/utilities/json.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
|
-
import { STRING, NUMBER, BOOLEAN } from "../constants";
|
|
6
|
-
import { NULL_JSON_TYPE, ARRAY_JSON_TYPE, OBJECT_JSON_TYPE, PRIMITIVE_JSON_TYPE } from "../jsonTypes";
|
|
7
|
-
import { BREAKING_VERSION_CHANGE, ADDITIVE_VERSION_CHANGE, COSMETIC_VERSION_CHANGE } from "../versionChanges";
|
|
8
|
-
|
|
9
|
-
const { first } = arrayUtilities;
|
|
10
|
-
|
|
11
|
-
function compareJSON(jsonA, jsonB) {
|
|
12
|
-
let result = BREAKING_VERSION_CHANGE;
|
|
13
|
-
|
|
14
|
-
const jsonAType = typeOf(jsonA),
|
|
15
|
-
jsonBType = typeOf(jsonB);
|
|
16
|
-
|
|
17
|
-
if (jsonAType === jsonBType) {
|
|
18
|
-
const jsonType = jsonAType; ///
|
|
19
|
-
|
|
20
|
-
switch (jsonType) {
|
|
21
|
-
case ARRAY_JSON_TYPE: {
|
|
22
|
-
const arrayA = jsonA, ///
|
|
23
|
-
arrayB = jsonB; ///
|
|
24
|
-
|
|
25
|
-
result = compareArrays(arrayA, arrayB);
|
|
26
|
-
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
case OBJECT_JSON_TYPE: {
|
|
31
|
-
const objectA = jsonA, ///
|
|
32
|
-
objectB = jsonB; ///
|
|
33
|
-
|
|
34
|
-
result = compareObjects(objectA, objectB);
|
|
35
|
-
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
case PRIMITIVE_JSON_TYPE: {
|
|
40
|
-
const primitiveA = jsonA, ///
|
|
41
|
-
primitiveB = jsonB; ///
|
|
42
|
-
|
|
43
|
-
result = comparePrimitives(primitiveA, primitiveB);
|
|
44
|
-
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default {
|
|
54
|
-
compareJSON
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function compareArrays(arrayA, arrayB) {
|
|
58
|
-
let result;
|
|
59
|
-
|
|
60
|
-
const arrayALength = arrayA.length,
|
|
61
|
-
arrayBLength = arrayB.length;
|
|
62
|
-
|
|
63
|
-
if (arrayALength === 0) {
|
|
64
|
-
if (arrayBLength === 0) {
|
|
65
|
-
result = COSMETIC_VERSION_CHANGE;
|
|
66
|
-
} else {
|
|
67
|
-
result = ADDITIVE_VERSION_CHANGE;
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
if (arrayBLength === 0) {
|
|
71
|
-
result = BREAKING_VERSION_CHANGE;
|
|
72
|
-
} else {
|
|
73
|
-
const firstElementA = first(arrayA), ///
|
|
74
|
-
elementA = firstElementA, ///
|
|
75
|
-
elementB = arrayB.find((elementB) => {
|
|
76
|
-
const jsonA = elementA, ///
|
|
77
|
-
jsonB = elementB, ///
|
|
78
|
-
result = compareJSON(jsonA, jsonB);
|
|
79
|
-
|
|
80
|
-
if (result === COSMETIC_VERSION_CHANGE) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
}) || null;
|
|
84
|
-
|
|
85
|
-
if (elementB !== null) {
|
|
86
|
-
arrayA = deleteElement(arrayA, elementA);
|
|
87
|
-
|
|
88
|
-
arrayB = deleteElement(arrayB, elementB);
|
|
89
|
-
|
|
90
|
-
result = compareArrays(arrayA, arrayB);
|
|
91
|
-
} else {
|
|
92
|
-
result = BREAKING_VERSION_CHANGE;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function compareObjects(objectA, objectB) {
|
|
101
|
-
let result;
|
|
102
|
-
|
|
103
|
-
const keysA = Object.keys(objectA),
|
|
104
|
-
keysB = Object.keys(objectB),
|
|
105
|
-
keysALength = keysA.length,
|
|
106
|
-
keysBLength = keysB.length;
|
|
107
|
-
|
|
108
|
-
if (keysALength === 0) {
|
|
109
|
-
if (keysBLength === 0) {
|
|
110
|
-
result = COSMETIC_VERSION_CHANGE;
|
|
111
|
-
} else {
|
|
112
|
-
result = ADDITIVE_VERSION_CHANGE;
|
|
113
|
-
}
|
|
114
|
-
} else {
|
|
115
|
-
if (keysBLength === 0) {
|
|
116
|
-
result = BREAKING_VERSION_CHANGE;
|
|
117
|
-
} else {
|
|
118
|
-
const firstKeyA = first(keysA), ///
|
|
119
|
-
keyA = firstKeyA, ///
|
|
120
|
-
keyB = keysB.find((keyB, index) => {
|
|
121
|
-
if (keyA === keyB) {
|
|
122
|
-
const valueA = objectA[keyA],
|
|
123
|
-
valueB = objectB[keyB],
|
|
124
|
-
jsonA = valueA, ///
|
|
125
|
-
jsonB = valueB, ///
|
|
126
|
-
result = compareJSON(jsonA, jsonB);
|
|
127
|
-
|
|
128
|
-
if (result === COSMETIC_VERSION_CHANGE) { ///
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}) || null;
|
|
133
|
-
|
|
134
|
-
if (keyB !== null) {
|
|
135
|
-
objectA = deleteKey(objectA, keyA);
|
|
136
|
-
|
|
137
|
-
objectB = deleteKey(objectB, keyB);
|
|
138
|
-
|
|
139
|
-
result = compareObjects(objectA, objectB);
|
|
140
|
-
} else {
|
|
141
|
-
result = BREAKING_VERSION_CHANGE;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return result;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function comparePrimitives(primitiveA, primitiveB) {
|
|
150
|
-
let result = BREAKING_VERSION_CHANGE;
|
|
151
|
-
|
|
152
|
-
if (primitiveA === primitiveB) {
|
|
153
|
-
result = COSMETIC_VERSION_CHANGE;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function typeOf(json) {
|
|
160
|
-
let type;
|
|
161
|
-
|
|
162
|
-
const _null = isNull(json),
|
|
163
|
-
array = isArray(json),
|
|
164
|
-
object = isObject(json),
|
|
165
|
-
primitive = isPrimitive(json);
|
|
166
|
-
|
|
167
|
-
if (_null) {
|
|
168
|
-
type = NULL_JSON_TYPE;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (array) {
|
|
172
|
-
type = ARRAY_JSON_TYPE;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (object) {
|
|
176
|
-
type = OBJECT_JSON_TYPE;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (primitive) {
|
|
180
|
-
type = PRIMITIVE_JSON_TYPE;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return type;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function isNull(json) {
|
|
187
|
-
const _null = (json === null);
|
|
188
|
-
|
|
189
|
-
return _null;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function isArray(json) {
|
|
193
|
-
const array = Array.isArray(json);
|
|
194
|
-
|
|
195
|
-
return array;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function isObject(json) {
|
|
199
|
-
const array = isArray(json),
|
|
200
|
-
primitive = isPrimitive(json),
|
|
201
|
-
object = (!array && !primitive);
|
|
202
|
-
|
|
203
|
-
return object;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function isString(json) {
|
|
207
|
-
const string = ((typeof json) === STRING);
|
|
208
|
-
|
|
209
|
-
return string;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function isNumber(json) {
|
|
213
|
-
const number = ((typeof json) === NUMBER);
|
|
214
|
-
|
|
215
|
-
return number;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function isBoolean(json) {
|
|
219
|
-
const boolean = ((typeof json) === BOOLEAN);
|
|
220
|
-
|
|
221
|
-
return boolean;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function isPrimitive(json) {
|
|
225
|
-
const _null = isNull(json),
|
|
226
|
-
string = isString(json),
|
|
227
|
-
number = isNumber(json),
|
|
228
|
-
boolean = isBoolean(json),
|
|
229
|
-
primitive = (_null || string || number || boolean);
|
|
230
|
-
|
|
231
|
-
return primitive;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function deleteElement(array, element) {
|
|
235
|
-
const deletedElement = element; ///
|
|
236
|
-
|
|
237
|
-
array = array.reduce((array, element) => { ///
|
|
238
|
-
if (element !== deletedElement) {
|
|
239
|
-
array.push(element);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return array;
|
|
243
|
-
}, []);
|
|
244
|
-
|
|
245
|
-
return array;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function deleteKey(object, key) {
|
|
249
|
-
const deletedKey = key, ///
|
|
250
|
-
keys = Object.keys(object),
|
|
251
|
-
values = Object.values(object);
|
|
252
|
-
|
|
253
|
-
object = keys.reduce((object, key, index) => { ///
|
|
254
|
-
if (key !== deletedKey) {
|
|
255
|
-
const value = values[index];
|
|
256
|
-
|
|
257
|
-
object[key] = value;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return object;
|
|
261
|
-
}, {});
|
|
262
|
-
|
|
263
|
-
return object;
|
|
264
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { matcher } from "../matcher";
|
|
4
|
-
import { first, second, third } from "../utilities/array";
|
|
5
|
-
import { METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
6
|
-
import { BRACKETED_CHILD_NODES_LENGTH, LEFT_BRACKET, RIGHT_BRACKET } from "../constants";
|
|
7
|
-
|
|
8
|
-
export function matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB) {
|
|
9
|
-
let bracketedNodeMatches = false;
|
|
10
|
-
|
|
11
|
-
if (!bracketedNodeMatches) {
|
|
12
|
-
const nonTerminalNodeMatches = matcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB);
|
|
13
|
-
|
|
14
|
-
bracketedNodeMatches = nonTerminalNodeMatches; ///
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (!bracketedNodeMatches) {
|
|
18
|
-
const nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
19
|
-
childNodesA = nonTerminalNodeAChildNodes, ///
|
|
20
|
-
bracketedNonTerminalChildNodeA = bracketedNonTerminalChildNodeFromChildNodes(childNodesA);
|
|
21
|
-
|
|
22
|
-
if (bracketedNonTerminalChildNodeA !== null) {
|
|
23
|
-
const nodeA = bracketedNonTerminalChildNodeA, ///
|
|
24
|
-
nodeB = nonTerminalNodeB, ///
|
|
25
|
-
nodeMatches = matcher.matchNode(nodeA, nodeB);
|
|
26
|
-
|
|
27
|
-
bracketedNodeMatches = nodeMatches; ///
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!bracketedNodeMatches) {
|
|
32
|
-
const nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
33
|
-
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
34
|
-
bracketedNonTerminalChildNodeB = bracketedNonTerminalChildNodeFromChildNodes(childNodesB);
|
|
35
|
-
|
|
36
|
-
if (bracketedNonTerminalChildNodeB !== null) {
|
|
37
|
-
const nodeB = bracketedNonTerminalChildNodeB, ///
|
|
38
|
-
nodeA = nonTerminalNodeA, ///
|
|
39
|
-
nodeMatches = matchNode(nodeA, nodeB);
|
|
40
|
-
|
|
41
|
-
bracketedNodeMatches = nodeMatches; ///
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return bracketedNodeMatches;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName = METASTATEMENT_RULE_NAME) {
|
|
49
|
-
let bracketedNonTerminalChildNode = null;
|
|
50
|
-
|
|
51
|
-
const childNodesLength = childNodes.length;
|
|
52
|
-
|
|
53
|
-
if (childNodesLength === BRACKETED_CHILD_NODES_LENGTH) {
|
|
54
|
-
const firstChildNode = first(childNodes),
|
|
55
|
-
thirdChildNode = third(childNodes),
|
|
56
|
-
secondChildNode = second(childNodes),
|
|
57
|
-
firstChildNodeTerminalNode = firstChildNode.isTerminalNode(),
|
|
58
|
-
thirdChildNodeTerminalNode = thirdChildNode.isTerminalNode(),
|
|
59
|
-
secondChildNodeNonTerminalNode = secondChildNode.isNonTerminalNode();
|
|
60
|
-
|
|
61
|
-
if (firstChildNodeTerminalNode && secondChildNodeNonTerminalNode && thirdChildNodeTerminalNode) {
|
|
62
|
-
const nonTerminalNode = secondChildNode, ///
|
|
63
|
-
firstTerminalNode = firstChildNode, ///
|
|
64
|
-
secondTerminalNode = thirdChildNode, ///
|
|
65
|
-
nonTerminalNodeRuleName = nonTerminalNode.getRuleName(),
|
|
66
|
-
firstTerminalNodeContent = firstTerminalNode.getContent(),
|
|
67
|
-
secondTerminalNodeContent = secondTerminalNode.getContent(),
|
|
68
|
-
nonTerminalNodeRuleNameRuleName = (nonTerminalNodeRuleName === ruleName),
|
|
69
|
-
firstTerminalNodeContentLeftBracket = (firstTerminalNodeContent === LEFT_BRACKET),
|
|
70
|
-
secondTerminalNodeContentRightBracket = (secondTerminalNodeContent === RIGHT_BRACKET);
|
|
71
|
-
|
|
72
|
-
if (nonTerminalNodeRuleNameRuleName && firstTerminalNodeContentLeftBracket && secondTerminalNodeContentRightBracket) {
|
|
73
|
-
bracketedNonTerminalChildNode = nonTerminalNode; ///
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return bracketedNonTerminalChildNode;
|
|
79
|
-
}
|
package/src/utilities/version.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { BREAKING_VERSION_CHANGE, ADDITIVE_VERSION_CHANGE, COSMETIC_VERSION_CHANGE } from "../versionChanges";
|
|
4
|
-
|
|
5
|
-
function updateVersion(version, versionChange) {
|
|
6
|
-
switch (versionChange) {
|
|
7
|
-
case BREAKING_VERSION_CHANGE:
|
|
8
|
-
version.bumpMajorNumber();
|
|
9
|
-
version.resetMinorNumber();
|
|
10
|
-
version.resetPatchNumber();
|
|
11
|
-
|
|
12
|
-
break;
|
|
13
|
-
|
|
14
|
-
case ADDITIVE_VERSION_CHANGE:
|
|
15
|
-
version.bumpMinorNumber();
|
|
16
|
-
version.resetPatchNumber();
|
|
17
|
-
|
|
18
|
-
break;
|
|
19
|
-
|
|
20
|
-
case COSMETIC_VERSION_CHANGE:
|
|
21
|
-
version.bumpPatchNumber();
|
|
22
|
-
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default {
|
|
28
|
-
updateVersion
|
|
29
|
-
};
|
|
30
|
-
|
package/src/versionChanges.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
export const BREAKING_VERSION_CHANGE = "breaking";
|
|
4
|
-
export const ADDITIVE_VERSION_CHANGE = "additive";
|
|
5
|
-
export const COSMETIC_VERSION_CHANGE = "cosmetic";
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
BREAKING_VERSION_CHANGE,
|
|
9
|
-
ADDITIVE_VERSION_CHANGE,
|
|
10
|
-
COSMETIC_VERSION_CHANGE
|
|
11
|
-
};
|