occam-verify-cli 1.0.984 → 1.0.986
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/action/verify.js +22 -27
- package/lib/constants.js +1 -41
- package/lib/index.js +1 -2
- package/lib/utilities/fileContext.js +3 -8
- package/lib/utilities/releaseContext.js +2 -2
- package/package.json +2 -5
- package/src/action/verify.js +8 -18
- package/src/constants.js +0 -10
- package/src/index.js +0 -2
- package/src/utilities/fileContext.js +1 -2
- package/src/utilities/releaseContext.js +1 -1
- package/lib/context/aphasic.js +0 -27
- package/lib/context/bounded.js +0 -244
- package/lib/context/branching.js +0 -61
- package/lib/context/file/nominal.js +0 -586
- package/lib/context/illative.js +0 -28
- package/lib/context/liminal.js +0 -200
- package/lib/context/literal.js +0 -44
- package/lib/context/mnemic.js +0 -454
- package/lib/context/nested.js +0 -31
- package/lib/context/nominal.js +0 -57
- package/lib/context/phaneric.js +0 -44
- package/lib/context/thetic.js +0 -28
- package/lib/context.js +0 -445
- package/lib/element/assertion/contained.js +0 -218
- package/lib/element/assertion/defined.js +0 -213
- package/lib/element/assertion/property.js +0 -176
- package/lib/element/assertion/signature.js +0 -170
- package/lib/element/assertion/subproof.js +0 -220
- package/lib/element/assertion/type.js +0 -227
- package/lib/element/assertion.js +0 -49
- package/lib/element/assumption/metaLevel.js +0 -244
- package/lib/element/assumption.js +0 -252
- package/lib/element/combinator/bracketed.js +0 -36
- package/lib/element/combinator.js +0 -104
- package/lib/element/conclusion.js +0 -131
- package/lib/element/constructor/bracketed.js +0 -57
- package/lib/element/constructor.js +0 -129
- package/lib/element/declaration/combinator.js +0 -58
- package/lib/element/declaration/complexType.js +0 -180
- package/lib/element/declaration/constructor.js +0 -93
- package/lib/element/declaration/metavariable.js +0 -77
- package/lib/element/declaration/property.js +0 -88
- package/lib/element/declaration/simpleType.js +0 -148
- package/lib/element/declaration/typePrefix.js +0 -53
- package/lib/element/declaration/variable.js +0 -99
- package/lib/element/declaration.js +0 -15
- package/lib/element/deduction.js +0 -131
- package/lib/element/derivation.js +0 -46
- package/lib/element/equality.js +0 -211
- package/lib/element/equivalence.js +0 -200
- package/lib/element/error.js +0 -27
- package/lib/element/frame.js +0 -238
- package/lib/element/hypothesis.js +0 -135
- package/lib/element/judgement.js +0 -212
- package/lib/element/label.js +0 -135
- package/lib/element/metaType.js +0 -57
- package/lib/element/metavariable.js +0 -452
- package/lib/element/parameter.js +0 -69
- package/lib/element/procedureCall.js +0 -116
- package/lib/element/procedureReference.js +0 -56
- package/lib/element/proof.js +0 -52
- package/lib/element/proofAssertion/premise.js +0 -238
- package/lib/element/proofAssertion/step.js +0 -235
- package/lib/element/proofAssertion/supposition.js +0 -249
- package/lib/element/proofAssertion.js +0 -56
- package/lib/element/property.js +0 -176
- package/lib/element/propertyRelation.js +0 -132
- package/lib/element/reference.js +0 -227
- package/lib/element/rule.js +0 -242
- package/lib/element/section.js +0 -64
- package/lib/element/signature.js +0 -195
- package/lib/element/statement.js +0 -228
- package/lib/element/subDerivation.js +0 -46
- package/lib/element/subproof.js +0 -91
- package/lib/element/substitution/frame.js +0 -256
- package/lib/element/substitution/reference.js +0 -192
- package/lib/element/substitution/statement.js +0 -294
- package/lib/element/substitution/term.js +0 -266
- package/lib/element/substitution.js +0 -183
- package/lib/element/term.js +0 -217
- package/lib/element/topLevelAssertion/axiom.js +0 -158
- package/lib/element/topLevelAssertion/conjecture.js +0 -42
- package/lib/element/topLevelAssertion/lemma.js +0 -39
- package/lib/element/topLevelAssertion/theorem.js +0 -42
- package/lib/element/topLevelAssertion.js +0 -286
- package/lib/element/topLevelMetaAssertion/metaLemma.js +0 -42
- package/lib/element/topLevelMetaAssertion/metatheorem.js +0 -42
- package/lib/element/topLevelMetaAssertion.js +0 -179
- package/lib/element/type.js +0 -240
- package/lib/element/typePrefix.js +0 -85
- package/lib/element/variable.js +0 -206
- package/lib/elements.js +0 -27
- package/lib/metaTypeNames.js +0 -26
- package/lib/metaTypes.js +0 -66
- package/lib/node/argument.js +0 -31
- package/lib/node/assertion/contained.js +0 -51
- package/lib/node/assertion/defined.js +0 -47
- package/lib/node/assertion/property.js +0 -36
- package/lib/node/assertion/signature.js +0 -32
- package/lib/node/assertion/subproof.js +0 -28
- package/lib/node/assertion/type.js +0 -32
- package/lib/node/assertion.js +0 -18
- package/lib/node/assumption/metaLevel.js +0 -27
- package/lib/node/assumption.js +0 -27
- package/lib/node/body/axiom.js +0 -23
- package/lib/node/body/conjecture.js +0 -23
- package/lib/node/body/lemma.js +0 -23
- package/lib/node/body/metaLemma.js +0 -23
- package/lib/node/body/metatheorem.js +0 -23
- package/lib/node/body/rule.js +0 -44
- package/lib/node/body/theorem.js +0 -23
- package/lib/node/body.js +0 -31
- package/lib/node/combinator.js +0 -23
- package/lib/node/conclusion.js +0 -27
- package/lib/node/constructor.js +0 -23
- package/lib/node/declaration/combinator.js +0 -28
- package/lib/node/declaration/complexType.js +0 -72
- package/lib/node/declaration/constructor.js +0 -47
- package/lib/node/declaration/metavariable.js +0 -36
- package/lib/node/declaration/property.js +0 -44
- package/lib/node/declaration/simpleType.js +0 -72
- package/lib/node/declaration/typePrefix.js +0 -32
- package/lib/node/declaration/variable.js +0 -51
- package/lib/node/declaration.js +0 -18
- package/lib/node/deduction.js +0 -27
- package/lib/node/derivation.js +0 -26
- package/lib/node/document.js +0 -18
- package/lib/node/equality.js +0 -33
- package/lib/node/equivalence.js +0 -23
- package/lib/node/equivalences.js +0 -18
- package/lib/node/error.js +0 -18
- package/lib/node/frame.js +0 -38
- package/lib/node/header/axiom.js +0 -28
- package/lib/node/header/conjecture.js +0 -23
- package/lib/node/header/lemma.js +0 -23
- package/lib/node/header/metaLemma.js +0 -23
- package/lib/node/header/metatheorem.js +0 -23
- package/lib/node/header/rule.js +0 -23
- package/lib/node/header/theorem.js +0 -23
- package/lib/node/header.js +0 -47
- package/lib/node/hypothesis.js +0 -27
- package/lib/node/judgement.js +0 -31
- package/lib/node/label.js +0 -23
- package/lib/node/labels.js +0 -23
- package/lib/node/metaArgument.js +0 -23
- package/lib/node/metaType.js +0 -30
- package/lib/node/metavariable.js +0 -39
- package/lib/node/parameter.js +0 -47
- package/lib/node/parenthesisedLabel.js +0 -23
- package/lib/node/parenthesisedLabels.js +0 -27
- package/lib/node/placeholder.js +0 -18
- package/lib/node/procedureCall.js +0 -31
- package/lib/node/procedureReference.js +0 -30
- package/lib/node/proof.js +0 -23
- package/lib/node/proofAssertion/premise.js +0 -28
- package/lib/node/proofAssertion/step.js +0 -52
- package/lib/node/proofAssertion/supposition.js +0 -28
- package/lib/node/proofAssertion.js +0 -27
- package/lib/node/property.js +0 -30
- package/lib/node/propertyRelation.js +0 -31
- package/lib/node/qualification.js +0 -27
- package/lib/node/reference.js +0 -23
- package/lib/node/rule.js +0 -43
- package/lib/node/section.js +0 -39
- package/lib/node/signature.js +0 -23
- package/lib/node/statement.js +0 -103
- package/lib/node/subDerivation.js +0 -26
- package/lib/node/subproof.js +0 -35
- package/lib/node/substitution/frame.js +0 -40
- package/lib/node/substitution/reference.js +0 -40
- package/lib/node/substitution/statement.js +0 -60
- package/lib/node/substitution/term.js +0 -40
- package/lib/node/substitution.js +0 -18
- package/lib/node/term.js +0 -60
- package/lib/node/topLevelAssertion/axiom.js +0 -26
- package/lib/node/topLevelAssertion/conjecture.js +0 -26
- package/lib/node/topLevelAssertion/lemma.js +0 -26
- package/lib/node/topLevelAssertion/theorem.js +0 -26
- package/lib/node/topLevelAssertion.js +0 -46
- package/lib/node/topLevelMetaAssertion/metaLemma.js +0 -26
- package/lib/node/topLevelMetaAssertion/metatheorem.js +0 -26
- package/lib/node/topLevelMetaAssertion.js +0 -42
- package/lib/node/type.js +0 -60
- package/lib/node/typePrefix.js +0 -30
- package/lib/node/types.js +0 -23
- package/lib/node/variable.js +0 -30
- package/lib/nominal/lexer.js +0 -15
- package/lib/nominal/parser.js +0 -24
- package/lib/nonTerminalNodeMap.js +0 -189
- package/lib/pass/zip.js +0 -23
- package/lib/preamble.js +0 -73
- package/lib/process/assign.js +0 -62
- package/lib/process/discharge.js +0 -38
- package/lib/process/equate.js +0 -73
- package/lib/process/instantiate.js +0 -261
- package/lib/process/unification.js +0 -228
- package/lib/process/unify.js +0 -336
- package/lib/process/validate.js +0 -135
- package/lib/process/validation.js +0 -291
- package/lib/process/verify.js +0 -205
- package/lib/ruleNames.js +0 -350
- package/lib/tokenTypes.js +0 -22
- package/lib/utilities/assignment.js +0 -47
- package/lib/utilities/bnf.js +0 -21
- package/lib/utilities/brackets.js +0 -77
- package/lib/utilities/breakPoint.js +0 -38
- package/lib/utilities/context.js +0 -220
- package/lib/utilities/element.js +0 -1851
- package/lib/utilities/equivalence.js +0 -27
- package/lib/utilities/equivalences.js +0 -134
- package/lib/utilities/instance.js +0 -44
- package/lib/utilities/json.js +0 -1109
- package/lib/utilities/string.js +0 -231
- package/lib/utilities/substitutions.js +0 -86
- package/lib/utilities/synoptic.js +0 -159
- package/lib/utilities/type.js +0 -27
- package/src/context/aphasic.js +0 -15
- package/src/context/bounded.js +0 -362
- package/src/context/branching.js +0 -69
- package/src/context/file/nominal.js +0 -955
- package/src/context/illative.js +0 -17
- package/src/context/liminal.js +0 -280
- package/src/context/literal.js +0 -42
- package/src/context/mnemic.js +0 -778
- package/src/context/nested.js +0 -21
- package/src/context/nominal.js +0 -62
- package/src/context/phaneric.js +0 -43
- package/src/context/thetic.js +0 -17
- package/src/context.js +0 -722
- package/src/element/assertion/contained.js +0 -313
- package/src/element/assertion/defined.js +0 -310
- package/src/element/assertion/property.js +0 -252
- package/src/element/assertion/signature.js +0 -239
- package/src/element/assertion/subproof.js +0 -335
- package/src/element/assertion/type.js +0 -328
- package/src/element/assertion.js +0 -65
- package/src/element/assumption/metaLevel.js +0 -373
- package/src/element/assumption.js +0 -374
- package/src/element/combinator/bracketed.js +0 -32
- package/src/element/combinator.js +0 -145
- package/src/element/conclusion.js +0 -185
- package/src/element/constructor/bracketed.js +0 -68
- package/src/element/constructor.js +0 -188
- package/src/element/declaration/combinator.js +0 -66
- package/src/element/declaration/complexType.js +0 -257
- package/src/element/declaration/constructor.js +0 -122
- package/src/element/declaration/metavariable.js +0 -93
- package/src/element/declaration/property.js +0 -108
- package/src/element/declaration/simpleType.js +0 -208
- package/src/element/declaration/typePrefix.js +0 -58
- package/src/element/declaration/variable.js +0 -130
- package/src/element/declaration.js +0 -7
- package/src/element/deduction.js +0 -185
- package/src/element/derivation.js +0 -57
- package/src/element/equality.js +0 -325
- package/src/element/equivalence.js +0 -276
- package/src/element/error.js +0 -26
- package/src/element/frame.js +0 -356
- package/src/element/hypothesis.js +0 -186
- package/src/element/judgement.js +0 -303
- package/src/element/label.js +0 -186
- package/src/element/metaType.js +0 -75
- package/src/element/metavariable.js +0 -662
- package/src/element/parameter.js +0 -90
- package/src/element/procedureCall.js +0 -159
- package/src/element/procedureReference.js +0 -71
- package/src/element/proof.js +0 -61
- package/src/element/proofAssertion/premise.js +0 -354
- package/src/element/proofAssertion/step.js +0 -271
- package/src/element/proofAssertion/supposition.js +0 -377
- package/src/element/proofAssertion.js +0 -74
- package/src/element/property.js +0 -258
- package/src/element/propertyRelation.js +0 -193
- package/src/element/reference.js +0 -345
- package/src/element/rule.js +0 -358
- package/src/element/section.js +0 -78
- package/src/element/signature.js +0 -292
- package/src/element/statement.js +0 -358
- package/src/element/subDerivation.js +0 -56
- package/src/element/subproof.js +0 -116
- package/src/element/substitution/frame.js +0 -392
- package/src/element/substitution/reference.js +0 -274
- package/src/element/substitution/statement.js +0 -452
- package/src/element/substitution/term.js +0 -407
- package/src/element/substitution.js +0 -261
- package/src/element/term.js +0 -339
- package/src/element/topLevelAssertion/axiom.js +0 -244
- package/src/element/topLevelAssertion/conjecture.js +0 -40
- package/src/element/topLevelAssertion/lemma.js +0 -42
- package/src/element/topLevelAssertion/theorem.js +0 -40
- package/src/element/topLevelAssertion.js +0 -436
- package/src/element/topLevelMetaAssertion/metaLemma.js +0 -40
- package/src/element/topLevelMetaAssertion/metatheorem.js +0 -40
- package/src/element/topLevelMetaAssertion.js +0 -276
- package/src/element/type.js +0 -374
- package/src/element/typePrefix.js +0 -113
- package/src/element/variable.js +0 -259
- package/src/elements.js +0 -13
- package/src/metaTypeNames.js +0 -5
- package/src/metaTypes.js +0 -71
- package/src/node/argument.js +0 -30
- package/src/node/assertion/contained.js +0 -53
- package/src/node/assertion/defined.js +0 -46
- package/src/node/assertion/property.js +0 -30
- package/src/node/assertion/signature.js +0 -23
- package/src/node/assertion/subproof.js +0 -16
- package/src/node/assertion/type.js +0 -23
- package/src/node/assertion.js +0 -7
- package/src/node/assumption/metaLevel.js +0 -23
- package/src/node/assumption.js +0 -23
- package/src/node/body/axiom.js +0 -7
- package/src/node/body/conjecture.js +0 -7
- package/src/node/body/lemma.js +0 -7
- package/src/node/body/metaLemma.js +0 -7
- package/src/node/body/metatheorem.js +0 -7
- package/src/node/body/rule.js +0 -42
- package/src/node/body/theorem.js +0 -7
- package/src/node/body.js +0 -30
- package/src/node/combinator.js +0 -16
- package/src/node/conclusion.js +0 -23
- package/src/node/constructor.js +0 -16
- package/src/node/declaration/combinator.js +0 -16
- package/src/node/declaration/complexType.js +0 -88
- package/src/node/declaration/constructor.js +0 -46
- package/src/node/declaration/metavariable.js +0 -30
- package/src/node/declaration/property.js +0 -42
- package/src/node/declaration/simpleType.js +0 -87
- package/src/node/declaration/typePrefix.js +0 -24
- package/src/node/declaration/variable.js +0 -53
- package/src/node/declaration.js +0 -7
- package/src/node/deduction.js +0 -23
- package/src/node/derivation.js +0 -19
- package/src/node/document.js +0 -7
- package/src/node/equality.js +0 -35
- package/src/node/equivalence.js +0 -16
- package/src/node/equivalences.js +0 -7
- package/src/node/error.js +0 -7
- package/src/node/frame.js +0 -40
- package/src/node/header/axiom.js +0 -16
- package/src/node/header/conjecture.js +0 -7
- package/src/node/header/lemma.js +0 -7
- package/src/node/header/metaLemma.js +0 -7
- package/src/node/header/metatheorem.js +0 -7
- package/src/node/header/rule.js +0 -7
- package/src/node/header/theorem.js +0 -7
- package/src/node/header.js +0 -54
- package/src/node/hypothesis.js +0 -23
- package/src/node/judgement.js +0 -30
- package/src/node/label.js +0 -16
- package/src/node/labels.js +0 -16
- package/src/node/metaArgument.js +0 -16
- package/src/node/metaType.js +0 -26
- package/src/node/metavariable.js +0 -42
- package/src/node/parameter.js +0 -51
- package/src/node/parenthesisedLabel.js +0 -16
- package/src/node/parenthesisedLabels.js +0 -23
- package/src/node/placeholder.js +0 -7
- package/src/node/procedureCall.js +0 -30
- package/src/node/procedureReference.js +0 -26
- package/src/node/proof.js +0 -16
- package/src/node/proofAssertion/premise.js +0 -16
- package/src/node/proofAssertion/step.js +0 -52
- package/src/node/proofAssertion/supposition.js +0 -16
- package/src/node/proofAssertion.js +0 -23
- package/src/node/property.js +0 -28
- package/src/node/propertyRelation.js +0 -30
- package/src/node/qualification.js +0 -23
- package/src/node/reference.js +0 -16
- package/src/node/rule.js +0 -51
- package/src/node/section.js +0 -44
- package/src/node/signature.js +0 -16
- package/src/node/statement.js +0 -167
- package/src/node/subDerivation.js +0 -19
- package/src/node/subproof.js +0 -35
- package/src/node/substitution/frame.js +0 -37
- package/src/node/substitution/reference.js +0 -38
- package/src/node/substitution/statement.js +0 -70
- package/src/node/substitution/term.js +0 -38
- package/src/node/substitution.js +0 -7
- package/src/node/term.js +0 -75
- package/src/node/topLevelAssertion/axiom.js +0 -13
- package/src/node/topLevelAssertion/conjecture.js +0 -13
- package/src/node/topLevelAssertion/lemma.js +0 -13
- package/src/node/topLevelAssertion/theorem.js +0 -13
- package/src/node/topLevelAssertion.js +0 -58
- package/src/node/topLevelMetaAssertion/metaLemma.js +0 -13
- package/src/node/topLevelMetaAssertion/metatheorem.js +0 -13
- package/src/node/topLevelMetaAssertion.js +0 -51
- package/src/node/type.js +0 -74
- package/src/node/typePrefix.js +0 -26
- package/src/node/types.js +0 -16
- package/src/node/variable.js +0 -26
- package/src/nominal/lexer.js +0 -5
- package/src/nominal/parser.js +0 -12
- package/src/nonTerminalNodeMap.js +0 -261
- package/src/pass/zip.js +0 -19
- package/src/preamble.js +0 -64
- package/src/process/assign.js +0 -53
- package/src/process/discharge.js +0 -33
- package/src/process/equate.js +0 -94
- package/src/process/instantiate.js +0 -198
- package/src/process/unification.js +0 -332
- package/src/process/unify.js +0 -504
- package/src/process/validate.js +0 -174
- package/src/process/validation.js +0 -410
- package/src/process/verify.js +0 -299
- package/src/ruleNames.js +0 -86
- package/src/tokenTypes.js +0 -4
- package/src/utilities/assignment.js +0 -57
- package/src/utilities/bnf.js +0 -20
- package/src/utilities/brackets.js +0 -87
- package/src/utilities/breakPoint.js +0 -29
- package/src/utilities/context.js +0 -223
- package/src/utilities/element.js +0 -2293
- package/src/utilities/equivalence.js +0 -25
- package/src/utilities/equivalences.js +0 -158
- package/src/utilities/instance.js +0 -40
- package/src/utilities/json.js +0 -1273
- package/src/utilities/string.js +0 -282
- package/src/utilities/substitutions.js +0 -93
- package/src/utilities/synoptic.js +0 -135
- package/src/utilities/type.js +0 -19
|
@@ -1,662 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { Element } from "occam-languages";
|
|
4
|
-
|
|
5
|
-
import elements from "../elements";
|
|
6
|
-
|
|
7
|
-
import { define } from "../elements";
|
|
8
|
-
import { instantiate } from "../utilities/context";
|
|
9
|
-
import { EMPTY_STRING } from "../constants";
|
|
10
|
-
import { instantiateMetavariable } from "../process/instantiate";
|
|
11
|
-
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "../utilities/json";
|
|
12
|
-
import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
|
|
13
|
-
import { unifyMetavariable, unifyMetavariableIntrinsically } from "../process/unify";
|
|
14
|
-
import { nameFromMetavariableNode, termFromMetavariableNode, typeFromMetavariableNode, metavariableFromStatementNode } from "../utilities/element";
|
|
15
|
-
|
|
16
|
-
export default define(class Metavariable extends Element {
|
|
17
|
-
constructor(context, string, node, breakPoint, name, term, type, metaType) {
|
|
18
|
-
super(context, string, node, breakPoint);
|
|
19
|
-
|
|
20
|
-
this.name = name;
|
|
21
|
-
this.term = term;
|
|
22
|
-
this.type = type;
|
|
23
|
-
this.metaType = metaType;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getName() {
|
|
27
|
-
return this.name;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getTerm() {
|
|
31
|
-
return this.term;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getType() {
|
|
35
|
-
return this.type;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getMetaType() {
|
|
39
|
-
return this.metaType;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setMetaType(metaType) {
|
|
43
|
-
this.metaType = metaType;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getMetavariableNode() {
|
|
47
|
-
const node = this.getNode(),
|
|
48
|
-
metavariableNode = node; ///
|
|
49
|
-
|
|
50
|
-
return metavariableNode;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getMetavariableName() {
|
|
54
|
-
const metavariableNode = this.getMetavariableNode(),
|
|
55
|
-
metavariableName = metavariableNode.getMetavariableName();
|
|
56
|
-
|
|
57
|
-
return metavariableName;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
isDeclared(context) {
|
|
61
|
-
const metavariableName = this.getMetavariableName(),
|
|
62
|
-
declaredMetavariable = context.findDeclaredMetavariableByMetavariableName(metavariableName),
|
|
63
|
-
declared = (declaredMetavariable !== null);
|
|
64
|
-
|
|
65
|
-
return declared;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
isEqualTo(metavariable) {
|
|
69
|
-
const metavariableNode = metavariable.getNode(),
|
|
70
|
-
metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
71
|
-
equalTo = metavariableNodeMatches; ///
|
|
72
|
-
|
|
73
|
-
return equalTo;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
77
|
-
|
|
78
|
-
matchMetavariableNode(metavariableNode) {
|
|
79
|
-
const node = metavariableNode, ///
|
|
80
|
-
nodeMatches = this.matchNode(node),
|
|
81
|
-
metavariableNodeMatches = nodeMatches; ///
|
|
82
|
-
|
|
83
|
-
return metavariableNodeMatches;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
compareMetavariable(metavariable) {
|
|
87
|
-
const metavariableName = metavariable.getName(),
|
|
88
|
-
comparesToMetavariableName = this.compareMetavariableName(metavariableName),
|
|
89
|
-
comparesToMetavariable = comparesToMetavariableName; ///
|
|
90
|
-
|
|
91
|
-
return comparesToMetavariable;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
compareMetavariableName(metavariableName) {
|
|
95
|
-
const nameMetavariableName = (this.name === metavariableName),
|
|
96
|
-
comparesToMetavariableName = nameMetavariableName; ///
|
|
97
|
-
|
|
98
|
-
return comparesToMetavariableName;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
findValidMetavariable(context) {
|
|
102
|
-
const metavariableNode = this.getMetavariableNode(),
|
|
103
|
-
metavariable = context.findMetavariableByMetavariableNode(metavariableNode),
|
|
104
|
-
validMetavariable = metavariable; ///
|
|
105
|
-
|
|
106
|
-
return validMetavariable;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
verify(context) {
|
|
110
|
-
let verifies = false;
|
|
111
|
-
|
|
112
|
-
const metavariableString = this.getString(); ///
|
|
113
|
-
|
|
114
|
-
context.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
115
|
-
|
|
116
|
-
const termVerifies = this.verifyTerm(context);
|
|
117
|
-
|
|
118
|
-
if (termVerifies) {
|
|
119
|
-
const typeVerifies = this.verifyType(context);
|
|
120
|
-
|
|
121
|
-
if (typeVerifies) {
|
|
122
|
-
verifies = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (verifies) {
|
|
127
|
-
context.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return verifies;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
verifyTerm(context) {
|
|
134
|
-
let termVerifies = true; ///
|
|
135
|
-
|
|
136
|
-
if (this.term !== null) {
|
|
137
|
-
const termString = this.term.getString(),
|
|
138
|
-
metavariableString = this.getString();
|
|
139
|
-
|
|
140
|
-
termVerifies = false;
|
|
141
|
-
|
|
142
|
-
context.trace(`A '${termString}' term is present in the '${metavariableString}' metavariable.`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return termVerifies;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
verifyType(context) {
|
|
149
|
-
let typeVerifies = true; ///
|
|
150
|
-
|
|
151
|
-
if (this.type !== null) {
|
|
152
|
-
const metavariableString = this.getString(); ///
|
|
153
|
-
|
|
154
|
-
context.trace(`Verifying the '${metavariableString}' metavariable's type...`);
|
|
155
|
-
|
|
156
|
-
const typeName = this.type.getName(),
|
|
157
|
-
type = context.findTypeByTypeName(typeName);
|
|
158
|
-
|
|
159
|
-
if (type !== null) {
|
|
160
|
-
this.type = type;
|
|
161
|
-
|
|
162
|
-
typeVerifies = true;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (typeVerifies) {
|
|
166
|
-
context.debug(`...verifieds the '${metavariableString}' metavariable's type.`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return typeVerifies;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
validate(strict, context) {
|
|
174
|
-
if (context === undefined) {
|
|
175
|
-
context = strict; ///
|
|
176
|
-
|
|
177
|
-
strict = false;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
let metavariable = null;
|
|
181
|
-
|
|
182
|
-
const metavariableString = this.getString(); ///
|
|
183
|
-
|
|
184
|
-
context.trace(`Validating the '${metavariableString}' metavariable...`);
|
|
185
|
-
|
|
186
|
-
let validates = false;
|
|
187
|
-
|
|
188
|
-
const validMetavariable = this.findValidMetavariable(context);
|
|
189
|
-
|
|
190
|
-
if (validMetavariable !== null) {
|
|
191
|
-
validates = true;
|
|
192
|
-
|
|
193
|
-
metavariable = validMetavariable; ///
|
|
194
|
-
|
|
195
|
-
context.debug(`...the '${metavariableString}' metavariable is already valid.`);
|
|
196
|
-
} else {
|
|
197
|
-
const nameValidates = this.validateName(strict, context);
|
|
198
|
-
|
|
199
|
-
if (nameValidates) {
|
|
200
|
-
const termValidates = this.validateTerm(strict, context);
|
|
201
|
-
|
|
202
|
-
if (termValidates) {
|
|
203
|
-
const typeValidates = this.validateType(strict, context);
|
|
204
|
-
|
|
205
|
-
if (typeValidates) {
|
|
206
|
-
validates = true;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (validates) {
|
|
212
|
-
metavariable = this; ///
|
|
213
|
-
|
|
214
|
-
const declared = this.isDeclared(context);
|
|
215
|
-
|
|
216
|
-
if (declared) {
|
|
217
|
-
context.addMetavariable(metavariable);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (validates) {
|
|
223
|
-
context.debug(`...validated the '${metavariableString}' metavariable.`);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return metavariable;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
validateName(strict, context) {
|
|
230
|
-
let nameValidates = true; ///
|
|
231
|
-
|
|
232
|
-
const metavariableString = this.getString(); ///
|
|
233
|
-
|
|
234
|
-
context.trace(`Validating the '${metavariableString}' metavariable's name...`);
|
|
235
|
-
|
|
236
|
-
const metavariableName = this.getMetavariableName(), ///
|
|
237
|
-
declaredMetavariable = context.findDeclaredMetavariableByMetavariableName(metavariableName);
|
|
238
|
-
|
|
239
|
-
if (declaredMetavariable !== null) {
|
|
240
|
-
const metaType = declaredMetavariable.getMetaType(),
|
|
241
|
-
metaTypeString = metaType.getString();
|
|
242
|
-
|
|
243
|
-
this.metaType = metaType;
|
|
244
|
-
|
|
245
|
-
context.trace(`Setting the '${metavariableString}' metavariable's meta-type to the '${metaTypeString}' meta-type.`);
|
|
246
|
-
} else {
|
|
247
|
-
if (strict) {
|
|
248
|
-
nameValidates = false;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (nameValidates) {
|
|
253
|
-
context.debug(`...validated the '${metavariableString}' metavariable's name.`);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return nameValidates;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
validateTerm(strict, context) {
|
|
260
|
-
let termValidates = false;
|
|
261
|
-
|
|
262
|
-
if (this.term === null) {
|
|
263
|
-
termValidates = true;
|
|
264
|
-
} else {
|
|
265
|
-
const metavariableString = this.getString(); ///
|
|
266
|
-
|
|
267
|
-
context.trace(`Validating the '${metavariableString}' metavariable's term...`);
|
|
268
|
-
|
|
269
|
-
const metavariableName = this.getMetavariableName(),
|
|
270
|
-
declaredMetavaraible = context.findDeclaredMetavariableByMetavariableName(metavariableName);
|
|
271
|
-
|
|
272
|
-
let term = null;
|
|
273
|
-
|
|
274
|
-
if (declaredMetavaraible !== null) {
|
|
275
|
-
const type = declaredMetavaraible.getType();
|
|
276
|
-
|
|
277
|
-
if (type !== null) {
|
|
278
|
-
term = this.term.validateGivenType(type, context);
|
|
279
|
-
}
|
|
280
|
-
} else {
|
|
281
|
-
if (!strict) {
|
|
282
|
-
term = this.term.validate(context, (term, context) => {
|
|
283
|
-
const validatesForwards = true;
|
|
284
|
-
|
|
285
|
-
return validatesForwards;
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (term !== null) {
|
|
291
|
-
this.term = term;
|
|
292
|
-
|
|
293
|
-
termValidates = true;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (termValidates) {
|
|
297
|
-
context.debug(`...validated the '${metavariableString}' metavariable's term.`);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return termValidates;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
validateType(strict, context) {
|
|
305
|
-
let typeValidates;
|
|
306
|
-
|
|
307
|
-
if (this.type === null) {
|
|
308
|
-
typeValidates = true;
|
|
309
|
-
} else {
|
|
310
|
-
const metavariableString = this.getString(); ///
|
|
311
|
-
|
|
312
|
-
context.trace(`Validating the '${metavariableString}' metavariable's type...`);
|
|
313
|
-
|
|
314
|
-
typeValidates = false;
|
|
315
|
-
|
|
316
|
-
const typeString = this.type.getString();
|
|
317
|
-
|
|
318
|
-
context.trace(`A '${typeString}' type is present in the '${metavariableString}' metavariable.`);
|
|
319
|
-
|
|
320
|
-
if (typeValidates) {
|
|
321
|
-
context.trace(`...validated the '${metavariableString}' metavariable's type.`);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return typeValidates;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
unifyFrame(frame, generalContext, specificContext) {
|
|
329
|
-
let frameUnifies = false;
|
|
330
|
-
|
|
331
|
-
const context = specificContext, ///
|
|
332
|
-
frameString = frame.getString(),
|
|
333
|
-
metavariableString = this.getString(); ///
|
|
334
|
-
|
|
335
|
-
context.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
336
|
-
|
|
337
|
-
const metavariable = this, ///
|
|
338
|
-
frameMetavariableUnifies = this.unifyFrameMetavariable(frame, generalContext, specificContext);
|
|
339
|
-
|
|
340
|
-
if (frameMetavariableUnifies) {
|
|
341
|
-
frameUnifies = true;
|
|
342
|
-
} else {
|
|
343
|
-
const metavariableNode = metavariable.getNode(),
|
|
344
|
-
derivedSubstitution = context.findDerivedSubstitutionByMetavariableNode(metavariableNode);
|
|
345
|
-
|
|
346
|
-
if (derivedSubstitution !== null) {
|
|
347
|
-
const derivedSubstitutionFrameComparesToFrame = derivedSubstitution.compareFrame(frame, context);
|
|
348
|
-
|
|
349
|
-
if (derivedSubstitutionFrameComparesToFrame) {
|
|
350
|
-
const derivedSubstitutionString = derivedSubstitution.getString();
|
|
351
|
-
|
|
352
|
-
context.trace(`The '${derivedSubstitutionString}' derived substitution is already present.`);
|
|
353
|
-
|
|
354
|
-
frameUnifies = true;
|
|
355
|
-
}
|
|
356
|
-
} else {
|
|
357
|
-
const { FrameSubstitution } = elements;
|
|
358
|
-
|
|
359
|
-
let frameSubstitution;
|
|
360
|
-
|
|
361
|
-
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, generalContext, specificContext);
|
|
362
|
-
|
|
363
|
-
frameSubstitution = frameSubstitution.validate(context); ///
|
|
364
|
-
|
|
365
|
-
const derivedSubstitution = frameSubstitution; ///
|
|
366
|
-
|
|
367
|
-
context.addDerivedSubstitution(derivedSubstitution);
|
|
368
|
-
|
|
369
|
-
frameUnifies = true;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
if (frameUnifies) {
|
|
374
|
-
context.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
return frameUnifies;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
unifyStatement(statement, substitution, generalContext, specificContext) {
|
|
381
|
-
let statementUnifies = false;
|
|
382
|
-
|
|
383
|
-
const context = specificContext, ///
|
|
384
|
-
statementString = statement.getString(),
|
|
385
|
-
metavariableString = this.getString(), ///
|
|
386
|
-
substitutionString = (substitution !== null) ?
|
|
387
|
-
substitution.getString() :
|
|
388
|
-
EMPTY_STRING;
|
|
389
|
-
|
|
390
|
-
context.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
391
|
-
|
|
392
|
-
const metavariable = this, ///
|
|
393
|
-
statementMetavariableUnifies = this.unifyStatementMetavariable(statement, generalContext, specificContext);
|
|
394
|
-
|
|
395
|
-
if (statementMetavariableUnifies) {
|
|
396
|
-
statementUnifies = true;
|
|
397
|
-
} else {
|
|
398
|
-
const metavariableNode = metavariable.getNode(),
|
|
399
|
-
derivedSubstitution = (substitution !== null) ?
|
|
400
|
-
context.findDerivedSubstitutionByMetavariableNodeAndSubstitution(metavariableNode, substitution) :
|
|
401
|
-
context.findDerivedSubstitutionByMetavariableNode(metavariableNode);
|
|
402
|
-
|
|
403
|
-
if (derivedSubstitution !== null) {
|
|
404
|
-
const derivedSubstitutionComparesToStatement = derivedSubstitution.compareStatement(statement, context);
|
|
405
|
-
|
|
406
|
-
if (derivedSubstitutionComparesToStatement) {
|
|
407
|
-
const derivedSubstitutionString = derivedSubstitution.getString();
|
|
408
|
-
|
|
409
|
-
context.trace(`The '${derivedSubstitutionString}' derived substitution is already present.`);
|
|
410
|
-
|
|
411
|
-
statementUnifies = true;
|
|
412
|
-
}
|
|
413
|
-
} else {
|
|
414
|
-
const { StatementSubstitution } = elements;
|
|
415
|
-
|
|
416
|
-
let statementSubstitution;
|
|
417
|
-
|
|
418
|
-
statementSubstitution = (substitution !== null) ?
|
|
419
|
-
StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, generalContext, specificContext) :
|
|
420
|
-
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, generalContext, specificContext);
|
|
421
|
-
|
|
422
|
-
statementSubstitution = statementSubstitution.validate(substitution, context); ///
|
|
423
|
-
|
|
424
|
-
const derivedSubstitution = statementSubstitution; ///
|
|
425
|
-
|
|
426
|
-
context.addDerivedSubstitution(derivedSubstitution);
|
|
427
|
-
|
|
428
|
-
statementUnifies = true;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (statementUnifies) {
|
|
433
|
-
context.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return statementUnifies;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
unifyReference(reference, generalContext, specificContext) {
|
|
440
|
-
let referenceUnifies = false;
|
|
441
|
-
|
|
442
|
-
const context = specificContext, ///
|
|
443
|
-
referenceString = reference.getString(),
|
|
444
|
-
metavariableString = this.getString(); ///
|
|
445
|
-
|
|
446
|
-
context.trace(`Unifying the '${referenceString}' reference with the '${metavariableString}' metavariable...`);
|
|
447
|
-
|
|
448
|
-
const metavariable = this, ///
|
|
449
|
-
referenceMetavariableUnifies = this.unifyReferenceMetavariable(reference, generalContext, specificContext);
|
|
450
|
-
|
|
451
|
-
if (referenceMetavariableUnifies) {
|
|
452
|
-
referenceUnifies = true;
|
|
453
|
-
} else {
|
|
454
|
-
const metavariableNode = metavariable.getNode(),
|
|
455
|
-
derivedSubstitution = context.findDerivedSubstitutionByMetavariableNode(metavariableNode);
|
|
456
|
-
|
|
457
|
-
if (derivedSubstitution !== null) {
|
|
458
|
-
const derivedSubstitutionReferenceComparesToReference = derivedSubstitution.compareReference(reference, context);
|
|
459
|
-
|
|
460
|
-
if (derivedSubstitutionReferenceComparesToReference) {
|
|
461
|
-
const derivedSubstitutionString = derivedSubstitution.getString();
|
|
462
|
-
|
|
463
|
-
context.trace(`The '${derivedSubstitutionString}' derived substitution is already present.`);
|
|
464
|
-
|
|
465
|
-
referenceUnifies = true;
|
|
466
|
-
}
|
|
467
|
-
} else {
|
|
468
|
-
const { ReferenceSubstitution } = elements;
|
|
469
|
-
|
|
470
|
-
let referenceSubstitution;
|
|
471
|
-
|
|
472
|
-
referenceSubstitution = ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, generalContext, specificContext);
|
|
473
|
-
|
|
474
|
-
referenceSubstitution = referenceSubstitution.validate(context); ///
|
|
475
|
-
|
|
476
|
-
const derivedSubstitution = referenceSubstitution; ///
|
|
477
|
-
|
|
478
|
-
context.addDerivedSubstitution(derivedSubstitution);
|
|
479
|
-
|
|
480
|
-
referenceUnifies = true;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
if (referenceUnifies) {
|
|
485
|
-
context.debug(`...unified the '${referenceString}' reference with the '${metavariableString}' metavariable.`);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
return referenceUnifies;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
unifyMetavariable(metavariable, context) {
|
|
492
|
-
let metavariableUnifies;
|
|
493
|
-
|
|
494
|
-
const generalContext = context, ///
|
|
495
|
-
specificContext = context, ///
|
|
496
|
-
generalMetavariable = this, ///
|
|
497
|
-
specificMetavariable = metavariable, ///
|
|
498
|
-
generalMetavariableString = generalMetavariable.getString(),
|
|
499
|
-
specificMetavariableString = specificMetavariable.getString();
|
|
500
|
-
|
|
501
|
-
context.trace(`Unifying the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable...`);
|
|
502
|
-
|
|
503
|
-
metavariableUnifies = unifyMetavariable(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
504
|
-
|
|
505
|
-
if (metavariableUnifies) {
|
|
506
|
-
context.debug(`...unified the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable.`);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return metavariableUnifies;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
unifyFrameMetavariable(frame, generalContext, specificContext) {
|
|
513
|
-
let frameMetavariableUnifies = false;
|
|
514
|
-
|
|
515
|
-
const context = specificContext, ///
|
|
516
|
-
frameString = frame.getString(),
|
|
517
|
-
metavariableString = this.getString(); ///
|
|
518
|
-
|
|
519
|
-
context.trace(`Unifying the '${frameString}' frame's metavariable with the '${metavariableString}' metavariable...`);
|
|
520
|
-
|
|
521
|
-
const generalContextFilePath = generalContext.getFilePath(),
|
|
522
|
-
specificContextFilePath = specificContext.getFilePath();
|
|
523
|
-
|
|
524
|
-
if (generalContextFilePath === specificContextFilePath) {
|
|
525
|
-
const metavariableNode = this.getMetavariableNode(), ///
|
|
526
|
-
metavariableNodeMatches = frame.matchMetavariableNode(metavariableNode);
|
|
527
|
-
|
|
528
|
-
if (metavariableNodeMatches) {
|
|
529
|
-
frameMetavariableUnifies = true;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
if (frameMetavariableUnifies) {
|
|
534
|
-
context.debug(`...unified the '${frameString}' frame's metavariable with the '${metavariableString}' metavariable.`);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
return frameMetavariableUnifies;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
unifyReferenceMetavariable(reference, generalContext, specificContext) {
|
|
541
|
-
let referenceMetavariableUnifies = false;
|
|
542
|
-
|
|
543
|
-
const context = specificContext, ///
|
|
544
|
-
referenceString = reference.getString(),
|
|
545
|
-
metavariableString = this.getString();
|
|
546
|
-
|
|
547
|
-
context.trace(`Unifying the '${referenceString}' reference's metavariable with the '${metavariableString}' metavariable...`);
|
|
548
|
-
|
|
549
|
-
const generalContextFilePath = generalContext.getFilePath(),
|
|
550
|
-
specificContextFilePath = specificContext.getFilePath();
|
|
551
|
-
|
|
552
|
-
if (generalContextFilePath === specificContextFilePath) {
|
|
553
|
-
const metavariableNode = this.getMetavariableNode(),
|
|
554
|
-
metavariableNodeMatches = reference.matchMetavariableNode(metavariableNode);
|
|
555
|
-
|
|
556
|
-
if (metavariableNodeMatches) {
|
|
557
|
-
referenceMetavariableUnifies = true;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
if (referenceMetavariableUnifies) {
|
|
562
|
-
context.trace(`...unified the '${referenceString}' reference's metavariable with the '${metavariableString}' metavariable.`);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
return referenceMetavariableUnifies;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
unifyStatementMetavariable(statement, generalContext, specificContext) {
|
|
569
|
-
let statementMetavariableUnifies = false;
|
|
570
|
-
|
|
571
|
-
const context = specificContext, ///
|
|
572
|
-
statementString = statement.getString(),
|
|
573
|
-
metavariableString = this.getString(); ///
|
|
574
|
-
|
|
575
|
-
context.trace(`Unifying the '${statementString}' statement's metavariable with the '${metavariableString}' metavariable...`);
|
|
576
|
-
|
|
577
|
-
const generalContextFilePath = generalContext.getFilePath(),
|
|
578
|
-
specificContextFilePath = specificContext.getFilePath();
|
|
579
|
-
|
|
580
|
-
if (generalContextFilePath === specificContextFilePath) {
|
|
581
|
-
const metavariableNode = this.getMetavariableNode(),
|
|
582
|
-
metavariableNodeMatches = statement.matchMetavariableNode(metavariableNode);
|
|
583
|
-
|
|
584
|
-
if (metavariableNodeMatches) {
|
|
585
|
-
statementMetavariableUnifies = true;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
if (statementMetavariableUnifies) {
|
|
590
|
-
context.debug(`...unified the '${statementString}' statement's metavariable with the '${metavariableString}' metavariable.`);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
return statementMetavariableUnifies;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
unifyMetavariableIntrinsically(metavariable, generalContext, specificContext) {
|
|
597
|
-
let metavariableUnifiesIntrinsically;
|
|
598
|
-
|
|
599
|
-
const context = specificContext, ///
|
|
600
|
-
generalMetavariable = this, ///
|
|
601
|
-
specificMetavariable = metavariable,
|
|
602
|
-
generalMetavariableString = generalMetavariable.getString(), ///
|
|
603
|
-
specificMetavariableString = specificMetavariable.getString();
|
|
604
|
-
|
|
605
|
-
context.trace(`Unifying the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable intrinsically...`);
|
|
606
|
-
|
|
607
|
-
metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
608
|
-
|
|
609
|
-
if (metavariableUnifiesIntrinsically) {
|
|
610
|
-
context.debug(`...unified the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable intrinsically.`);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return metavariableUnifiesIntrinsically;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
toJSON() {
|
|
617
|
-
const metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
|
|
618
|
-
metaType = metaTypeJSON, ///
|
|
619
|
-
string = this.getString();
|
|
620
|
-
|
|
621
|
-
let breakPoint;
|
|
622
|
-
|
|
623
|
-
breakPoint = this.getBreakPoint();
|
|
624
|
-
|
|
625
|
-
const breakPointJSON = breakPointToBreakPointJSON(breakPoint);
|
|
626
|
-
|
|
627
|
-
breakPoint = breakPointJSON; ///
|
|
628
|
-
|
|
629
|
-
const json = {
|
|
630
|
-
string,
|
|
631
|
-
breakPoint,
|
|
632
|
-
metaType
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
return json;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
static name = "Metavariable";
|
|
639
|
-
|
|
640
|
-
static fromJSON(json, context) {
|
|
641
|
-
return instantiate((context) => {
|
|
642
|
-
const { string } = json,
|
|
643
|
-
metavariableNode = instantiateMetavariable(string, context),
|
|
644
|
-
node = metavariableNode, ///
|
|
645
|
-
breakPoint = breakPointFromJSON(json),
|
|
646
|
-
name = nameFromMetavariableNode(metavariableNode, context),
|
|
647
|
-
term = termFromMetavariableNode(metavariableNode, context),
|
|
648
|
-
type = typeFromMetavariableNode(metavariableNode, context),
|
|
649
|
-
metaType = metaTypeFromJSON(json, context),
|
|
650
|
-
metavariable = new Metavariable(context, string, node, breakPoint, name, term, type, metaType);
|
|
651
|
-
|
|
652
|
-
return metavariable;
|
|
653
|
-
}, context);
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
static fromStatement(statement, context) {
|
|
657
|
-
const statementNode = statement.getNode(),
|
|
658
|
-
metavariable = metavariableFromStatementNode(statementNode, context);
|
|
659
|
-
|
|
660
|
-
return metavariable;
|
|
661
|
-
}
|
|
662
|
-
});
|