yukigo-haskell-parser 0.1.0 → 0.1.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.
Files changed (65) hide show
  1. package/.mocharc.json +3 -3
  2. package/CHANGELOG.md +6 -0
  3. package/README.md +10 -10
  4. package/dist/index.d.ts +13 -2
  5. package/dist/index.js +112 -32
  6. package/dist/index.js.map +1 -1
  7. package/dist/parser/grammar.js +220 -231
  8. package/dist/parser/grammar.js.map +1 -1
  9. package/dist/parser/lexer.d.ts +70 -15
  10. package/dist/parser/lexer.js +259 -50
  11. package/dist/parser/lexer.js.map +1 -1
  12. package/dist/prelude.d.ts +1 -1
  13. package/dist/prelude.js +280 -204
  14. package/dist/prelude.js.map +1 -1
  15. package/dist/typechecker/DeclarationCollector.d.ts +6 -1
  16. package/dist/typechecker/DeclarationCollector.js +39 -0
  17. package/dist/typechecker/DeclarationCollector.js.map +1 -1
  18. package/dist/typechecker/TypeBuilder.d.ts +1 -1
  19. package/dist/typechecker/TypeBuilder.js +6 -2
  20. package/dist/typechecker/TypeBuilder.js.map +1 -1
  21. package/dist/typechecker/checker.d.ts +15 -4
  22. package/dist/typechecker/checker.js +108 -25
  23. package/dist/typechecker/checker.js.map +1 -1
  24. package/dist/typechecker/core.d.ts +4 -0
  25. package/dist/typechecker/core.js +45 -19
  26. package/dist/typechecker/core.js.map +1 -1
  27. package/dist/typechecker/inference.d.ts +5 -1
  28. package/dist/typechecker/inference.js +95 -21
  29. package/dist/typechecker/inference.js.map +1 -1
  30. package/dist/utils/helpers.d.ts +1 -1
  31. package/dist/utils/helpers.js +1 -1
  32. package/dist/utils/helpers.js.map +1 -1
  33. package/dist/utils/types.d.ts +1 -1
  34. package/dist/utils/types.js +7 -0
  35. package/dist/utils/types.js.map +1 -1
  36. package/package.json +3 -3
  37. package/src/index.ts +192 -55
  38. package/src/parser/grammar.ne +519 -463
  39. package/src/parser/grammar.ts +230 -239
  40. package/src/parser/lexer.ts +353 -77
  41. package/src/prelude.ts +282 -206
  42. package/src/typechecker/DeclarationCollector.ts +157 -104
  43. package/src/typechecker/TypeBuilder.ts +150 -148
  44. package/src/typechecker/checker.ts +501 -395
  45. package/src/typechecker/core.ts +192 -162
  46. package/src/typechecker/inference.ts +1421 -1327
  47. package/src/utils/helpers.ts +29 -29
  48. package/src/utils/types.ts +63 -56
  49. package/tests/hspec.spec.ts +92 -0
  50. package/tests/lexer.spec.ts +175 -0
  51. package/tests/parser.spec.ts +829 -823
  52. package/tests/prelude.spec.ts +17 -22
  53. package/tests/typechecker.spec.ts +327 -310
  54. package/tsconfig.json +26 -17
  55. package/tsconfig.tsbuildinfo +1 -0
  56. package/dist/parser/layoutPreprocessor.d.ts +0 -1
  57. package/dist/parser/layoutPreprocessor.js +0 -22
  58. package/dist/parser/layoutPreprocessor.js.map +0 -1
  59. package/dist/parser/preprocessor.d.ts +0 -28
  60. package/dist/parser/preprocessor.js +0 -453
  61. package/dist/parser/preprocessor.js.map +0 -1
  62. package/src/parser/layoutPreprocessor.ts +0 -21
  63. package/src/parser/preprocessor.ne +0 -375
  64. package/src/parser/preprocessor.ts +0 -502
  65. package/tests/preprocessor.spec.ts +0 -69
@@ -1,69 +0,0 @@
1
- import { assert } from "chai";
2
- import { preprocessor } from "../src/parser/layoutPreprocessor.js";
3
- import { PreprocessorLexer } from "../src/parser/lexer.js";
4
-
5
- describe("Preprocessor Tests", () => {
6
- it("processes where clauses correctly", () => {
7
- const expectedCode =
8
- "f x = x * pi where { pi = 3.14; anotherBinding = 200 }";
9
- assert.equal(
10
- preprocessor(`f x = x * pi
11
- where
12
- pi = 3.14
13
- anotherBinding = 200`),
14
- expectedCode
15
- );
16
- assert.equal(
17
- preprocessor(`f x = x * pi where
18
- pi = 3.14
19
- anotherBinding = 200`),
20
- expectedCode
21
- );
22
- assert.equal(
23
- preprocessor(`f x = x * pi where pi = 3.14; anotherBinding = 200`),
24
- expectedCode
25
- );
26
- assert.equal(
27
- preprocessor(`f x = x where x = 1`),
28
- `f x = x where { x = 1 }`
29
- );
30
- assert.equal(
31
- preprocessor(`f x = x where { x = 1 }`),
32
- `f x = x where { x = 1 }`
33
- );
34
- assert.equal(
35
- preprocessor(`g y = y * z
36
- where
37
- z = 10
38
- h w = w where w = 2`),
39
- `g y = y * z where { z = 10 }
40
- h w = w where { w = 2 }`
41
- );
42
- });
43
- it("processes let...in expressions correctly", () => {
44
- const expectedCode = "f = let { x = 1; y = 2 } in x + y";
45
- assert.equal(preprocessor(`f = let x = 1; y = 2 in x + y`), expectedCode);
46
- assert.equal(preprocessor(`f = let {x=1;y=2} in x + y`), expectedCode);
47
- assert.equal(
48
- preprocessor(`f = let
49
- x = 1
50
- y = 2
51
- in x + y`),
52
- expectedCode
53
- );
54
- assert.equal(
55
- preprocessor(`
56
- f =
57
- let x = 1
58
- y = 2
59
- in x + y`),
60
- expectedCode
61
- );
62
- assert.equal(
63
- preprocessor(
64
- `hypotenuse a b =\n let\n a_sq = a * a\n b_sq = b * b\n sum_sq = a_sq + b_sq\n in\n sqrt sum_sq`
65
- ),
66
- `hypotenuse a b = let { a_sq = a * a; b_sq = b * b; sum_sq = a_sq + b_sq } in sqrt sum_sq`
67
- );
68
- });
69
- });