yukigo 0.2.3 → 0.3.2
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/.mocharc.json +3 -3
- package/CHANGELOG.md +105 -40
- package/README.md +193 -193
- package/dist/analyzer/GraphBuilder.d.ts +1 -0
- package/dist/analyzer/GraphBuilder.js +2 -1
- package/dist/analyzer/index.d.ts +0 -7
- package/dist/analyzer/index.js +3 -3
- package/dist/analyzer/inspections/functional/functional.d.ts +1 -1
- package/dist/analyzer/inspections/functional/functional.js +1 -1
- package/dist/analyzer/inspections/functional/smells.d.ts +3 -3
- package/dist/analyzer/inspections/functional/smells.js +27 -35
- package/dist/analyzer/inspections/generic/generic.d.ts +22 -14
- package/dist/analyzer/inspections/generic/generic.js +82 -60
- package/dist/analyzer/inspections/generic/smells.d.ts +2 -0
- package/dist/analyzer/inspections/generic/smells.js +55 -64
- package/dist/analyzer/inspections/imperative/imperative.d.ts +3 -3
- package/dist/analyzer/inspections/imperative/imperative.js +3 -3
- package/dist/analyzer/inspections/imperative/smells.d.ts +1 -0
- package/dist/analyzer/inspections/imperative/smells.js +8 -5
- package/dist/analyzer/inspections/logic/logic.d.ts +8 -8
- package/dist/analyzer/inspections/logic/logic.js +5 -5
- package/dist/analyzer/inspections/logic/smells.js +2 -2
- package/dist/analyzer/inspections/object/object.d.ts +5 -5
- package/dist/analyzer/inspections/object/object.js +22 -21
- package/dist/analyzer/inspections/object/smells.js +11 -23
- package/dist/analyzer/utils.d.ts +6 -2
- package/dist/analyzer/utils.js +6 -2
- package/dist/interpreter/components/EnvBuilder.d.ts +20 -1
- package/dist/interpreter/components/EnvBuilder.js +211 -66
- package/dist/interpreter/components/EqualityComparer.d.ts +15 -0
- package/dist/interpreter/components/EqualityComparer.js +69 -0
- package/dist/interpreter/components/Operations.d.ts +17 -14
- package/dist/interpreter/components/Operations.js +61 -62
- package/dist/interpreter/components/PatternMatcher.d.ts +19 -58
- package/dist/interpreter/components/PatternMatcher.js +185 -286
- package/dist/interpreter/components/RuntimeContext.d.ts +24 -15
- package/dist/interpreter/components/RuntimeContext.js +43 -4
- package/dist/interpreter/components/TestRunner.d.ts +15 -13
- package/dist/interpreter/components/TestRunner.js +86 -53
- package/dist/interpreter/components/evaluators/BaseEvaluator.d.ts +19 -0
- package/dist/interpreter/components/evaluators/BaseEvaluator.js +20 -0
- package/dist/interpreter/components/evaluators/ExpressionEvaluator.d.ts +34 -0
- package/dist/interpreter/components/evaluators/ExpressionEvaluator.js +298 -0
- package/dist/interpreter/components/evaluators/OperationEvaluator.d.ts +25 -0
- package/dist/interpreter/components/evaluators/OperationEvaluator.js +226 -0
- package/dist/interpreter/components/evaluators/PrimitiveEvaluator.d.ts +19 -0
- package/dist/interpreter/components/evaluators/PrimitiveEvaluator.js +50 -0
- package/dist/interpreter/components/evaluators/StatementEvaluator.d.ts +28 -0
- package/dist/interpreter/components/evaluators/StatementEvaluator.js +240 -0
- package/dist/interpreter/components/evaluators/TestingEvaluator.d.ts +15 -0
- package/dist/interpreter/components/evaluators/TestingEvaluator.js +14 -0
- package/dist/interpreter/components/evaluators/index.d.ts +110 -0
- package/dist/interpreter/components/evaluators/index.js +21 -0
- package/dist/interpreter/components/evaluators/utils.d.ts +7 -0
- package/dist/interpreter/components/evaluators/utils.js +50 -0
- package/dist/interpreter/components/hooks/YukigoHook.d.ts +27 -0
- package/dist/interpreter/components/hooks/YukigoHook.js +1 -0
- package/dist/interpreter/components/kernel/commands.d.ts +122 -0
- package/dist/interpreter/components/kernel/commands.js +203 -0
- package/dist/interpreter/components/kernel/index.d.ts +51 -0
- package/dist/interpreter/components/kernel/index.js +176 -0
- package/dist/interpreter/components/logic/LogicEngine.d.ts +26 -23
- package/dist/interpreter/components/logic/LogicEngine.js +234 -221
- package/dist/interpreter/components/logic/LogicResolver.d.ts +22 -51
- package/dist/interpreter/components/logic/LogicResolver.js +73 -440
- package/dist/interpreter/components/logic/LogicTerm.d.ts +104 -0
- package/dist/interpreter/components/logic/LogicTerm.js +423 -0
- package/dist/interpreter/components/logic/LogicTranslator.d.ts +25 -9
- package/dist/interpreter/components/logic/LogicTranslator.js +211 -74
- package/dist/interpreter/components/runtimes/FunctionRuntime.d.ts +6 -4
- package/dist/interpreter/components/runtimes/FunctionRuntime.js +82 -84
- package/dist/interpreter/components/runtimes/LazyRuntime.d.ts +13 -14
- package/dist/interpreter/components/runtimes/LazyRuntime.js +112 -239
- package/dist/interpreter/components/runtimes/ObjectRuntime.d.ts +17 -14
- package/dist/interpreter/components/runtimes/ObjectRuntime.js +105 -74
- package/dist/interpreter/errors.d.ts +10 -0
- package/dist/interpreter/errors.js +17 -0
- package/dist/interpreter/index.d.ts +9 -5
- package/dist/interpreter/index.js +11 -13
- package/dist/interpreter/primitives/YuValue.d.ts +21 -0
- package/dist/interpreter/primitives/YuValue.js +40 -0
- package/dist/interpreter/primitives/capabilities.d.ts +90 -0
- package/dist/interpreter/primitives/capabilities.js +1 -0
- package/dist/interpreter/primitives/entities/LazyList.d.ts +48 -0
- package/dist/interpreter/primitives/entities/LazyList.js +164 -0
- package/dist/interpreter/primitives/entities/LogicResult.d.ts +51 -0
- package/dist/interpreter/primitives/entities/LogicResult.js +101 -0
- package/dist/interpreter/primitives/entities/RuntimeClass.d.ts +24 -0
- package/dist/interpreter/primitives/entities/RuntimeClass.js +57 -0
- package/dist/interpreter/primitives/entities/RuntimeFunction.d.ts +40 -0
- package/dist/interpreter/primitives/entities/RuntimeFunction.js +73 -0
- package/dist/interpreter/primitives/entities/RuntimeObject.d.ts +27 -0
- package/dist/interpreter/primitives/entities/RuntimeObject.js +82 -0
- package/dist/interpreter/primitives/entities/RuntimePredicate.d.ts +19 -0
- package/dist/interpreter/primitives/entities/RuntimePredicate.js +59 -0
- package/dist/interpreter/primitives/index.d.ts +14 -0
- package/dist/interpreter/primitives/index.js +14 -0
- package/dist/interpreter/primitives/scalars/YuBoolean.d.ts +24 -0
- package/dist/interpreter/primitives/scalars/YuBoolean.js +69 -0
- package/dist/interpreter/primitives/scalars/YuChar.d.ts +28 -0
- package/dist/interpreter/primitives/scalars/YuChar.js +78 -0
- package/dist/interpreter/primitives/scalars/YuNil.d.ts +25 -0
- package/dist/interpreter/primitives/scalars/YuNil.js +73 -0
- package/dist/interpreter/primitives/scalars/YuNumber.d.ts +49 -0
- package/dist/interpreter/primitives/scalars/YuNumber.js +165 -0
- package/dist/interpreter/primitives/sequences/YuArray.d.ts +33 -0
- package/dist/interpreter/primitives/sequences/YuArray.js +150 -0
- package/dist/interpreter/primitives/sequences/YuString.d.ts +40 -0
- package/dist/interpreter/primitives/sequences/YuString.js +130 -0
- package/dist/interpreter/utils.d.ts +23 -10
- package/dist/interpreter/utils.js +25 -30
- package/dist/tester/index.d.ts +3 -3
- package/dist/tester/index.js +39 -28
- package/dist/utils/helpers.d.ts +13 -5
- package/dist/utils/helpers.js +38 -85
- package/package.json +3 -16
- package/src/analyzer/GraphBuilder.ts +143 -142
- package/src/analyzer/index.ts +185 -194
- package/src/analyzer/inspections/functional/functional.ts +121 -121
- package/src/analyzer/inspections/functional/smells.ts +88 -102
- package/src/analyzer/inspections/generic/generic.ts +610 -577
- package/src/analyzer/inspections/generic/smells.ts +355 -365
- package/src/analyzer/inspections/imperative/imperative.ts +104 -101
- package/src/analyzer/inspections/imperative/smells.ts +58 -54
- package/src/analyzer/inspections/logic/logic.ts +84 -90
- package/src/analyzer/inspections/logic/smells.ts +54 -54
- package/src/analyzer/inspections/object/object.ts +295 -264
- package/src/analyzer/inspections/object/smells.ts +130 -144
- package/src/analyzer/utils.ts +115 -109
- package/src/index.ts +3 -3
- package/src/interpreter/components/EnvBuilder.ts +405 -202
- package/src/interpreter/components/EqualityComparer.ts +107 -0
- package/src/interpreter/components/Operations.ts +126 -99
- package/src/interpreter/components/PatternMatcher.ts +375 -475
- package/src/interpreter/components/RuntimeContext.ts +181 -119
- package/src/interpreter/components/TestRunner.ts +223 -151
- package/src/interpreter/components/evaluators/BaseEvaluator.ts +36 -0
- package/src/interpreter/components/evaluators/ExpressionEvaluator.ts +475 -0
- package/src/interpreter/components/evaluators/OperationEvaluator.ts +477 -0
- package/src/interpreter/components/evaluators/PrimitiveEvaluator.ts +80 -0
- package/src/interpreter/components/evaluators/StatementEvaluator.ts +372 -0
- package/src/interpreter/components/evaluators/TestingEvaluator.ts +26 -0
- package/src/interpreter/components/evaluators/index.ts +34 -0
- package/src/interpreter/components/evaluators/utils.ts +64 -0
- package/src/interpreter/components/hooks/YukigoHook.ts +45 -0
- package/src/interpreter/components/kernel/commands.ts +255 -0
- package/src/interpreter/components/kernel/index.ts +222 -0
- package/src/interpreter/components/logic/LogicEngine.ts +509 -519
- package/src/interpreter/components/logic/LogicResolver.ts +209 -858
- package/src/interpreter/components/logic/LogicTerm.ts +477 -0
- package/src/interpreter/components/logic/LogicTranslator.ts +362 -149
- package/src/interpreter/components/runtimes/FunctionRuntime.ts +249 -227
- package/src/interpreter/components/runtimes/LazyRuntime.ts +226 -334
- package/src/interpreter/components/runtimes/ObjectRuntime.ts +262 -224
- package/src/interpreter/errors.ts +68 -47
- package/src/interpreter/index.ts +50 -52
- package/src/interpreter/primitives/YuValue.ts +64 -0
- package/src/interpreter/primitives/capabilities.ts +111 -0
- package/src/interpreter/primitives/entities/LazyList.ts +225 -0
- package/src/interpreter/primitives/entities/LogicResult.ts +133 -0
- package/src/interpreter/primitives/entities/RuntimeClass.ts +70 -0
- package/src/interpreter/primitives/entities/RuntimeFunction.ts +108 -0
- package/src/interpreter/primitives/entities/RuntimeObject.ts +110 -0
- package/src/interpreter/primitives/entities/RuntimePredicate.ts +77 -0
- package/src/interpreter/primitives/index.ts +17 -0
- package/src/interpreter/primitives/scalars/YuBoolean.ts +79 -0
- package/src/interpreter/primitives/scalars/YuChar.ts +94 -0
- package/src/interpreter/primitives/scalars/YuNil.ts +84 -0
- package/src/interpreter/primitives/scalars/YuNumber.ts +187 -0
- package/src/interpreter/primitives/sequences/YuArray.ts +178 -0
- package/src/interpreter/primitives/sequences/YuString.ts +165 -0
- package/src/interpreter/utils.ts +105 -84
- package/src/tester/index.ts +157 -128
- package/src/utils/helpers.ts +113 -169
- package/tests/analyzer/functional.spec.ts +221 -207
- package/tests/analyzer/generic.spec.ts +178 -178
- package/tests/analyzer/helpers.spec.ts +83 -89
- package/tests/analyzer/logic.spec.ts +237 -237
- package/tests/analyzer/oop.spec.ts +320 -323
- package/tests/analyzer/transitive.spec.ts +166 -166
- package/tests/interpreter/EnvBuilder.spec.ts +181 -183
- package/tests/interpreter/FunctionRuntime.spec.ts +224 -223
- package/tests/interpreter/LazyRuntime.spec.ts +227 -225
- package/tests/interpreter/LogicEngine.spec.ts +371 -327
- package/tests/interpreter/LogicSubstitution.spec.ts +90 -80
- package/tests/interpreter/ObjectRuntime.spec.ts +431 -606
- package/tests/interpreter/Operations.spec.ts +312 -220
- package/tests/interpreter/PatternSystem.spec.ts +254 -213
- package/tests/interpreter/Tests.spec.ts +122 -122
- package/tests/interpreter/interpreter.spec.ts +1143 -991
- package/tests/kernel/YukigoKernel.spec.ts +112 -0
- package/tests/tester/Tester.spec.ts +156 -152
- package/tsconfig.build.json +16 -15
- package/tsconfig.json +27 -25
- package/dist/interpreter/components/Visitor.d.ts +0 -70
- package/dist/interpreter/components/Visitor.js +0 -634
- package/dist/interpreter/entities.d.ts +0 -105
- package/dist/interpreter/entities.js +0 -96
- package/dist/interpreter/trampoline.d.ts +0 -17
- package/dist/interpreter/trampoline.js +0 -38
- package/dist/src/analyzer/GraphBuilder.d.ts +0 -30
- package/dist/src/analyzer/GraphBuilder.js +0 -100
- package/dist/src/analyzer/index.d.ts +0 -59
- package/dist/src/analyzer/index.js +0 -152
- package/dist/src/analyzer/inspections/functional/functional.d.ts +0 -44
- package/dist/src/analyzer/inspections/functional/functional.js +0 -149
- package/dist/src/analyzer/inspections/functional/smells.d.ts +0 -16
- package/dist/src/analyzer/inspections/functional/smells.js +0 -98
- package/dist/src/analyzer/inspections/generic/generic.d.ts +0 -178
- package/dist/src/analyzer/inspections/generic/generic.js +0 -604
- package/dist/src/analyzer/inspections/generic/smells.d.ts +0 -61
- package/dist/src/analyzer/inspections/generic/smells.js +0 -349
- package/dist/src/analyzer/inspections/imperative/imperative.d.ts +0 -35
- package/dist/src/analyzer/inspections/imperative/imperative.js +0 -109
- package/dist/src/analyzer/inspections/imperative/smells.d.ts +0 -16
- package/dist/src/analyzer/inspections/imperative/smells.js +0 -58
- package/dist/src/analyzer/inspections/logic/logic.d.ts +0 -32
- package/dist/src/analyzer/inspections/logic/logic.js +0 -96
- package/dist/src/analyzer/inspections/logic/smells.d.ts +0 -15
- package/dist/src/analyzer/inspections/logic/smells.js +0 -60
- package/dist/src/analyzer/inspections/object/object.d.ts +0 -90
- package/dist/src/analyzer/inspections/object/object.js +0 -321
- package/dist/src/analyzer/inspections/object/smells.d.ts +0 -30
- package/dist/src/analyzer/inspections/object/smells.js +0 -135
- package/dist/src/analyzer/utils.d.ts +0 -30
- package/dist/src/analyzer/utils.js +0 -78
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -4
- package/dist/src/interpreter/components/EnvBuilder.d.ts +0 -21
- package/dist/src/interpreter/components/EnvBuilder.js +0 -155
- package/dist/src/interpreter/components/Operations.d.ts +0 -14
- package/dist/src/interpreter/components/Operations.js +0 -84
- package/dist/src/interpreter/components/PatternMatcher.d.ts +0 -73
- package/dist/src/interpreter/components/PatternMatcher.js +0 -358
- package/dist/src/interpreter/components/RuntimeContext.d.ts +0 -35
- package/dist/src/interpreter/components/RuntimeContext.js +0 -93
- package/dist/src/interpreter/components/TestRunner.d.ts +0 -19
- package/dist/src/interpreter/components/TestRunner.js +0 -110
- package/dist/src/interpreter/components/Visitor.d.ts +0 -71
- package/dist/src/interpreter/components/Visitor.js +0 -638
- package/dist/src/interpreter/components/logic/LogicEngine.d.ts +0 -29
- package/dist/src/interpreter/components/logic/LogicEngine.js +0 -259
- package/dist/src/interpreter/components/logic/LogicResolver.d.ts +0 -53
- package/dist/src/interpreter/components/logic/LogicResolver.js +0 -484
- package/dist/src/interpreter/components/logic/LogicTranslator.d.ts +0 -14
- package/dist/src/interpreter/components/logic/LogicTranslator.js +0 -99
- package/dist/src/interpreter/components/runtimes/FunctionRuntime.d.ts +0 -12
- package/dist/src/interpreter/components/runtimes/FunctionRuntime.js +0 -149
- package/dist/src/interpreter/components/runtimes/LazyRuntime.d.ts +0 -19
- package/dist/src/interpreter/components/runtimes/LazyRuntime.js +0 -269
- package/dist/src/interpreter/components/runtimes/ObjectRuntime.d.ts +0 -35
- package/dist/src/interpreter/components/runtimes/ObjectRuntime.js +0 -126
- package/dist/src/interpreter/errors.d.ts +0 -19
- package/dist/src/interpreter/errors.js +0 -36
- package/dist/src/interpreter/index.d.ts +0 -24
- package/dist/src/interpreter/index.js +0 -41
- package/dist/src/interpreter/trampoline.d.ts +0 -17
- package/dist/src/interpreter/trampoline.js +0 -38
- package/dist/src/interpreter/utils.d.ts +0 -11
- package/dist/src/interpreter/utils.js +0 -65
- package/dist/src/tester/index.d.ts +0 -25
- package/dist/src/tester/index.js +0 -113
- package/dist/src/utils/helpers.d.ts +0 -13
- package/dist/src/utils/helpers.js +0 -52
- package/src/interpreter/components/Visitor.ts +0 -1065
- package/src/interpreter/trampoline.ts +0 -71
|
@@ -1,71 +1,32 @@
|
|
|
1
|
-
import { ApplicationPattern, AsPattern, ASTNode, ConsPattern, ConstructorPattern,
|
|
1
|
+
import { ApplicationPattern, AsPattern, ASTNode, ConsPattern, ConstructorPattern, FunctorPattern, ListPattern, LiteralPattern, TuplePattern, UnionPattern, VariablePattern, WildcardPattern, TypePattern } from "yukigo-ast";
|
|
2
2
|
import { Bindings } from "../index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ExecutionCommand } from "../components/kernel/commands.js";
|
|
4
4
|
import { RuntimeContext } from "./RuntimeContext.js";
|
|
5
|
-
import {
|
|
6
|
-
declare class SharedSequence {
|
|
7
|
-
private cache;
|
|
8
|
-
private source;
|
|
9
|
-
private isDone;
|
|
10
|
-
constructor(generatorFactory: () => Generator<PrimitiveValue, void, unknown>);
|
|
11
|
-
get(index: number): {
|
|
12
|
-
value: PrimitiveValue | null;
|
|
13
|
-
done: boolean;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface InternalConsState {
|
|
17
|
-
readonly head: PrimitiveValue;
|
|
18
|
-
readonly tailExpr: Expression;
|
|
19
|
-
readonly evaluator: ExpressionEvaluator;
|
|
20
|
-
readonly capturedEnv: EnvStack;
|
|
21
|
-
realizedTail?: PrimitiveValue;
|
|
22
|
-
}
|
|
23
|
-
export interface MemoizedLazyList extends LazyList {
|
|
24
|
-
_sequence: SharedSequence;
|
|
25
|
-
_offset: number;
|
|
26
|
-
_consState?: InternalConsState;
|
|
27
|
-
toJSON: () => any;
|
|
28
|
-
}
|
|
29
|
-
export declare function isMemoizedList(list: unknown): list is MemoizedLazyList;
|
|
30
|
-
export declare function createMemoizedStream(genFactory: () => Generator<PrimitiveValue, void, unknown>, sequence?: SharedSequence, offset?: number): MemoizedLazyList;
|
|
31
|
-
export declare class PatternResolver implements Visitor<string> {
|
|
32
|
-
visitVariablePattern(node: VariablePattern): string;
|
|
33
|
-
visitWildcardPattern(node: WildcardPattern): string;
|
|
34
|
-
visitLiteralPattern(node: LiteralPattern): string;
|
|
35
|
-
visitTuplePattern(node: TuplePattern): string;
|
|
36
|
-
visitListPattern(node: ListPattern): string;
|
|
37
|
-
visitConsPattern(node: ConsPattern): string;
|
|
38
|
-
visitConstructorPattern(node: ConstructorPattern): string;
|
|
39
|
-
visitFunctorPattern(node: FunctorPattern): string;
|
|
40
|
-
visitApplicationPattern(node: ApplicationPattern): string;
|
|
41
|
-
visitAsPattern(node: AsPattern): string;
|
|
42
|
-
visitTypePattern(node: TypePattern): string;
|
|
43
|
-
visit(node: ASTNode): string;
|
|
44
|
-
}
|
|
5
|
+
import { YuValue } from "../primitives/index.js";
|
|
45
6
|
/**
|
|
46
7
|
* Recursively matches a value against a pattern node.
|
|
47
8
|
* Updates `bindings` when variables are bound successfully.
|
|
48
9
|
* Returns true if the pattern matches, false otherwise.
|
|
49
10
|
*/
|
|
50
|
-
export declare class PatternMatcher
|
|
11
|
+
export declare class PatternMatcher {
|
|
51
12
|
private value;
|
|
52
13
|
private bindings;
|
|
53
14
|
private ctx;
|
|
54
|
-
constructor(value:
|
|
55
|
-
visitVariablePattern(node: VariablePattern):
|
|
56
|
-
visitWildcardPattern(node: WildcardPattern):
|
|
57
|
-
visitLiteralPattern(node: LiteralPattern):
|
|
58
|
-
visitTuplePattern(node: TuplePattern):
|
|
59
|
-
visitListPattern(node: ListPattern):
|
|
15
|
+
constructor(value: YuValue, bindings: Bindings, ctx: RuntimeContext);
|
|
16
|
+
visitVariablePattern(node: VariablePattern): ExecutionCommand;
|
|
17
|
+
visitWildcardPattern(node: WildcardPattern): ExecutionCommand;
|
|
18
|
+
visitLiteralPattern(node: LiteralPattern): ExecutionCommand;
|
|
19
|
+
visitTuplePattern(node: TuplePattern): ExecutionCommand;
|
|
20
|
+
visitListPattern(node: ListPattern): ExecutionCommand;
|
|
60
21
|
private matchList;
|
|
61
|
-
visitConsPattern(node: ConsPattern):
|
|
62
|
-
visitTypePattern(node: TypePattern):
|
|
22
|
+
visitConsPattern(node: ConsPattern): ExecutionCommand;
|
|
23
|
+
visitTypePattern(node: TypePattern): ExecutionCommand;
|
|
63
24
|
private resolveCons;
|
|
64
|
-
visitConstructorPattern(node: ConstructorPattern):
|
|
65
|
-
visitFunctorPattern(node: FunctorPattern):
|
|
66
|
-
visitApplicationPattern(node: ApplicationPattern):
|
|
67
|
-
visitAsPattern(node: AsPattern):
|
|
68
|
-
visitUnionPattern(node: UnionPattern):
|
|
69
|
-
visit(node: ASTNode):
|
|
25
|
+
visitConstructorPattern(node: ConstructorPattern): ExecutionCommand;
|
|
26
|
+
visitFunctorPattern(node: FunctorPattern): ExecutionCommand;
|
|
27
|
+
visitApplicationPattern(node: ApplicationPattern): ExecutionCommand;
|
|
28
|
+
visitAsPattern(node: AsPattern): ExecutionCommand;
|
|
29
|
+
visitUnionPattern(node: UnionPattern): ExecutionCommand;
|
|
30
|
+
visit(node: ASTNode): ExecutionCommand;
|
|
31
|
+
fallback(node: ASTNode): ExecutionCommand;
|
|
70
32
|
}
|
|
71
|
-
export {};
|
|
@@ -1,119 +1,9 @@
|
|
|
1
|
-
import { ConstructorPattern,
|
|
2
|
-
import {
|
|
3
|
-
import { getYukigoType } from "../utils.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
isDone = false;
|
|
8
|
-
constructor(generatorFactory) {
|
|
9
|
-
this.source = generatorFactory();
|
|
10
|
-
}
|
|
11
|
-
get(index) {
|
|
12
|
-
if (index < this.cache.length)
|
|
13
|
-
return { value: this.cache[index], done: false };
|
|
14
|
-
if (this.isDone)
|
|
15
|
-
return { value: null, done: true };
|
|
16
|
-
while (this.cache.length <= index) {
|
|
17
|
-
const next = this.source.next();
|
|
18
|
-
if (next.done) {
|
|
19
|
-
this.isDone = true;
|
|
20
|
-
return { value: null, done: true };
|
|
21
|
-
}
|
|
22
|
-
this.cache.push(next.value);
|
|
23
|
-
}
|
|
24
|
-
return { value: this.cache[index], done: false };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export function isMemoizedList(list) {
|
|
28
|
-
return (list &&
|
|
29
|
-
typeof list === "object" &&
|
|
30
|
-
"type" in list &&
|
|
31
|
-
"_offset" in list &&
|
|
32
|
-
"_sequence" in list);
|
|
33
|
-
}
|
|
34
|
-
export function createMemoizedStream(genFactory, sequence, offset = 0) {
|
|
35
|
-
const seq = sequence ?? new SharedSequence(genFactory);
|
|
36
|
-
return {
|
|
37
|
-
type: "LazyList",
|
|
38
|
-
_sequence: seq,
|
|
39
|
-
_offset: offset,
|
|
40
|
-
generator: function* () {
|
|
41
|
-
let currentIdx = offset;
|
|
42
|
-
while (true) {
|
|
43
|
-
const res = seq.get(currentIdx);
|
|
44
|
-
if (res.done)
|
|
45
|
-
return;
|
|
46
|
-
yield res.value;
|
|
47
|
-
currentIdx++;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
toJSON() {
|
|
51
|
-
const iterator = this.generator();
|
|
52
|
-
const buffer = [];
|
|
53
|
-
let next = iterator.next();
|
|
54
|
-
while (!next.done) {
|
|
55
|
-
buffer.push(next.value);
|
|
56
|
-
next = iterator.next();
|
|
57
|
-
}
|
|
58
|
-
return buffer;
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export class PatternResolver {
|
|
63
|
-
visitVariablePattern(node) {
|
|
64
|
-
return node.name.value;
|
|
65
|
-
}
|
|
66
|
-
visitWildcardPattern(node) {
|
|
67
|
-
return "_";
|
|
68
|
-
}
|
|
69
|
-
visitLiteralPattern(node) {
|
|
70
|
-
const { name } = node;
|
|
71
|
-
if (name instanceof ListPrimitive)
|
|
72
|
-
return String(name.value.map((elem) => elem.accept(this)));
|
|
73
|
-
return String(name.value);
|
|
74
|
-
}
|
|
75
|
-
visitTuplePattern(node) {
|
|
76
|
-
return String(node.elements.map((elem) => elem.accept(this)));
|
|
77
|
-
}
|
|
78
|
-
visitListPattern(node) {
|
|
79
|
-
const { elements } = node;
|
|
80
|
-
return elements.length === 0
|
|
81
|
-
? "[]"
|
|
82
|
-
: String(elements.map((elem) => elem.accept(this)));
|
|
83
|
-
}
|
|
84
|
-
visitConsPattern(node) {
|
|
85
|
-
const head = node.left.accept(this);
|
|
86
|
-
const tail = node.right.accept(this);
|
|
87
|
-
return `(${head}:${tail})`;
|
|
88
|
-
}
|
|
89
|
-
visitConstructorPattern(node) {
|
|
90
|
-
const constr = node.identifier.value;
|
|
91
|
-
const args = node.args.map((pat) => pat.accept(this)).join(" ");
|
|
92
|
-
return `${constr} ${args}`;
|
|
93
|
-
}
|
|
94
|
-
visitFunctorPattern(node) {
|
|
95
|
-
// Same as ConstructorPattern (alias)
|
|
96
|
-
return this.visitConstructorPattern(new ConstructorPattern(node.identifier, node.args));
|
|
97
|
-
}
|
|
98
|
-
visitApplicationPattern(node) {
|
|
99
|
-
// Same as FunctorPattern
|
|
100
|
-
return this.visitConstructorPattern(new ConstructorPattern(node.identifier, node.args));
|
|
101
|
-
}
|
|
102
|
-
visitAsPattern(node) {
|
|
103
|
-
const alias = node.left.accept(this);
|
|
104
|
-
const pattern = node.right.accept(this);
|
|
105
|
-
return `${alias}@${pattern}`;
|
|
106
|
-
}
|
|
107
|
-
visitTypePattern(node) {
|
|
108
|
-
const typeStr = node.targetType.toString();
|
|
109
|
-
return node.innerPattern
|
|
110
|
-
? `(${typeStr} ${node.innerPattern.accept(this)})`
|
|
111
|
-
: typeStr;
|
|
112
|
-
}
|
|
113
|
-
visit(node) {
|
|
114
|
-
return node.accept(this);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
1
|
+
import { ConstructorPattern, SimpleType, ListType, } from "yukigo-ast";
|
|
2
|
+
import { StepCommand, BindCommand, FailCommand, RaiseCommand, } from "../components/kernel/commands.js";
|
|
3
|
+
import { boolean, getYukigoType } from "../utils.js";
|
|
4
|
+
import { InterpreterError, UnexpectedNode } from "../errors.js";
|
|
5
|
+
import { EqualityComparer } from "./EqualityComparer.js";
|
|
6
|
+
import { YuBoolean, YuArray, isLazyList, YuNil, YuString, LazyList, LazyStepResult, YuChar, } from "../primitives/index.js";
|
|
117
7
|
/**
|
|
118
8
|
* Recursively matches a value against a pattern node.
|
|
119
9
|
* Updates `bindings` when variables are bound successfully.
|
|
@@ -129,185 +19,193 @@ export class PatternMatcher {
|
|
|
129
19
|
this.ctx = ctx;
|
|
130
20
|
}
|
|
131
21
|
visitVariablePattern(node) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return k(true);
|
|
135
|
-
};
|
|
22
|
+
this.bindings.push([node.name.value, this.value]);
|
|
23
|
+
return boolean(true);
|
|
136
24
|
}
|
|
137
25
|
visitWildcardPattern(node) {
|
|
138
|
-
return (
|
|
26
|
+
return boolean(true);
|
|
139
27
|
}
|
|
140
28
|
visitLiteralPattern(node) {
|
|
141
|
-
return (
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
29
|
+
return new BindCommand(this.ctx.forceValue(this.value), (val) => {
|
|
30
|
+
const visitor = this.ctx.evaluatorFactory(this.ctx);
|
|
31
|
+
const VisitorClass = visitor.constructor;
|
|
32
|
+
const literalValue = VisitorClass.evaluateLiteral(node.name, this.ctx);
|
|
33
|
+
return EqualityComparer.compare(val, literalValue, this.ctx);
|
|
34
|
+
});
|
|
145
35
|
}
|
|
146
36
|
visitTuplePattern(node) {
|
|
147
|
-
return (
|
|
37
|
+
return new BindCommand(this.ctx.forceValue(this.value), (forcedVal) => {
|
|
148
38
|
const processValue = (val) => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return k(true);
|
|
156
|
-
const matcher = new PatternMatcher(val[index], this.bindings, this.ctx);
|
|
157
|
-
return node.elements[index].accept(matcher)((isMatch) => {
|
|
158
|
-
if (!isMatch)
|
|
159
|
-
return k(false);
|
|
160
|
-
return () => matchNext(index + 1);
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
return matchNext(0);
|
|
39
|
+
const seq = val.asSequence;
|
|
40
|
+
if (!(seq instanceof YuArray))
|
|
41
|
+
return boolean(false);
|
|
42
|
+
if (seq.items.length !== node.elements.length)
|
|
43
|
+
return boolean(false);
|
|
44
|
+
return this.matchList(node.elements, seq, 0);
|
|
164
45
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
46
|
+
const valSeq = forcedVal.asSequence;
|
|
47
|
+
if (valSeq && isLazyList(valSeq)) {
|
|
48
|
+
return new BindCommand(this.ctx.lazyRuntime.realizeList(forcedVal), processValue);
|
|
169
49
|
}
|
|
170
|
-
return processValue(
|
|
171
|
-
};
|
|
50
|
+
return processValue(forcedVal);
|
|
51
|
+
});
|
|
172
52
|
}
|
|
173
53
|
visitListPattern(node) {
|
|
174
|
-
return (
|
|
175
|
-
const value = this.value;
|
|
54
|
+
return new BindCommand(this.ctx.forceValue(this.value), (value) => {
|
|
176
55
|
const neededLength = node.elements.length;
|
|
177
56
|
const finishMatching = (valArr) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
57
|
+
const seq = valArr.asSequence;
|
|
58
|
+
if (!(seq instanceof YuArray))
|
|
59
|
+
return new RaiseCommand(new InterpreterError("[PatternMatcher]", `Expected ${valArr} to be a list.`));
|
|
60
|
+
if (seq.items.length !== neededLength)
|
|
61
|
+
return boolean(false);
|
|
62
|
+
return this.matchList(node.elements, seq, 0);
|
|
181
63
|
};
|
|
182
|
-
// empty list case
|
|
183
64
|
if (neededLength === 0) {
|
|
184
|
-
if (
|
|
185
|
-
return
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
65
|
+
if (value instanceof YuNil)
|
|
66
|
+
return boolean(true);
|
|
67
|
+
const seq = value.asSequence;
|
|
68
|
+
if (seq) {
|
|
69
|
+
if (seq instanceof YuArray || seq instanceof YuString) {
|
|
70
|
+
return new StepCommand(new YuBoolean(seq.toJSON().length === 0));
|
|
71
|
+
}
|
|
72
|
+
if (isLazyList(seq)) {
|
|
73
|
+
return new BindCommand(seq.step(), (res) => boolean(res instanceof YuNil));
|
|
74
|
+
}
|
|
189
75
|
}
|
|
190
|
-
return
|
|
76
|
+
return boolean(false);
|
|
191
77
|
}
|
|
192
|
-
if (
|
|
193
|
-
return
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
78
|
+
if (value instanceof YuNil)
|
|
79
|
+
return boolean(false);
|
|
80
|
+
const seq = value.asSequence;
|
|
81
|
+
if (seq) {
|
|
82
|
+
if (seq instanceof YuArray)
|
|
83
|
+
return finishMatching(value);
|
|
84
|
+
if (seq instanceof YuString)
|
|
85
|
+
return new BindCommand(seq.split(), (splitted) => finishMatching(splitted));
|
|
86
|
+
if (isLazyList(seq)) {
|
|
87
|
+
return new BindCommand(this.ctx.lazyRuntime.realizeList(value), finishMatching);
|
|
88
|
+
}
|
|
200
89
|
}
|
|
201
|
-
return
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
matchList(elements, value,
|
|
205
|
-
if (
|
|
206
|
-
return
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return () => matchNext(index + 1);
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
return matchNext(0);
|
|
90
|
+
return boolean(false);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
matchList(elements, value, index) {
|
|
94
|
+
if (index >= elements.length)
|
|
95
|
+
return boolean(true);
|
|
96
|
+
const matcher = new PatternMatcher(value.at(index), this.bindings, this.ctx);
|
|
97
|
+
return new BindCommand(elements[index].accept(matcher), (res) => {
|
|
98
|
+
const isMatch = res instanceof YuBoolean && res.value;
|
|
99
|
+
if (!isMatch)
|
|
100
|
+
return boolean(false);
|
|
101
|
+
return this.matchList(elements, value, index + 1);
|
|
102
|
+
});
|
|
218
103
|
}
|
|
219
104
|
visitConsPattern(node) {
|
|
220
|
-
return (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
105
|
+
return new BindCommand(this.ctx.forceValue(this.value), (forcedVal) => {
|
|
106
|
+
return new BindCommand(this.resolveCons(forcedVal), (resolved) => {
|
|
107
|
+
if (!(resolved instanceof YuArray) || resolved.items.length !== 2)
|
|
108
|
+
return boolean(false);
|
|
109
|
+
const head = resolved.at(0);
|
|
110
|
+
const tail = resolved.at(1);
|
|
111
|
+
const headMatcher = new PatternMatcher(head, this.bindings, this.ctx);
|
|
112
|
+
return new BindCommand(node.left.accept(headMatcher), (headRes) => {
|
|
113
|
+
const headMatches = headRes instanceof YuBoolean && headRes.value;
|
|
114
|
+
if (!headMatches)
|
|
115
|
+
return boolean(false);
|
|
116
|
+
const tailMatcher = new PatternMatcher(tail, this.bindings, this.ctx);
|
|
117
|
+
return node.right.accept(tailMatcher);
|
|
118
|
+
});
|
|
230
119
|
});
|
|
231
|
-
};
|
|
120
|
+
});
|
|
232
121
|
}
|
|
233
122
|
visitTypePattern(node) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
123
|
+
const actualType = getYukigoType(this.value);
|
|
124
|
+
let matches = false;
|
|
125
|
+
const targetType = node.targetType;
|
|
126
|
+
if (targetType instanceof SimpleType) {
|
|
127
|
+
matches = targetType.value === actualType;
|
|
128
|
+
}
|
|
129
|
+
else if (targetType instanceof ListType) {
|
|
130
|
+
matches =
|
|
131
|
+
actualType === "List" ||
|
|
132
|
+
actualType === "Array" ||
|
|
133
|
+
actualType === "String";
|
|
134
|
+
}
|
|
135
|
+
if (!matches)
|
|
136
|
+
return boolean(false);
|
|
137
|
+
if (node.innerPattern) {
|
|
138
|
+
const innerMatcher = new PatternMatcher(this.value, this.bindings, this.ctx);
|
|
139
|
+
return node.innerPattern.accept(innerMatcher);
|
|
140
|
+
}
|
|
141
|
+
return boolean(true);
|
|
142
|
+
}
|
|
143
|
+
resolveCons(val) {
|
|
144
|
+
const list = val.asSequence;
|
|
145
|
+
if (!list)
|
|
146
|
+
return new StepCommand(YuNil.getInstance());
|
|
147
|
+
if (list instanceof YuArray) {
|
|
148
|
+
if (list.items.length === 0)
|
|
149
|
+
return new StepCommand(YuNil.getInstance());
|
|
257
150
|
const isLazy = this.ctx.config.lazyLoading;
|
|
258
151
|
if (!isLazy)
|
|
259
|
-
return
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
152
|
+
return new StepCommand(new YuArray([
|
|
153
|
+
list.at(0),
|
|
154
|
+
new YuArray(list.items.slice(list.index + 1)),
|
|
155
|
+
]));
|
|
156
|
+
const tail = new LazyList(() => {
|
|
157
|
+
const next = (arr, idx) => {
|
|
158
|
+
if (idx >= arr.items.length)
|
|
159
|
+
return new StepCommand(YuNil.getInstance());
|
|
160
|
+
return new StepCommand(new LazyStepResult(arr.items[idx], new LazyList(() => next(arr, idx + 1))));
|
|
161
|
+
};
|
|
162
|
+
return next(list, list.index + 1);
|
|
163
|
+
});
|
|
164
|
+
const arr = new YuArray([list.at(0), tail]);
|
|
165
|
+
return new StepCommand(arr);
|
|
268
166
|
}
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
|
|
167
|
+
if (list instanceof YuString) {
|
|
168
|
+
const s = list.toJSON();
|
|
169
|
+
if (s.length === 0)
|
|
170
|
+
return new StepCommand(YuNil.getInstance());
|
|
272
171
|
const isLazy = this.ctx.config.lazyLoading;
|
|
273
172
|
if (!isLazy)
|
|
274
|
-
return [
|
|
275
|
-
const tail = {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
173
|
+
return new StepCommand(new YuArray([new YuString(s[0]), new YuString(s.slice(1))]));
|
|
174
|
+
const tail = new LazyList(() => {
|
|
175
|
+
const next = (str, idx) => {
|
|
176
|
+
if (idx >= str.length)
|
|
177
|
+
return new StepCommand(YuNil.getInstance());
|
|
178
|
+
return new StepCommand(new LazyStepResult(new YuChar(str[idx]), new LazyList(() => next(str, idx + 1))));
|
|
179
|
+
};
|
|
180
|
+
return next(s, 1);
|
|
181
|
+
});
|
|
182
|
+
return new StepCommand(new YuArray([new YuChar(s[0]), tail]));
|
|
283
183
|
}
|
|
284
184
|
// lazy list case
|
|
285
185
|
if (isLazyList(list)) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const tail = createMemoizedStream(list.generator, memoList._sequence, memoList._offset + 1);
|
|
298
|
-
return [currentRes.value, tail];
|
|
186
|
+
return new BindCommand(list.step(), (stepRes) => {
|
|
187
|
+
if (stepRes.isNil)
|
|
188
|
+
return new StepCommand(YuNil.getInstance());
|
|
189
|
+
const stepResult = stepRes.asStepResult;
|
|
190
|
+
if (!stepResult)
|
|
191
|
+
return new RaiseCommand(new InterpreterError("PatternMatcher", "step did not return StepResult"));
|
|
192
|
+
return new StepCommand(new YuArray([
|
|
193
|
+
stepResult.head,
|
|
194
|
+
stepResult.tail || YuNil.getInstance(),
|
|
195
|
+
]));
|
|
196
|
+
});
|
|
299
197
|
}
|
|
300
|
-
return
|
|
198
|
+
return new StepCommand(YuNil.getInstance());
|
|
301
199
|
}
|
|
302
200
|
visitConstructorPattern(node) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
201
|
+
const seq = this.value.asSequence;
|
|
202
|
+
if (!(seq instanceof YuArray) || seq.items.length === 0)
|
|
203
|
+
return boolean(false);
|
|
204
|
+
const head = seq.at(0);
|
|
205
|
+
if (!(head instanceof YuString) || head.toJSON() !== node.identifier.value)
|
|
206
|
+
return boolean(false);
|
|
207
|
+
const args = new YuArray(seq.items.slice(seq.index + 1));
|
|
208
|
+
return this.matchList(node.args, args, 0);
|
|
311
209
|
}
|
|
312
210
|
visitFunctorPattern(node) {
|
|
313
211
|
return this.visitConstructorPattern(new ConstructorPattern(node.identifier, node.args));
|
|
@@ -316,36 +214,37 @@ export class PatternMatcher {
|
|
|
316
214
|
return this.visitConstructorPattern(new ConstructorPattern(node.identifier, node.args));
|
|
317
215
|
}
|
|
318
216
|
visitAsPattern(node) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
};
|
|
217
|
+
const innerMatcher = new PatternMatcher(this.value, this.bindings, this.ctx);
|
|
218
|
+
return new BindCommand(node.right.accept(innerMatcher), (res) => {
|
|
219
|
+
const innerMatches = res instanceof YuBoolean && res.value;
|
|
220
|
+
if (!innerMatches)
|
|
221
|
+
return boolean(false);
|
|
222
|
+
const aliasMatcher = new PatternMatcher(this.value, this.bindings, this.ctx);
|
|
223
|
+
return node.left.accept(aliasMatcher);
|
|
224
|
+
});
|
|
328
225
|
}
|
|
329
226
|
visitUnionPattern(node) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
345
|
-
return tryNext(0);
|
|
227
|
+
const tryNext = (index) => {
|
|
228
|
+
if (index >= node.elements.length)
|
|
229
|
+
return boolean(false);
|
|
230
|
+
const pattern = node.elements[index];
|
|
231
|
+
const trialBindings = [];
|
|
232
|
+
const matcher = new PatternMatcher(this.value, trialBindings, this.ctx);
|
|
233
|
+
return new BindCommand(pattern.accept(matcher), (res) => {
|
|
234
|
+
const isMatch = res instanceof YuBoolean && res.value;
|
|
235
|
+
if (isMatch) {
|
|
236
|
+
this.bindings.push(...trialBindings);
|
|
237
|
+
return boolean(true);
|
|
238
|
+
}
|
|
239
|
+
return tryNext(index + 1);
|
|
240
|
+
});
|
|
346
241
|
};
|
|
242
|
+
return tryNext(0);
|
|
347
243
|
}
|
|
348
244
|
visit(node) {
|
|
349
245
|
return node.accept(this);
|
|
350
246
|
}
|
|
247
|
+
fallback(node) {
|
|
248
|
+
return new FailCommand(new UnexpectedNode(node.constructor.name, "PatternMatcher"));
|
|
249
|
+
}
|
|
351
250
|
}
|