@willbooster/tree-sitter-haskell 2.0.1 → 3.0.0
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/README.md +6 -7
- package/grammar/externals.js +1 -0
- package/grammar/id.js +1 -1
- package/grammar/literal.js +20 -12
- package/grammar/type.js +1 -1
- package/package.json +3 -3
- package/tree-sitter-haskell.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -13,8 +13,7 @@ Haskell grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), f
|
|
|
13
13
|
to its authors and contributors. This is not an official release of that project.
|
|
14
14
|
|
|
15
15
|
This fork is based on upstream's version 0.23.1 grammar and generates the parser with the
|
|
16
|
-
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries that fork's own ABI number, so it loads only with that fork's runtime, version
|
|
17
|
-
or later; upstream's runtime rejects it.
|
|
16
|
+
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries that fork's own ABI number, so it loads only with that fork's runtime, version 4.0.2 or later in the 4.x series; upstream's runtime rejects it.
|
|
18
17
|
[Upstream's README at that version](https://github.com/tree-sitter/tree-sitter-haskell/blob/v0.23.1/README.md) lists
|
|
19
18
|
the supported language extensions and, under "Querying", explains how to query the grammar's supertypes; it is the
|
|
20
19
|
readme that the comments in `grammar.js` refer to.
|
|
@@ -23,6 +22,7 @@ readme that the comments in `grammar.js` refer to.
|
|
|
23
22
|
|
|
24
23
|
The fork's main differences from upstream 0.23.1 are:
|
|
25
24
|
|
|
25
|
+
- **MultilineStrings**: triple-quoted literals retain their complete source as a single `string` node, including embedded quotes, escapes, and string gaps.
|
|
26
26
|
- **Comment scanning**: empty block comments such as `{--}` terminate at their closing delimiter and preserve following code.
|
|
27
27
|
An ordinary line comment does not absorb a following marked Haddock comment.
|
|
28
28
|
Unmarked continuation lines remain in their preceding Haddock block, including space or tab indentation and LF or CRLF newlines.
|
|
@@ -42,7 +42,7 @@ reports an error: the lexers of the WillBooster/tree-sitter generator let charac
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
44
44
|
The npm package ships `tree-sitter-haskell.wasm` for
|
|
45
|
-
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version
|
|
45
|
+
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 4.0.2 or later in the 4.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers. In Node.js and Bun, load the grammar from its path:
|
|
46
46
|
|
|
47
47
|
```js
|
|
48
48
|
import { fileURLToPath } from 'node:url';
|
|
@@ -88,8 +88,8 @@ fuzzed with:
|
|
|
88
88
|
|
|
89
89
|
```toml
|
|
90
90
|
[dependencies]
|
|
91
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
92
|
-
tree-sitter-haskell = { package = "willbooster-tree-sitter-haskell", version = "
|
|
91
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "4.0.2" }
|
|
92
|
+
tree-sitter-haskell = { package = "willbooster-tree-sitter-haskell", version = "3" }
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
```rust
|
|
@@ -127,8 +127,7 @@ and the release build regenerate the parsers before compiling them.
|
|
|
127
127
|
- the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
|
|
128
128
|
- an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
|
|
129
129
|
edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
|
|
130
|
-
`TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits
|
|
131
|
-
upstream's own parser also reparses differently from a fresh parse (see `script/fuzz-corpus`);
|
|
130
|
+
`TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
|
|
132
131
|
- a check that the real-world Haskell files in `examples/`, the checked-in ones and those of the cloned repositories, fail to
|
|
133
132
|
parse exactly as listed in `script/known-failures.txt`; upstream's prebuilt parser fails on the same files. The first run clones the repositories. The example repositories are pinned to commits in
|
|
134
133
|
`script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites it;
|
package/grammar/externals.js
CHANGED
package/grammar/id.js
CHANGED
|
@@ -68,7 +68,7 @@ module.exports = {
|
|
|
68
68
|
_tyconids: $ => choice($._qtyconid, $._tyconid),
|
|
69
69
|
|
|
70
70
|
_tycon_arrow: $ => parens($, alias($._arrow, $.operator)),
|
|
71
|
-
_qualified_arrow: $ => qualified($, alias($._arrow, $.operator)),
|
|
71
|
+
_qualified_arrow: $ => qualified($, alias(choice($._arrow, $._linear_arrow), $.operator)),
|
|
72
72
|
_qtycon_arrow: $ => parens($, alias($._qualified_arrow, $.qualified)),
|
|
73
73
|
|
|
74
74
|
_tycon: $ => choice($._tyconid, $._pvarsym, alias($._tycon_arrow, $.prefix_id), $._pconsym),
|
package/grammar/literal.js
CHANGED
|
@@ -7,14 +7,12 @@ const {
|
|
|
7
7
|
const decimal = /[0-9][0-9_]*/
|
|
8
8
|
const exponent = /[eE][+-]?[0-9_]+/
|
|
9
9
|
const hex_exponent = /[pP][+-]?[0-9a-fA-F_]+/
|
|
10
|
+
const escaped = /\\(\^)?./
|
|
11
|
+
const string_gap = /\\\p{White_Space}+\\/
|
|
10
12
|
const magic_hash = rule => token(seq(rule, optional(token.immediate(/##?/))))
|
|
11
13
|
|
|
12
14
|
module.exports = {
|
|
13
15
|
|
|
14
|
-
// ------------------------------------------------------------------------
|
|
15
|
-
// literals
|
|
16
|
-
// ------------------------------------------------------------------------
|
|
17
|
-
|
|
18
16
|
// the `choice` here is necessary to avoid integers being parsed as floats
|
|
19
17
|
float: _ => magic_hash(
|
|
20
18
|
seq(
|
|
@@ -34,14 +32,24 @@ module.exports = {
|
|
|
34
32
|
),
|
|
35
33
|
|
|
36
34
|
string: _ => magic_hash(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
choice(
|
|
36
|
+
seq(
|
|
37
|
+
'"',
|
|
38
|
+
repeat(choice(
|
|
39
|
+
/[^\\"\n]/,
|
|
40
|
+
escaped,
|
|
41
|
+
/\\\n\s*\\/,
|
|
42
|
+
)),
|
|
43
|
+
'"',
|
|
44
|
+
),
|
|
45
|
+
seq(
|
|
46
|
+
'"""',
|
|
47
|
+
repeat(seq(
|
|
48
|
+
optional(/""?/),
|
|
49
|
+
choice(/[^\\"]/, /\\(?:\^[@-_]|[^\p{White_Space}^])/, string_gap),
|
|
50
|
+
)),
|
|
51
|
+
'"""',
|
|
52
|
+
),
|
|
45
53
|
),
|
|
46
54
|
),
|
|
47
55
|
|
package/grammar/type.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-haskell",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Haskell grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
49
49
|
"@willbooster/oxlint-config": "1.4.8",
|
|
50
50
|
"@willbooster/wb": "22.26.1",
|
|
51
|
-
"@willbooster/web-tree-sitter": "
|
|
51
|
+
"@willbooster/web-tree-sitter": "4.0.2",
|
|
52
52
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
53
53
|
"lefthook": "2.2.1",
|
|
54
54
|
"oxfmt": "0.72.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"wrangler": "4.147.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^
|
|
64
|
+
"@willbooster/web-tree-sitter": "^4.0.2"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@willbooster/web-tree-sitter": {
|
package/tree-sitter-haskell.wasm
CHANGED
|
Binary file
|