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.
- package/.mocharc.json +3 -3
- package/CHANGELOG.md +6 -0
- package/README.md +10 -10
- package/dist/index.d.ts +13 -2
- package/dist/index.js +112 -32
- package/dist/index.js.map +1 -1
- package/dist/parser/grammar.js +220 -231
- package/dist/parser/grammar.js.map +1 -1
- package/dist/parser/lexer.d.ts +70 -15
- package/dist/parser/lexer.js +259 -50
- package/dist/parser/lexer.js.map +1 -1
- package/dist/prelude.d.ts +1 -1
- package/dist/prelude.js +280 -204
- package/dist/prelude.js.map +1 -1
- package/dist/typechecker/DeclarationCollector.d.ts +6 -1
- package/dist/typechecker/DeclarationCollector.js +39 -0
- package/dist/typechecker/DeclarationCollector.js.map +1 -1
- package/dist/typechecker/TypeBuilder.d.ts +1 -1
- package/dist/typechecker/TypeBuilder.js +6 -2
- package/dist/typechecker/TypeBuilder.js.map +1 -1
- package/dist/typechecker/checker.d.ts +15 -4
- package/dist/typechecker/checker.js +108 -25
- package/dist/typechecker/checker.js.map +1 -1
- package/dist/typechecker/core.d.ts +4 -0
- package/dist/typechecker/core.js +45 -19
- package/dist/typechecker/core.js.map +1 -1
- package/dist/typechecker/inference.d.ts +5 -1
- package/dist/typechecker/inference.js +95 -21
- package/dist/typechecker/inference.js.map +1 -1
- package/dist/utils/helpers.d.ts +1 -1
- package/dist/utils/helpers.js +1 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.js +7 -0
- package/dist/utils/types.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +192 -55
- package/src/parser/grammar.ne +519 -463
- package/src/parser/grammar.ts +230 -239
- package/src/parser/lexer.ts +353 -77
- package/src/prelude.ts +282 -206
- package/src/typechecker/DeclarationCollector.ts +157 -104
- package/src/typechecker/TypeBuilder.ts +150 -148
- package/src/typechecker/checker.ts +501 -395
- package/src/typechecker/core.ts +192 -162
- package/src/typechecker/inference.ts +1421 -1327
- package/src/utils/helpers.ts +29 -29
- package/src/utils/types.ts +63 -56
- package/tests/hspec.spec.ts +92 -0
- package/tests/lexer.spec.ts +175 -0
- package/tests/parser.spec.ts +829 -823
- package/tests/prelude.spec.ts +17 -22
- package/tests/typechecker.spec.ts +327 -310
- package/tsconfig.json +26 -17
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/parser/layoutPreprocessor.d.ts +0 -1
- package/dist/parser/layoutPreprocessor.js +0 -22
- package/dist/parser/layoutPreprocessor.js.map +0 -1
- package/dist/parser/preprocessor.d.ts +0 -28
- package/dist/parser/preprocessor.js +0 -453
- package/dist/parser/preprocessor.js.map +0 -1
- package/src/parser/layoutPreprocessor.ts +0 -21
- package/src/parser/preprocessor.ne +0 -375
- package/src/parser/preprocessor.ts +0 -502
- 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
|
-
});
|