occam-verify-cli 0.0.983 → 0.0.985
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/lib/constructor/bracketed.js +2 -2
- package/lib/node/statement/combinator/bracketed.js +3 -3
- package/lib/node/term/constructor/bracketed.js +3 -3
- package/lib/ocmbinator/bracketed.js +2 -2
- package/lib/ruleNames.js +7 -7
- package/lib/substitution/frameForMetavariable.js +7 -11
- package/lib/substitution/statementForMetavariable.js +6 -21
- package/lib/tokens/combinatorFrame/bracketed.js +17 -0
- package/lib/tokens/combinatorStatement/bracketed.js +17 -0
- package/lib/tokens/constructorTerm/bracketed.js +17 -0
- package/lib/unifier/metaLevel.js +16 -7
- package/lib/unify/metavariableWithFrame.js +39 -0
- package/lib/utilities/node.js +12 -22
- package/lib/utilities/tokens.js +11 -11
- package/lib/utilities/unify.js +20 -6
- package/lib/verify/assertion/contained.js +37 -34
- package/lib/verify/assertion/defined.js +27 -35
- package/lib/verify/frame.js +2 -3
- package/package.json +4 -4
- package/src/constructor/bracketed.js +1 -1
- package/src/node/statement/combinator/bracketed.js +3 -3
- package/src/node/term/constructor/bracketed.js +3 -3
- package/src/ocmbinator/bracketed.js +2 -2
- package/src/ruleNames.js +2 -2
- package/src/substitution/frameForMetavariable.js +10 -15
- package/src/substitution/statementForMetavariable.js +5 -21
- package/src/tokens/combinatorFrame/bracketed.js +10 -0
- package/src/tokens/combinatorStatement/bracketed.js +10 -0
- package/src/tokens/constructorTerm/bracketed.js +10 -0
- package/src/unifier/metaLevel.js +22 -7
- package/src/unify/metavariableWithFrame.js +38 -0
- package/src/utilities/node.js +14 -30
- package/src/utilities/tokens.js +8 -10
- package/src/utilities/unify.js +25 -6
- package/src/verify/assertion/contained.js +48 -45
- package/src/verify/assertion/defined.js +31 -45
- package/src/verify/frame.js +3 -4
- package/lib/tokens/constructorDeclaration/bracketed.js +0 -17
- package/lib/tokens/unqualifiedStatement/combinator/bracketed.js +0 -17
- package/src/tokens/constructorDeclaration/bracketed.js +0 -10
- package/src/tokens/unqualifiedStatement/combinator/bracketed.js +0 -10
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import bracketedConstructorTermTokens from "../../../tokens/constructorTerm/bracketed";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { termNodeFromTermTokens } from "../../../utilities/node";
|
|
6
6
|
|
|
7
|
-
const bracketedConstructorTermNode =
|
|
7
|
+
const bracketedConstructorTermNode = termNodeFromTermTokens(bracketedConstructorTermTokens);
|
|
8
8
|
|
|
9
9
|
export default bracketedConstructorTermNode;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import Combinator from "../combinator";
|
|
4
4
|
import bracketedCombinatorStatementNode from "../node/statement/combinator/bracketed";
|
|
5
|
-
import
|
|
5
|
+
import bracketedCombinatorStatementTokens from "../tokens/combinatorStatement/bracketed";
|
|
6
6
|
|
|
7
7
|
import { nodeAsString } from "../utilities/string";
|
|
8
8
|
|
|
9
9
|
class BracketedCombinator extends Combinator {
|
|
10
10
|
static fromNothing() {
|
|
11
11
|
const node = bracketedCombinatorStatementNode, ///
|
|
12
|
-
tokens =
|
|
12
|
+
tokens = bracketedCombinatorStatementTokens, ///
|
|
13
13
|
string = nodeAsString(node, tokens),
|
|
14
14
|
statementNode = node, ///
|
|
15
15
|
bracketedCombinator = new BracketedCombinator(statementNode, string);
|
package/src/ruleNames.js
CHANGED
|
@@ -4,10 +4,10 @@ import Substitution from "../substitution";
|
|
|
4
4
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
import { stripBracketsFromFrame } from "../utilities/brackets";
|
|
8
7
|
|
|
9
8
|
const frameNodeQuery = nodeQuery("/substitution/frame!"),
|
|
10
|
-
|
|
9
|
+
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
10
|
+
substitutionMetavariableNodeQuery = nodeQuery("/substitution/metavariable!");
|
|
11
11
|
|
|
12
12
|
export default class FrameForMetavariableSubstitution extends Substitution {
|
|
13
13
|
constructor(frameNode, metavariableNode, substitution) {
|
|
@@ -60,8 +60,6 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
matchFrameNode(frameNode) {
|
|
63
|
-
frameNode = stripBracketsFromFrame(frameNode); ///
|
|
64
|
-
|
|
65
63
|
const frameNodeMatches = this.frameNode.match(frameNode);
|
|
66
64
|
|
|
67
65
|
return frameNodeMatches;
|
|
@@ -101,13 +99,12 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
101
99
|
static fromSubstitutionNode(substitutionNode) {
|
|
102
100
|
let frameForMetavariableSubstitution = null;
|
|
103
101
|
|
|
104
|
-
let frameNode = frameNodeQuery(substitutionNode)
|
|
105
|
-
metavariableNode = metavariableNodeQuery(substitutionNode);
|
|
102
|
+
let frameNode = frameNodeQuery(substitutionNode);
|
|
106
103
|
|
|
107
104
|
if (frameNode !== null) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
const substitutionMetavariableNode = substitutionMetavariableNodeQuery(substitutionNode),
|
|
106
|
+
metavariableNode = substitutionMetavariableNode, ///
|
|
107
|
+
substitution = null;
|
|
111
108
|
|
|
112
109
|
frameForMetavariableSubstitution = new FrameForMetavariableSubstitution(frameNode, metavariableNode, substitution);
|
|
113
110
|
}
|
|
@@ -116,8 +113,6 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
116
113
|
}
|
|
117
114
|
|
|
118
115
|
static fromFrameNodeAndMetavariableNode(frameNode, metavariableNode) {
|
|
119
|
-
frameNode = stripBracketsFromFrame(frameNode); ///
|
|
120
|
-
|
|
121
116
|
const substitution = null,
|
|
122
117
|
frameForMetavariableSubstitution = new FrameForMetavariableSubstitution(frameNode, metavariableNode, substitution);
|
|
123
118
|
|
|
@@ -125,8 +120,6 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
125
120
|
}
|
|
126
121
|
|
|
127
122
|
static fromFrameNodeMetavariableNodeAndSubstitutionNode(frameNode, metavariableNode, substitutionNode) {
|
|
128
|
-
frameNode = stripBracketsFromFrame(frameNode); ///
|
|
129
|
-
|
|
130
123
|
const substitution = substitutionFromSubstitutionNode(substitutionNode),
|
|
131
124
|
frameForMetavariableSubstitution = new FrameForMetavariableSubstitution(frameNode, metavariableNode, substitution);
|
|
132
125
|
|
|
@@ -159,9 +152,11 @@ function substitutionFromSubstitutionNode(substitutionNode) {
|
|
|
159
152
|
function transformFrameNode(frameNode, substitutions) {
|
|
160
153
|
let transformedFrameNode = null;
|
|
161
154
|
|
|
162
|
-
const
|
|
155
|
+
const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
|
|
156
|
+
|
|
157
|
+
if (frameMetavariableNode !== null) {
|
|
158
|
+
const metavariableNode = frameMetavariableNode; ///
|
|
163
159
|
|
|
164
|
-
if (metavariableNode !== null) {
|
|
165
160
|
substitutions.someSubstitution((substitution) => {
|
|
166
161
|
const substitutionMatchesVariableNode = substitution.matchMetavariableNode(metavariableNode);
|
|
167
162
|
|
|
@@ -7,8 +7,7 @@ import FrameForMetavariableSubstitution from "../substitution/frameForMetavariab
|
|
|
7
7
|
import { nodeQuery } from "../utilities/query";
|
|
8
8
|
import { stripBracketsFromStatement } from "../utilities/brackets";
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
metavariableNodeQuery = nodeQuery("/*/metavariable!");
|
|
10
|
+
const statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
12
11
|
|
|
13
12
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
14
13
|
constructor(statementNode, metavariableNode, substitution) {
|
|
@@ -99,23 +98,6 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
99
98
|
return string;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
// static fromSubstitutionNode(substitutionNode) {
|
|
103
|
-
// let statementForMetavariableSubstitution = null;
|
|
104
|
-
//
|
|
105
|
-
// let statementNode = statementNodeQuery(substitutionNode),
|
|
106
|
-
// metavariableNode = metavariableNodeQuery(substitutionNode);
|
|
107
|
-
//
|
|
108
|
-
// if (statementNode !== null) {
|
|
109
|
-
// statementNode = stripBracketsFromStatement(statementNode); ///
|
|
110
|
-
//
|
|
111
|
-
// const substitution = null;
|
|
112
|
-
//
|
|
113
|
-
// statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode, substitution);
|
|
114
|
-
// }
|
|
115
|
-
//
|
|
116
|
-
// return statementForMetavariableSubstitution;
|
|
117
|
-
// }
|
|
118
|
-
|
|
119
101
|
static fromStatementNodeAndMetavariableNode(statementNode, metavariableNode) {
|
|
120
102
|
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
121
103
|
|
|
@@ -160,9 +142,11 @@ function substitutionFromSubstitutionNode(substitutionNode) {
|
|
|
160
142
|
function transformStatementNode(statementNode, substitutions) {
|
|
161
143
|
let transformedStatementNode = null;
|
|
162
144
|
|
|
163
|
-
const
|
|
145
|
+
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
|
|
146
|
+
|
|
147
|
+
if (statementMetavariableNode !== null) {
|
|
148
|
+
const metavariableNode = statementMetavariableNode; ///
|
|
164
149
|
|
|
165
|
-
if (metavariableNode !== null) {
|
|
166
150
|
substitutions.someSubstitution((substitution) => {
|
|
167
151
|
const substitutionMatchesVariableNode = substitution.matchMetavariableNode(metavariableNode);
|
|
168
152
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { FRAME_META_TYPE_NAME } from "../../metaTypeNames";
|
|
4
|
+
import { fromTokensFromFrameString } from "../../utilities/tokens";
|
|
5
|
+
|
|
6
|
+
const bracketedCombinatorFrameString = `(${FRAME_META_TYPE_NAME})`;
|
|
7
|
+
|
|
8
|
+
const bracketedCombinatorFrameTokens = fromTokensFromFrameString(bracketedCombinatorFrameString)
|
|
9
|
+
|
|
10
|
+
export default bracketedCombinatorFrameTokens;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { STATEMENT_META_TYPE_NAME } from "../../metaTypeNames";
|
|
4
|
+
import { statementTokensFromStatementString } from "../../utilities/tokens";
|
|
5
|
+
|
|
6
|
+
const bracketedCombinatorStatementString = `(${STATEMENT_META_TYPE_NAME})`;
|
|
7
|
+
|
|
8
|
+
const bracketedCombinatorStatementTokens = statementTokensFromStatementString(bracketedCombinatorStatementString)
|
|
9
|
+
|
|
10
|
+
export default bracketedCombinatorStatementTokens;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { OBJECT_TYPE_NAME } from "../../typeNames";
|
|
4
|
+
import { termTokensFromTermString } from "../../utilities/tokens";
|
|
5
|
+
|
|
6
|
+
const bracketedConstructorTermString = `(${OBJECT_TYPE_NAME})`;
|
|
7
|
+
|
|
8
|
+
const bracketedConstructorDeclarationTokens = termTokensFromTermString(bracketedConstructorTermString)
|
|
9
|
+
|
|
10
|
+
export default bracketedConstructorDeclarationTokens;
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Unifier from "../unifier";
|
|
5
5
|
import unifyVariableWithTerm from "../unify/variableWithTerm";
|
|
6
|
+
import unifyMetavariableWithFrame from "../unify/metavariableWithFrame";
|
|
6
7
|
import unifyMetavariableWithStatement from "../unify/metavariableWithStatement";
|
|
7
8
|
import unifyMetavariableWithStatementGivenSubstitution from "../unify/metavariableWithStatementGivenSubstitution";
|
|
8
9
|
|
|
9
10
|
import { nodeQuery } from "../utilities/query";
|
|
10
11
|
|
|
11
12
|
const termNodeQuery = nodeQuery("/term!"),
|
|
13
|
+
frameNodeQuery = nodeQuery("/frame!"),
|
|
12
14
|
statementNodeQuery = nodeQuery("/statement!"),
|
|
13
15
|
termVariableNodeQuery = nodeQuery("/term/variable!"),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
17
|
+
statementSubstitutionNodeQuery = nodeQuery("/statement/substitution!"),
|
|
18
|
+
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
16
19
|
|
|
17
20
|
class MetaLevelUnifier extends Unifier {
|
|
18
21
|
unify(nodeA, nodeB, substitutions, localContextA, localContextB) {
|
|
@@ -34,17 +37,19 @@ class MetaLevelUnifier extends Unifier {
|
|
|
34
37
|
unify: (statementNodeA, statementNodeB, substitutions, localContextA, localContextB) => {
|
|
35
38
|
let statementUnifiedWithStatement;
|
|
36
39
|
|
|
37
|
-
const
|
|
40
|
+
const statementMetavariableNodeA = statementMetavariableNodeQuery(statementNodeA);
|
|
38
41
|
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
42
|
+
if (statementMetavariableNodeA !== null) {
|
|
43
|
+
const metavariableNodeA = statementMetavariableNodeA, ///
|
|
44
|
+
statementSubstitutionNodeA = statementSubstitutionNodeQuery(statementNodeA);
|
|
41
45
|
|
|
42
|
-
if (
|
|
46
|
+
if (statementSubstitutionNodeA === null) {
|
|
43
47
|
const metavariableUnifiedWithStatement = unifyMetavariableWithStatement(metavariableNodeA, statementNodeB, substitutions, localContextA, localContextB);
|
|
44
48
|
|
|
45
49
|
statementUnifiedWithStatement = metavariableUnifiedWithStatement; ///
|
|
46
50
|
} else {
|
|
47
|
-
const
|
|
51
|
+
const substitutionNodeA = statementSubstitutionNodeA, ///
|
|
52
|
+
metavariableUnifiedWithStatementGivenSubstitution = unifyMetavariableWithStatementGivenSubstitution(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB);
|
|
48
53
|
|
|
49
54
|
statementUnifiedWithStatement = metavariableUnifiedWithStatementGivenSubstitution; ///
|
|
50
55
|
}
|
|
@@ -63,6 +68,16 @@ class MetaLevelUnifier extends Unifier {
|
|
|
63
68
|
return statementUnifiedWithStatement;
|
|
64
69
|
}
|
|
65
70
|
},
|
|
71
|
+
{
|
|
72
|
+
nodeQueryA: frameMetavariableNodeQuery,
|
|
73
|
+
nodeQueryB: frameNodeQuery,
|
|
74
|
+
unify: (frameMetavariableNodeA, frameNodeB, substitutions, localContextA, localContextB) => {
|
|
75
|
+
const metavariableNodeA = frameMetavariableNodeA, ///
|
|
76
|
+
metavariableUnifiedWithFrame = unifyMetavariableWithFrame(metavariableNodeA, frameNodeB, substitutions, localContextA, localContextB);
|
|
77
|
+
|
|
78
|
+
return metavariableUnifiedWithFrame;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
66
81
|
{
|
|
67
82
|
nodeQueryA: termVariableNodeQuery,
|
|
68
83
|
nodeQueryB: termNodeQuery,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
|
|
4
|
+
|
|
5
|
+
import { metavariableFromFrameNode } from "../utilities/unify";
|
|
6
|
+
|
|
7
|
+
export default function unifyMetavariableWithFrame(metavariableNodeA, frameNodeB, substitutions, localContextA, localContextB) {
|
|
8
|
+
let metavariableUnifiedWithFrame = false;
|
|
9
|
+
|
|
10
|
+
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNodeA),
|
|
11
|
+
substitution = simpleSubstitution; ///
|
|
12
|
+
|
|
13
|
+
if (substitution !== null) {
|
|
14
|
+
const frameNodeMatches = substitution.matchFrameNode(frameNodeB);
|
|
15
|
+
|
|
16
|
+
if (frameNodeMatches) {
|
|
17
|
+
metavariableUnifiedWithFrame = true;
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
const metavariableA = localContextA.findMetavariableByMetavariableNode(metavariableNodeA),
|
|
21
|
+
metavariableB = metavariableFromFrameNode(frameNodeB, localContextB);
|
|
22
|
+
|
|
23
|
+
if (metavariableA === metavariableB) {
|
|
24
|
+
metavariableUnifiedWithFrame = true;
|
|
25
|
+
} else {
|
|
26
|
+
const frameNode = frameNodeB, ///
|
|
27
|
+
metavariableNode = metavariableNodeA, ///
|
|
28
|
+
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameNodeAndMetavariableNode(frameNode, metavariableNode),
|
|
29
|
+
substitution = frameForMetavariableSubstitution; ///
|
|
30
|
+
|
|
31
|
+
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
32
|
+
|
|
33
|
+
metavariableUnifiedWithFrame = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return metavariableUnifiedWithFrame;
|
|
38
|
+
}
|
package/src/utilities/node.js
CHANGED
|
@@ -2,61 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
import { parsersUtilities } from "occam-custom-grammars";
|
|
4
4
|
|
|
5
|
-
import { nodeQuery } from "../utilities/query";
|
|
6
5
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { TERM_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
7
|
+
import { termTokensFromTermString, statementTokensFromStatementString } from "../utilities/tokens";
|
|
9
8
|
|
|
10
9
|
const { florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
11
10
|
|
|
12
11
|
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
13
12
|
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
14
13
|
|
|
15
|
-
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
16
|
-
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!");
|
|
17
|
-
|
|
18
14
|
export function termNodeFromTermString(termString, lexer, parser) {
|
|
19
|
-
const
|
|
20
|
-
termNode =
|
|
15
|
+
const termTokens = termTokensFromTermString(termString, lexer),
|
|
16
|
+
termNode = termNodeFromTermTokens(termTokens, parser);
|
|
21
17
|
|
|
22
18
|
return termNode;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
export function statementNodeFromStatementString(statementString, lexer, parser) {
|
|
26
|
-
const
|
|
27
|
-
statementNode =
|
|
22
|
+
const statementTokens = statementTokensFromStatementString(statementString, lexer),
|
|
23
|
+
statementNode = statementNodeFromStatementTokens(statementTokens, parser);
|
|
28
24
|
|
|
29
25
|
return statementNode;
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
export function
|
|
33
|
-
const
|
|
34
|
-
|
|
28
|
+
export function termNodeFromTermTokens(termTokens, parser) {
|
|
29
|
+
const tokens = termTokens, ///
|
|
30
|
+
ruleName = TERM_RULE_NAME,
|
|
31
|
+
termNode = nodeFromTokensRuleNameAndParser(tokens, ruleName, parser);
|
|
35
32
|
|
|
36
33
|
return termNode;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
export function
|
|
40
|
-
const
|
|
41
|
-
|
|
36
|
+
export function statementNodeFromStatementTokens(statementTokens, parser) {
|
|
37
|
+
const tokens = statementTokens, ///
|
|
38
|
+
ruleName = STATEMENT_RULE_NAME,
|
|
39
|
+
statementNode = nodeFromTokensRuleNameAndParser(tokens, ruleName, parser);
|
|
42
40
|
|
|
43
41
|
return statementNode;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser) {
|
|
47
|
-
const ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
48
|
-
unqualifiedStatementNode = nodeFromTokensRuleNameAndParser(unqualifiedStatementTokens, ruleName, parser);
|
|
49
|
-
|
|
50
|
-
return unqualifiedStatementNode;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function constructorDeclarationNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser) {
|
|
54
|
-
const ruleName = CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
55
|
-
constructorDeclarationNode = nodeFromTokensRuleNameAndParser(constructorDeclarationTokens, ruleName, parser);
|
|
56
|
-
|
|
57
|
-
return constructorDeclarationNode;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
44
|
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser = florenceParser) {
|
|
61
45
|
const ruleMap = parser.getRuleMap(),
|
|
62
46
|
rule = ruleMap[ruleName],
|
package/src/utilities/tokens.js
CHANGED
|
@@ -9,20 +9,18 @@ const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities;
|
|
|
9
9
|
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
10
10
|
florenceLexer = florenceLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
11
11
|
|
|
12
|
-
export function
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
constructorDeclarationTokens = tokensFromContentAndLexer(constructorDeclarationContent, lexer);
|
|
12
|
+
export function termTokensFromTermString(termString, lexer) {
|
|
13
|
+
const content = termString, ///
|
|
14
|
+
termTokens = tokensFromContentAndLexer(content, lexer);
|
|
16
15
|
|
|
17
|
-
return
|
|
16
|
+
return termTokens;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export function
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
unqualifiedStatementTokens = tokensFromContentAndLexer(unqualifiedStatementContent, lexer);
|
|
19
|
+
export function statementTokensFromStatementString(statementString, lexer) {
|
|
20
|
+
const content = statementString, ///
|
|
21
|
+
statementTokens = tokensFromContentAndLexer(content, lexer);
|
|
24
22
|
|
|
25
|
-
return
|
|
23
|
+
return statementTokens;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
function tokensFromContentAndLexer(content, lexer = florenceLexer) {
|
package/src/utilities/unify.js
CHANGED
|
@@ -2,27 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
import { nodeQuery } from "../utilities/query";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const termVariableNodeQuery = nodeQuery("/term/variable"),
|
|
6
|
+
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable"),
|
|
7
|
+
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable");
|
|
7
8
|
|
|
8
9
|
export function variableFromTermNode(termNode, localContext) {
|
|
9
10
|
let variable = null;
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const termVariableNode = termVariableNodeQuery(termNode);
|
|
13
|
+
|
|
14
|
+
if (termVariableNode !== null) {
|
|
15
|
+
const variableNode = termVariableNode; ///
|
|
12
16
|
|
|
13
|
-
if (variableNode !== null) {
|
|
14
17
|
variable = localContext.findVariableByVariableNode(variableNode);
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
return variable;
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
export function metavariableFromFrameNode(frameNode, localContext) {
|
|
24
|
+
let metavariable = null;
|
|
25
|
+
|
|
26
|
+
const frameMetavariableNode = frameMetavariableNodeQuery(frameNode)
|
|
27
|
+
|
|
28
|
+
if (frameMetavariableNode !== null) {
|
|
29
|
+
const metavariableNode = frameMetavariableNode; ///
|
|
30
|
+
|
|
31
|
+
metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return metavariable;
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
export function metavariableFromStatementNode(statementNode, localContext) {
|
|
21
38
|
let metavariable = null;
|
|
22
39
|
|
|
23
|
-
const
|
|
40
|
+
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode)
|
|
41
|
+
|
|
42
|
+
if (statementMetavariableNode !== null) {
|
|
43
|
+
const metavariableNode = statementMetavariableNode; ///
|
|
24
44
|
|
|
25
|
-
if (metavariableNode !== null) {
|
|
26
45
|
metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
27
46
|
}
|
|
28
47
|
|
|
@@ -6,9 +6,9 @@ import { isAssertionNegated } from "../../utilities/assertion";
|
|
|
6
6
|
import { nodeQuery, nodesQuery } from "../../utilities/query";
|
|
7
7
|
|
|
8
8
|
const variableNodeQuery = nodeQuery("/containedAssertion/term/variable!"),
|
|
9
|
-
metavariableNodeQuery = nodeQuery("/containedAssertion/frame
|
|
10
|
-
statementVariableNodesQuery = nodesQuery("/containedAssertion/statement
|
|
11
|
-
statementMetavariableNodesQuery = nodesQuery("/containedAssertion/statement
|
|
9
|
+
metavariableNodeQuery = nodeQuery("/containedAssertion/frame/metavariable!"),
|
|
10
|
+
statementVariableNodesQuery = nodesQuery("/containedAssertion/statement//variable"),
|
|
11
|
+
statementMetavariableNodesQuery = nodesQuery("/containedAssertion/statement//metavariable");
|
|
12
12
|
|
|
13
13
|
const verifyContainedAssertionFunctions = [
|
|
14
14
|
verifyDerivedContainedAssertion,
|
|
@@ -56,53 +56,56 @@ function verifyDerivedContainedAssertion(containedAssertionNode, assignments, st
|
|
|
56
56
|
|
|
57
57
|
localContext.trace(`Verifying the '${containedAssertionString}' derived contained assertion...`, containedAssertionNode);
|
|
58
58
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
const metavariableNode = metavariableNodeQuery(containedAssertionNode);
|
|
60
|
+
|
|
61
|
+
if (metavariableNode !== null) {
|
|
62
|
+
const assertionNegated = isAssertionNegated(containedAssertionNode),
|
|
63
|
+
variableNode = variableNodeQuery(containedAssertionNode),
|
|
64
|
+
negated = assertionNegated; ///
|
|
65
|
+
|
|
66
|
+
if (false) {
|
|
67
|
+
///
|
|
68
|
+
} else if (metavariableNode !== null) {
|
|
69
|
+
const statementMetavariableNodes = statementMetavariableNodesQuery(containedAssertionNode),
|
|
70
|
+
variableNodeMatchesStatementMetavariableNode = statementMetavariableNodes.some((statementMetavariableNode) => {
|
|
71
|
+
const variableNodeMatchesStatementMetavariableNode = metavariableNode.match(statementMetavariableNode);
|
|
72
|
+
|
|
73
|
+
if (variableNodeMatchesStatementMetavariableNode) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (!negated) {
|
|
79
|
+
if (variableNodeMatchesStatementMetavariableNode) {
|
|
80
|
+
derivedContainedAssertionVerified = true;
|
|
81
|
+
}
|
|
79
82
|
}
|
|
80
|
-
}
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
if (negated) {
|
|
85
|
+
if (!variableNodeMatchesStatementMetavariableNode) {
|
|
86
|
+
derivedContainedAssertionVerified = true;
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
} else if (variableNode !== null) {
|
|
90
|
+
const statementVariableNodes = statementVariableNodesQuery(containedAssertionNode),
|
|
91
|
+
variableNodeMatchesStatementVariableNode = statementVariableNodes.some((statementVariableNode) => {
|
|
92
|
+
const variableNodeMatchesStatementVariableNode = variableNode.match(statementVariableNode);
|
|
93
|
+
|
|
94
|
+
if (variableNodeMatchesStatementVariableNode) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (!negated) {
|
|
100
|
+
if (variableNodeMatchesStatementVariableNode) {
|
|
101
|
+
derivedContainedAssertionVerified = true;
|
|
102
|
+
}
|
|
100
103
|
}
|
|
101
|
-
}
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
if (negated) {
|
|
106
|
+
if (!variableNodeMatchesStatementVariableNode) {
|
|
107
|
+
derivedContainedAssertionVerified = true;
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
}
|