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
package/.mocharc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extension": ["ts"],
|
|
3
|
-
"spec": "tests/**/*.spec.ts"
|
|
1
|
+
{
|
|
2
|
+
"extension": ["ts"],
|
|
3
|
+
"spec": "tests/**/*.spec.ts"
|
|
4
4
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,70 +1,135 @@
|
|
|
1
|
-
## 0.2
|
|
1
|
+
## 0.3.2 (2026-08-04)
|
|
2
2
|
|
|
3
3
|
### 🩹 Fixes
|
|
4
4
|
|
|
5
|
-
- **yukigo:** fix
|
|
6
|
-
|
|
7
|
-
### ❤️ Thank You
|
|
8
|
-
|
|
9
|
-
- noiseArch
|
|
10
|
-
|
|
11
|
-
## 0.2.2 (2026-05-01)
|
|
12
|
-
|
|
13
|
-
### 🩹 Fixes
|
|
14
|
-
|
|
15
|
-
- **yukigo:** MulangAdapter handle v1 and v2 inspections ([872558f](https://github.com/miyukiproject/yukigo/commit/872558f))
|
|
5
|
+
- **yukigo:** fix v0 Mulang Inspections translation ([2995ccc](https://github.com/miyukiproject/yukigo/commit/2995ccc))
|
|
16
6
|
|
|
17
7
|
### 🧱 Updated Dependencies
|
|
18
8
|
|
|
19
|
-
- Updated yukigo-ast to 0.2
|
|
9
|
+
- Updated yukigo-ast to 0.3.2
|
|
20
10
|
|
|
21
11
|
### ❤️ Thank You
|
|
22
12
|
|
|
23
13
|
- noiseArch
|
|
24
14
|
|
|
25
|
-
## 0.
|
|
26
|
-
|
|
27
|
-
### 🩹 Fixes
|
|
28
|
-
|
|
29
|
-
- **yukigo:** MulangAdapter handle v1 and v2 inspections ([872558f](https://github.com/miyukiproject/yukigo/commit/872558f))
|
|
15
|
+
## 0.3.1 (2026-08-01)
|
|
30
16
|
|
|
31
17
|
### 🧱 Updated Dependencies
|
|
32
18
|
|
|
33
|
-
- Updated yukigo-ast to 0.
|
|
19
|
+
- Updated yukigo-ast to 0.3.1
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- noiseArch
|
|
38
|
-
|
|
39
|
-
## 0.2.0 (2026-04-11)
|
|
21
|
+
## 0.3.0 (2026-08-01)
|
|
40
22
|
|
|
41
23
|
### 🚀 Features
|
|
42
24
|
|
|
43
|
-
-
|
|
25
|
+
- Interpreter NativeBody support & YukigoHooks ([0b854b4](https://github.com/miyukiproject/yukigo/commit/0b854b4))
|
|
26
|
+
- **interpreter:** implement semantic error handling and stack traces ([b61768f](https://github.com/miyukiproject/yukigo/commit/b61768f))
|
|
27
|
+
- **interpreter:** integrate Kernel as the primary execution engine ([503af3d](https://github.com/miyukiproject/yukigo/commit/503af3d))
|
|
28
|
+
- **interpreter:** introduce YukigoKernel and command-based infrastructure ([9380892](https://github.com/miyukiproject/yukigo/commit/9380892))
|
|
29
|
+
- **yukigo:** implement and test YukigoKernel ([3d42ac4](https://github.com/miyukiproject/yukigo/commit/3d42ac4))
|
|
44
30
|
|
|
45
31
|
### 🩹 Fixes
|
|
46
32
|
|
|
47
|
-
- **yukigo:**
|
|
48
|
-
- **yukigo:**
|
|
49
|
-
- **yukigo:**
|
|
50
|
-
- **yukigo:**
|
|
51
|
-
- **yukigo:**
|
|
52
|
-
- **yukigo:**
|
|
53
|
-
- **yukigo:**
|
|
54
|
-
-
|
|
55
|
-
- **yukigo:**
|
|
33
|
+
- **yukigo-e2e:** fixes to pass E2E tests ([02d895f](https://github.com/miyukiproject/yukigo/commit/02d895f))
|
|
34
|
+
- **yukigo:** allow concatenation with Plus operator ([7799416](https://github.com/miyukiproject/yukigo/commit/7799416))
|
|
35
|
+
- **yukigo:** fix circular dependency ([64534a8](https://github.com/miyukiproject/yukigo/commit/64534a8))
|
|
36
|
+
- **yukigo:** failed test didnt throw bc now it handles 1 + "a" ([23ebeb6](https://github.com/miyukiproject/yukigo/commit/23ebeb6))
|
|
37
|
+
- **yukigo:** zero-arity functions and Wollok bugs ([995dad4](https://github.com/miyukiproject/yukigo/commit/995dad4))
|
|
38
|
+
- **yukigo:** ObjectRuntime error should return RaiseCommand not FailCommand ([ccb31fa](https://github.com/miyukiproject/yukigo/commit/ccb31fa))
|
|
39
|
+
- **yukigo:** method registration with arity to allow overload ([8ffcb36](https://github.com/miyukiproject/yukigo/commit/8ffcb36))
|
|
40
|
+
- TypeSignature is not a Binding ([13c2c5a](https://github.com/miyukiproject/yukigo/commit/13c2c5a))
|
|
41
|
+
- **yukigo:** support If and Call nodes in LogicEngine ([a0f4086](https://github.com/miyukiproject/yukigo/commit/a0f4086))
|
|
42
|
+
- **yukigo:** fixed functional tester was evaluating logic tests ([914310e](https://github.com/miyukiproject/yukigo/commit/914310e))
|
|
43
|
+
- **yukigo:** solved scope leak at logical binary operations ([8779899](https://github.com/miyukiproject/yukigo/commit/8779899))
|
|
44
|
+
- ToString operator ([f5284ab](https://github.com/miyukiproject/yukigo/commit/f5284ab))
|
|
45
|
+
- **yukigo:** fix pattern matching in FunctionRuntime ([467cdf7](https://github.com/miyukiproject/yukigo/commit/467cdf7))
|
|
46
|
+
- **yukigo:** fix bitwise negation ([b13ef4d](https://github.com/miyukiproject/yukigo/commit/b13ef4d))
|
|
47
|
+
- **yukigo:** fix asynchronous logic unification and parameter resolution ([e467068](https://github.com/miyukiproject/yukigo/commit/e467068))
|
|
48
|
+
- **yukigo:** arreglo operaciones y sustitucion logica ([c95f33f](https://github.com/miyukiproject/yukigo/commit/c95f33f))
|
|
49
|
+
- fix parsers grammar compilation to export to .cjs ([ef59727](https://github.com/miyukiproject/yukigo/commit/ef59727))
|
|
50
|
+
- **yukigo:** fix tests to reflect correct representations ([76b1512](https://github.com/miyukiproject/yukigo/commit/76b1512))
|
|
51
|
+
- **yukigo:** fix Visitor and LazyRuntime to use new correct methods from context ([0eb9168](https://github.com/miyukiproject/yukigo/commit/0eb9168))
|
|
52
|
+
- **yukigo:** arreglos en logicengine ([0604555](https://github.com/miyukiproject/yukigo/commit/0604555))
|
|
53
|
+
- **yukigo:** fix mini error in oop test ([b9fd07e](https://github.com/miyukiproject/yukigo/commit/b9fd07e))
|
|
54
|
+
- **yukigo:** removed unwanted error handling ([0d1ff15](https://github.com/miyukiproject/yukigo/commit/0d1ff15))
|
|
55
|
+
- **yukigo:** replace instanceof with .is method in analyzer ([d953413](https://github.com/miyukiproject/yukigo/commit/d953413))
|
|
56
|
+
- **yukigo:** add InterpreterConfig as export ([280146c](https://github.com/miyukiproject/yukigo/commit/280146c))
|
|
56
57
|
|
|
57
58
|
### 🧱 Updated Dependencies
|
|
58
59
|
|
|
59
|
-
- Updated yukigo-ast to 0.
|
|
60
|
+
- Updated yukigo-ast to 0.3.0
|
|
60
61
|
|
|
61
62
|
### ❤️ Thank You
|
|
62
63
|
|
|
63
64
|
- noiseArch
|
|
64
65
|
|
|
65
|
-
## 0.
|
|
66
|
-
|
|
67
|
-
###
|
|
68
|
-
|
|
69
|
-
-
|
|
66
|
+
## 0.2.3 (2026-05-02)
|
|
67
|
+
|
|
68
|
+
### 🩹 Fixes
|
|
69
|
+
|
|
70
|
+
- **yukigo:** fix bugs on MulangAdapter ([7fc193d](https://github.com/miyukiproject/yukigo/commit/7fc193d))
|
|
71
|
+
|
|
72
|
+
### ❤️ Thank You
|
|
73
|
+
|
|
74
|
+
- noiseArch
|
|
75
|
+
|
|
76
|
+
## 0.2.2 (2026-05-01)
|
|
77
|
+
|
|
78
|
+
### 🩹 Fixes
|
|
79
|
+
|
|
80
|
+
- **yukigo:** MulangAdapter handle v1 and v2 inspections ([872558f](https://github.com/miyukiproject/yukigo/commit/872558f))
|
|
81
|
+
|
|
82
|
+
### 🧱 Updated Dependencies
|
|
83
|
+
|
|
84
|
+
- Updated yukigo-ast to 0.2.1
|
|
85
|
+
|
|
86
|
+
### ❤️ Thank You
|
|
87
|
+
|
|
88
|
+
- noiseArch
|
|
89
|
+
|
|
90
|
+
## 0.2.1 (2026-05-01)
|
|
91
|
+
|
|
92
|
+
### 🩹 Fixes
|
|
93
|
+
|
|
94
|
+
- **yukigo:** MulangAdapter handle v1 and v2 inspections ([872558f](https://github.com/miyukiproject/yukigo/commit/872558f))
|
|
95
|
+
|
|
96
|
+
### 🧱 Updated Dependencies
|
|
97
|
+
|
|
98
|
+
- Updated yukigo-ast to 0.2.0
|
|
99
|
+
|
|
100
|
+
### ❤️ Thank You
|
|
101
|
+
|
|
102
|
+
- noiseArch
|
|
103
|
+
|
|
104
|
+
## 0.2.0 (2026-04-11)
|
|
105
|
+
|
|
106
|
+
### 🚀 Features
|
|
107
|
+
|
|
108
|
+
- **yukigo:** agrego `clone` a `RuntimeContext` para clonar el entorno ([ee8e0af](https://github.com/miyukiproject/yukigo/commit/ee8e0af))
|
|
109
|
+
|
|
110
|
+
### 🩹 Fixes
|
|
111
|
+
|
|
112
|
+
- **yukigo:** permitir a las inspections tener args undefined ([4f36ebe](https://github.com/miyukiproject/yukigo/commit/4f36ebe))
|
|
113
|
+
- **yukigo:** Evaluar `Equal` y `NotEqual` fuera de `processBinary` ([31eca15](https://github.com/miyukiproject/yukigo/commit/31eca15))
|
|
114
|
+
- **yukigo:** delegue logica de deepEqual a LazyRuntime ([8496113](https://github.com/miyukiproject/yukigo/commit/8496113))
|
|
115
|
+
- **yukigo:** evaluateConcatLazy permite eager y lazy evaluation ([3faf646](https://github.com/miyukiproject/yukigo/commit/3faf646))
|
|
116
|
+
- **yukigo:** corrijo `isEqual` para que compare strings con listas ([d6225c9](https://github.com/miyukiproject/yukigo/commit/d6225c9))
|
|
117
|
+
- **yukigo:** corrijo manejo de entorno en `applyArguments` y `visitApplication` ([5c7ab1f](https://github.com/miyukiproject/yukigo/commit/5c7ab1f))
|
|
118
|
+
- **yukigo:** capturar correctamente el entorno en `evaluateCons` ([a1bc7a4](https://github.com/miyukiproject/yukigo/commit/a1bc7a4))
|
|
119
|
+
- **yukigo:** `popEnv` no tiene que esperar el `env` por parametro ([575bacf](https://github.com/miyukiproject/yukigo/commit/575bacf))
|
|
120
|
+
- **yukigo:** agrego metodo visitTypeCast faltante ([61c9984](https://github.com/miyukiproject/yukigo/commit/61c9984))
|
|
121
|
+
|
|
122
|
+
### 🧱 Updated Dependencies
|
|
123
|
+
|
|
124
|
+
- Updated yukigo-ast to 0.2.0
|
|
125
|
+
|
|
126
|
+
### ❤️ Thank You
|
|
127
|
+
|
|
128
|
+
- noiseArch
|
|
129
|
+
|
|
130
|
+
## 0.1.0 (2025-12-09)
|
|
131
|
+
|
|
132
|
+
### 🧱 Updated Dependencies
|
|
133
|
+
|
|
134
|
+
- Updated yukigo-prolog-parser to 0.1.0
|
|
70
135
|
- Updated yukigo-ast to 0.1.0
|
package/README.md
CHANGED
|
@@ -1,193 +1,193 @@
|
|
|
1
|
-
# ❄️ Yukigo
|
|
2
|
-
A universal, multi-language, multi-paradigm code analyzer highly inspired in [mulang](https://github.com/mumuki/mulang)
|
|
3
|
-
|
|
4
|
-
## Components
|
|
5
|
-
|
|
6
|
-
### **Abstract Semantic Tree:**
|
|
7
|
-
|
|
8
|
-
This is the intermediate representation of any language. Allows us to analyse the semantics of the code independently of the paradigm or the language.
|
|
9
|
-
|
|
10
|
-
### **Analyzer:**
|
|
11
|
-
|
|
12
|
-
The Analyzer is the component that traverses the AST and runs the specified inspections.
|
|
13
|
-
|
|
14
|
-
### **Interpreter:**
|
|
15
|
-
|
|
16
|
-
The Interpreter is the component that evaluates provided Expression nodes and returns the resultant PrimitiveValue
|
|
17
|
-
|
|
18
|
-
# Usage
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
We will be using Haskell as the target language in this example.
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
npm install yukigo yukigo-haskell-parser
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
or
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
yarn add yukigo yukigo-haskell-parser
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Example
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
import { Analyzer } from "yukigo";
|
|
38
|
-
import { YukigoHaskellParser } from "yukigo-haskell-parser";
|
|
39
|
-
|
|
40
|
-
const code = "doble num = num * 2";
|
|
41
|
-
const expectations = [
|
|
42
|
-
{
|
|
43
|
-
inspection: "HasBinding",
|
|
44
|
-
args: { name: "minimoEntre" },
|
|
45
|
-
expected: false,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
inspection: "HasBinding",
|
|
49
|
-
args: { name: "doble" },
|
|
50
|
-
expected: true,
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
const parser = new YukigoHaskellParser();
|
|
55
|
-
const ast = parser.parse(code);
|
|
56
|
-
|
|
57
|
-
const analyzer = new ASTAnalyzer(ast);
|
|
58
|
-
const result = analyzer.analyse(expectations);
|
|
59
|
-
|
|
60
|
-
console.log(results);
|
|
61
|
-
// [
|
|
62
|
-
// {
|
|
63
|
-
// rule: {
|
|
64
|
-
// inspection: "HasBinding",
|
|
65
|
-
// args: { name: "minimoEntre" },
|
|
66
|
-
// expected: false,
|
|
67
|
-
// },
|
|
68
|
-
// passed: true,
|
|
69
|
-
// actual: false,
|
|
70
|
-
// },
|
|
71
|
-
// {
|
|
72
|
-
// rule: {
|
|
73
|
-
// inspection: "HasBinding",
|
|
74
|
-
// args: { name: "doble" },
|
|
75
|
-
// expected: true,
|
|
76
|
-
// },
|
|
77
|
-
// passed: true,
|
|
78
|
-
// actual: true,
|
|
79
|
-
// },
|
|
80
|
-
// ];
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Example with Mulang's Inspections (in a YAML file)
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
import { Analyzer, translateMulangToInspectionRules } from "yukigo";
|
|
87
|
-
import { YukigoHaskellParser } from "yukigo-haskell-parser";
|
|
88
|
-
|
|
89
|
-
const code = `
|
|
90
|
-
squareList :: [Int] -> [Int]
|
|
91
|
-
squareList xs = map (\n -> n * n) xs
|
|
92
|
-
|
|
93
|
-
square :: Int -> Int
|
|
94
|
-
square n = n * n
|
|
95
|
-
|
|
96
|
-
squareList2 :: [Int] -> [Int]
|
|
97
|
-
squareList2 = map square
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
|
-
// Assuming the expectations are in a yaml file. Implement a way to load the actual file.
|
|
101
|
-
const mulangInspections = `
|
|
102
|
-
expectations:
|
|
103
|
-
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
104
|
-
binding: squareList
|
|
105
|
-
inspection: HasBinding
|
|
106
|
-
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
107
|
-
binding: squareList
|
|
108
|
-
inspection: HasLambdaExpression
|
|
109
|
-
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
110
|
-
binding: square
|
|
111
|
-
inspection: HasArithmetic
|
|
112
|
-
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
113
|
-
binding: doble
|
|
114
|
-
inspection: Not:HasBinding
|
|
115
|
-
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
116
|
-
binding: square
|
|
117
|
-
inspection: Uses:n
|
|
118
|
-
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
119
|
-
binding: squareList2
|
|
120
|
-
inspection: Uses:map
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
|
-
const expectations = translateMulangToInspectionRules(mulangInspections);
|
|
124
|
-
|
|
125
|
-
const parser = new YukigoHaskellParser();
|
|
126
|
-
const ast = parser.parse(code);
|
|
127
|
-
|
|
128
|
-
const analyzer = new Analyzer(ast);
|
|
129
|
-
const result = analyzer.analyse(expectations);
|
|
130
|
-
|
|
131
|
-
console.log(results);
|
|
132
|
-
// [
|
|
133
|
-
// {
|
|
134
|
-
// rule: { inspection: "HasBinding", args: [Object], expected: true },
|
|
135
|
-
// passed: true,
|
|
136
|
-
// actual: true,
|
|
137
|
-
// },
|
|
138
|
-
// {
|
|
139
|
-
// rule: {
|
|
140
|
-
// inspection: "HasLambdaExpression",
|
|
141
|
-
// args: [Object],
|
|
142
|
-
// expected: true,
|
|
143
|
-
// },
|
|
144
|
-
// passed: true,
|
|
145
|
-
// actual: true,
|
|
146
|
-
// },
|
|
147
|
-
// {
|
|
148
|
-
// rule: { inspection: "HasArithmetic", args: [Object], expected: true },
|
|
149
|
-
// passed: true,
|
|
150
|
-
// actual: true,
|
|
151
|
-
// },
|
|
152
|
-
// {
|
|
153
|
-
// rule: { inspection: "HasBinding", args: [Object], expected: false },
|
|
154
|
-
// passed: true,
|
|
155
|
-
// actual: false,
|
|
156
|
-
// },
|
|
157
|
-
// {
|
|
158
|
-
// rule: { inspection: "Uses", args: [Object], expected: true },
|
|
159
|
-
// passed: true,
|
|
160
|
-
// actual: true,
|
|
161
|
-
// },
|
|
162
|
-
// {
|
|
163
|
-
// rule: { inspection: "Uses", args: [Object], expected: true },
|
|
164
|
-
// passed: true,
|
|
165
|
-
// actual: true,
|
|
166
|
-
// },
|
|
167
|
-
// ];
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
# Relevant tools
|
|
171
|
-
- yukigo-ast: A library of AST node definitions and utilities for making yukigo parsers
|
|
172
|
-
|
|
173
|
-
## Tools
|
|
174
|
-
- [CLI](https://github.com/noiseArch/yukigo-cli)
|
|
175
|
-
- create-yukigo-parser: A scaffolding tool to quickstart a yukigo parser with recommended configuration
|
|
176
|
-
|
|
177
|
-
## Parsers
|
|
178
|
-
- Haskell
|
|
179
|
-
- Prolog
|
|
180
|
-
- Wollok
|
|
181
|
-
|
|
182
|
-
# How to make a parser
|
|
183
|
-
|
|
184
|
-
A yukigo's parser is a class that implements the interface `YukigoParser` which exposes a public method called `parse` and an `errors` array like this:
|
|
185
|
-
```ts
|
|
186
|
-
errors: string[];
|
|
187
|
-
parse: (code: string) => AST;
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
The package `yukigo-ast` has all the current supported AST nodes.
|
|
191
|
-
For the grammar, you can use a tool like Jison or Nearley.
|
|
192
|
-
|
|
193
|
-
Here's a [tutorial](https://miyukiproject.github.io/yukigo/guides/making-a-parser.html) for implementing a small custom language.
|
|
1
|
+
# ❄️ Yukigo
|
|
2
|
+
A universal, multi-language, multi-paradigm code analyzer highly inspired in [mulang](https://github.com/mumuki/mulang)
|
|
3
|
+
|
|
4
|
+
## Components
|
|
5
|
+
|
|
6
|
+
### **Abstract Semantic Tree:**
|
|
7
|
+
|
|
8
|
+
This is the intermediate representation of any language. Allows us to analyse the semantics of the code independently of the paradigm or the language.
|
|
9
|
+
|
|
10
|
+
### **Analyzer:**
|
|
11
|
+
|
|
12
|
+
The Analyzer is the component that traverses the AST and runs the specified inspections.
|
|
13
|
+
|
|
14
|
+
### **Interpreter:**
|
|
15
|
+
|
|
16
|
+
The Interpreter is the component that evaluates provided Expression nodes and returns the resultant PrimitiveValue
|
|
17
|
+
|
|
18
|
+
# Usage
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
We will be using Haskell as the target language in this example.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
npm install yukigo yukigo-haskell-parser
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
or
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
yarn add yukigo yukigo-haskell-parser
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Analyzer } from "yukigo";
|
|
38
|
+
import { YukigoHaskellParser } from "yukigo-haskell-parser";
|
|
39
|
+
|
|
40
|
+
const code = "doble num = num * 2";
|
|
41
|
+
const expectations = [
|
|
42
|
+
{
|
|
43
|
+
inspection: "HasBinding",
|
|
44
|
+
args: { name: "minimoEntre" },
|
|
45
|
+
expected: false,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
inspection: "HasBinding",
|
|
49
|
+
args: { name: "doble" },
|
|
50
|
+
expected: true,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const parser = new YukigoHaskellParser();
|
|
55
|
+
const ast = parser.parse(code);
|
|
56
|
+
|
|
57
|
+
const analyzer = new ASTAnalyzer(ast);
|
|
58
|
+
const result = analyzer.analyse(expectations);
|
|
59
|
+
|
|
60
|
+
console.log(results);
|
|
61
|
+
// [
|
|
62
|
+
// {
|
|
63
|
+
// rule: {
|
|
64
|
+
// inspection: "HasBinding",
|
|
65
|
+
// args: { name: "minimoEntre" },
|
|
66
|
+
// expected: false,
|
|
67
|
+
// },
|
|
68
|
+
// passed: true,
|
|
69
|
+
// actual: false,
|
|
70
|
+
// },
|
|
71
|
+
// {
|
|
72
|
+
// rule: {
|
|
73
|
+
// inspection: "HasBinding",
|
|
74
|
+
// args: { name: "doble" },
|
|
75
|
+
// expected: true,
|
|
76
|
+
// },
|
|
77
|
+
// passed: true,
|
|
78
|
+
// actual: true,
|
|
79
|
+
// },
|
|
80
|
+
// ];
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Example with Mulang's Inspections (in a YAML file)
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { Analyzer, translateMulangToInspectionRules } from "yukigo";
|
|
87
|
+
import { YukigoHaskellParser } from "yukigo-haskell-parser";
|
|
88
|
+
|
|
89
|
+
const code = `
|
|
90
|
+
squareList :: [Int] -> [Int]
|
|
91
|
+
squareList xs = map (\n -> n * n) xs
|
|
92
|
+
|
|
93
|
+
square :: Int -> Int
|
|
94
|
+
square n = n * n
|
|
95
|
+
|
|
96
|
+
squareList2 :: [Int] -> [Int]
|
|
97
|
+
squareList2 = map square
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
// Assuming the expectations are in a yaml file. Implement a way to load the actual file.
|
|
101
|
+
const mulangInspections = `
|
|
102
|
+
expectations:
|
|
103
|
+
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
104
|
+
binding: squareList
|
|
105
|
+
inspection: HasBinding
|
|
106
|
+
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
107
|
+
binding: squareList
|
|
108
|
+
inspection: HasLambdaExpression
|
|
109
|
+
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
110
|
+
binding: square
|
|
111
|
+
inspection: HasArithmetic
|
|
112
|
+
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
113
|
+
binding: doble
|
|
114
|
+
inspection: Not:HasBinding
|
|
115
|
+
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
116
|
+
binding: square
|
|
117
|
+
inspection: Uses:n
|
|
118
|
+
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
119
|
+
binding: squareList2
|
|
120
|
+
inspection: Uses:map
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
const expectations = translateMulangToInspectionRules(mulangInspections);
|
|
124
|
+
|
|
125
|
+
const parser = new YukigoHaskellParser();
|
|
126
|
+
const ast = parser.parse(code);
|
|
127
|
+
|
|
128
|
+
const analyzer = new Analyzer(ast);
|
|
129
|
+
const result = analyzer.analyse(expectations);
|
|
130
|
+
|
|
131
|
+
console.log(results);
|
|
132
|
+
// [
|
|
133
|
+
// {
|
|
134
|
+
// rule: { inspection: "HasBinding", args: [Object], expected: true },
|
|
135
|
+
// passed: true,
|
|
136
|
+
// actual: true,
|
|
137
|
+
// },
|
|
138
|
+
// {
|
|
139
|
+
// rule: {
|
|
140
|
+
// inspection: "HasLambdaExpression",
|
|
141
|
+
// args: [Object],
|
|
142
|
+
// expected: true,
|
|
143
|
+
// },
|
|
144
|
+
// passed: true,
|
|
145
|
+
// actual: true,
|
|
146
|
+
// },
|
|
147
|
+
// {
|
|
148
|
+
// rule: { inspection: "HasArithmetic", args: [Object], expected: true },
|
|
149
|
+
// passed: true,
|
|
150
|
+
// actual: true,
|
|
151
|
+
// },
|
|
152
|
+
// {
|
|
153
|
+
// rule: { inspection: "HasBinding", args: [Object], expected: false },
|
|
154
|
+
// passed: true,
|
|
155
|
+
// actual: false,
|
|
156
|
+
// },
|
|
157
|
+
// {
|
|
158
|
+
// rule: { inspection: "Uses", args: [Object], expected: true },
|
|
159
|
+
// passed: true,
|
|
160
|
+
// actual: true,
|
|
161
|
+
// },
|
|
162
|
+
// {
|
|
163
|
+
// rule: { inspection: "Uses", args: [Object], expected: true },
|
|
164
|
+
// passed: true,
|
|
165
|
+
// actual: true,
|
|
166
|
+
// },
|
|
167
|
+
// ];
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
# Relevant tools
|
|
171
|
+
- yukigo-ast: A library of AST node definitions and utilities for making yukigo parsers
|
|
172
|
+
|
|
173
|
+
## Tools
|
|
174
|
+
- [CLI](https://github.com/noiseArch/yukigo-cli)
|
|
175
|
+
- create-yukigo-parser: A scaffolding tool to quickstart a yukigo parser with recommended configuration
|
|
176
|
+
|
|
177
|
+
## Parsers
|
|
178
|
+
- Haskell
|
|
179
|
+
- Prolog
|
|
180
|
+
- Wollok
|
|
181
|
+
|
|
182
|
+
# How to make a parser
|
|
183
|
+
|
|
184
|
+
A yukigo's parser is a class that implements the interface `YukigoParser` which exposes a public method called `parse` and an `errors` array like this:
|
|
185
|
+
```ts
|
|
186
|
+
errors: string[];
|
|
187
|
+
parse: (code: string) => AST;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The package `yukigo-ast` has all the current supported AST nodes.
|
|
191
|
+
For the grammar, you can use a tool like Jison or Nearley.
|
|
192
|
+
|
|
193
|
+
Here's a [tutorial](https://miyukiproject.github.io/yukigo/guides/making-a-parser.html) for implementing a small custom language.
|
|
@@ -79,7 +79,7 @@ export class GraphBuilder extends TraverseVisitor {
|
|
|
79
79
|
if (!this.scope)
|
|
80
80
|
return;
|
|
81
81
|
const arr = this.calls.get(this.scope) || [];
|
|
82
|
-
if (node.functionExpr
|
|
82
|
+
if (node.functionExpr.is(SymbolPrimitive))
|
|
83
83
|
this.calls.set(this.scope, [node.functionExpr.value, ...arr]);
|
|
84
84
|
else
|
|
85
85
|
node.functionExpr.accept(this);
|
|
@@ -96,4 +96,5 @@ export class GraphBuilder extends TraverseVisitor {
|
|
|
96
96
|
const arr = this.calls.get(this.scope) || [];
|
|
97
97
|
this.calls.set(this.scope, [node.identifier.value, ...arr]);
|
|
98
98
|
}
|
|
99
|
+
fallback(node) { }
|
|
99
100
|
}
|
package/dist/analyzer/index.d.ts
CHANGED
|
@@ -6,18 +6,11 @@ export type AnalysisResult = {
|
|
|
6
6
|
actual: boolean;
|
|
7
7
|
error?: string;
|
|
8
8
|
};
|
|
9
|
-
export type TargetSuffix = "named" | "like" | "except";
|
|
10
|
-
export type InspectionMatcher = {
|
|
11
|
-
type: string;
|
|
12
|
-
value?: string;
|
|
13
|
-
};
|
|
14
9
|
export type InspectionRule = {
|
|
15
10
|
inspection: string;
|
|
16
11
|
binding?: string;
|
|
17
12
|
args?: string[];
|
|
18
13
|
expected: boolean;
|
|
19
|
-
targetSuffix?: TargetSuffix;
|
|
20
|
-
matcher?: InspectionMatcher;
|
|
21
14
|
};
|
|
22
15
|
export declare const DefaultInspectionSet: InspectionMap;
|
|
23
16
|
export declare const DefaultSmellsSet: InspectionMap;
|
package/dist/analyzer/index.js
CHANGED
|
@@ -104,7 +104,7 @@ export class Analyzer {
|
|
|
104
104
|
const visited = new Set();
|
|
105
105
|
while (workList.length > 0) {
|
|
106
106
|
const currentBinding = workList.shift();
|
|
107
|
-
if (visited.has(currentBinding))
|
|
107
|
+
if (!currentBinding || visited.has(currentBinding))
|
|
108
108
|
continue;
|
|
109
109
|
visited.add(currentBinding);
|
|
110
110
|
const node = defs.get(currentBinding);
|
|
@@ -117,7 +117,7 @@ export class Analyzer {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
let actual = false;
|
|
120
|
-
let error;
|
|
120
|
+
let error = undefined;
|
|
121
121
|
// Execution Loop
|
|
122
122
|
const isGlobalVisitor = !rule.binding || rule.binding === "*";
|
|
123
123
|
const normalizedBinding = isGlobalVisitor ? undefined : rule.binding;
|
|
@@ -125,7 +125,7 @@ export class Analyzer {
|
|
|
125
125
|
const visitor = new InspectionClass(...args, normalizedBinding);
|
|
126
126
|
for (const { node, binding } of targets) {
|
|
127
127
|
try {
|
|
128
|
-
if (!isGlobalVisitor && visitor.setBinding) {
|
|
128
|
+
if (!isGlobalVisitor && visitor.setBinding && binding) {
|
|
129
129
|
visitor.setBinding(binding);
|
|
130
130
|
}
|
|
131
131
|
node.accept(visitor);
|
|
@@ -14,7 +14,7 @@ export declare class UsesComprehension extends ScopedVisitor {
|
|
|
14
14
|
}
|
|
15
15
|
export declare class UsesGuards extends ScopedVisitor {
|
|
16
16
|
constructor(scope?: string);
|
|
17
|
-
|
|
17
|
+
visitGuardedExpression(node: Yu.GuardedExpression): void;
|
|
18
18
|
}
|
|
19
19
|
export declare class UsesOtherwise extends ScopedVisitor {
|
|
20
20
|
constructor(scope?: string);
|