@konomanoasa/tree-sitter-gitattributes 0.3.0 → 0.4.1
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/Cargo.toml +2 -2
- package/README.md +4 -5
- package/grammar.js +40 -40
- package/package.json +5 -5
- package/src/grammar.json +158 -108
- package/src/node-types.json +4 -0
- package/src/parser.c +2540 -2437
- package/src/scanner.c +237 -276
- package/test/bindings.test.rs +0 -13
- package/tree-sitter.json +1 -1
package/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "konomanoasa-tree-sitter-gitattributes"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.1"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
description = "Tree-sitter grammar for gitattributes."
|
|
6
6
|
readme = "README.md"
|
|
@@ -30,7 +30,7 @@ path = "test/bindings.test.rs"
|
|
|
30
30
|
tree-sitter-language = "0.1.8"
|
|
31
31
|
|
|
32
32
|
[dev-dependencies]
|
|
33
|
-
tree-sitter = "0.27.
|
|
33
|
+
tree-sitter = "0.27.1"
|
|
34
34
|
|
|
35
35
|
[build-dependencies]
|
|
36
36
|
cc = "1.4"
|
package/README.md
CHANGED
|
@@ -7,11 +7,6 @@
|
|
|
7
7
|
[Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for
|
|
8
8
|
Git attributes files 2.55.0.
|
|
9
9
|
|
|
10
|
-
## Syntax Issues
|
|
11
|
-
|
|
12
|
-
The parser detects syntax issues, including missing syntax, while preserving the surrounding structure.
|
|
13
|
-
These issues are represented as `syntax_issue` nodes.
|
|
14
|
-
|
|
15
10
|
## Installation
|
|
16
11
|
|
|
17
12
|
```sh
|
|
@@ -33,6 +28,10 @@ npm test
|
|
|
33
28
|
- [Git 2.55.0 gitattributes manual](https://git-scm.com/docs/gitattributes/2.55.0)
|
|
34
29
|
- [Git 2.55.0 gitignore manual](https://git-scm.com/docs/gitignore/2.55.0)
|
|
35
30
|
|
|
31
|
+
## Used By
|
|
32
|
+
|
|
33
|
+
[gitfile-ts-mode](https://github.com/konomanoasa/gitfile-ts-mode): Emacs major mode.
|
|
34
|
+
|
|
36
35
|
## License
|
|
37
36
|
|
|
38
37
|
[MIT](LICENSE)
|
package/grammar.js
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
+
const missingKinds = (name) => [
|
|
2
|
+
[`missing_${name}`, "invalid_syntax", `missing_${name}`],
|
|
3
|
+
[`incomplete_${name}`, "incomplete_syntax", `missing_${name}`],
|
|
4
|
+
];
|
|
1
5
|
const issueKinds = [
|
|
2
|
-
|
|
3
|
-
["incomplete_set_close", "incomplete_syntax", "missing_set_close"],
|
|
6
|
+
...missingKinds("set_close"),
|
|
4
7
|
["invalid_encoding", "invalid_syntax", "invalid_encoding"],
|
|
5
8
|
["negative_pattern", "invalid_syntax", "negative_pattern"],
|
|
6
|
-
["
|
|
9
|
+
["ended_escape", "invalid_syntax", "incomplete_escape"],
|
|
7
10
|
["incomplete_escape", "incomplete_syntax", "incomplete_escape"],
|
|
8
11
|
["invalid_quoted_escape", "invalid_syntax", "invalid_quoted_escape"],
|
|
9
12
|
["ended_quoted_escape", "invalid_syntax", "incomplete_quoted_escape"],
|
|
10
13
|
["incomplete_quoted_escape", "incomplete_syntax", "incomplete_quoted_escape"],
|
|
11
|
-
|
|
12
|
-
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
...missingKinds("quote_close"),
|
|
15
|
+
[
|
|
16
|
+
"missing_attribute_separator",
|
|
17
|
+
"invalid_syntax",
|
|
18
|
+
"missing_attribute_separator",
|
|
19
|
+
],
|
|
20
|
+
...missingKinds("attribute_name"),
|
|
16
21
|
["invalid_name_character", "invalid_syntax", "invalid_name_character"],
|
|
22
|
+
["incomplete_name_character", "incomplete_syntax", "invalid_name_character"],
|
|
17
23
|
[
|
|
18
24
|
"invalid_name_escape",
|
|
19
25
|
"invalid_syntax",
|
|
@@ -42,17 +48,24 @@ const issueRules = Object.fromEntries(
|
|
|
42
48
|
const issue = ($, name) =>
|
|
43
49
|
field("issue", alias($[`_${name}_issue`], $.syntax_issue));
|
|
44
50
|
const issues = ($, ...names) => names.map((name) => issue($, name));
|
|
51
|
+
const missing = ($, name) =>
|
|
52
|
+
choice(issue($, `missing_${name}`), issue($, `incomplete_${name}`));
|
|
45
53
|
const heldPrefix = ($, ...names) =>
|
|
46
54
|
seq($._escape_prefix, choice(...issues($, ...names)));
|
|
47
|
-
const missingName = ($) =>
|
|
48
|
-
choice(...issues($, "missing_name", "incomplete_name"));
|
|
49
55
|
const quoteClose = ($) =>
|
|
50
|
-
optional(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
optional(choice(field("closing", $.quote_close), missing($, "quote_close")));
|
|
57
|
+
const attributeName = ($) =>
|
|
58
|
+
choice(field("name", $.attribute_name), missing($, "attribute_name"));
|
|
59
|
+
const globIssues = ($) => [
|
|
60
|
+
...issues(
|
|
61
|
+
$,
|
|
62
|
+
"invalid_encoding",
|
|
63
|
+
"ended_escape",
|
|
64
|
+
"incomplete_escape",
|
|
65
|
+
...quotedEscapeIssues,
|
|
66
|
+
),
|
|
67
|
+
heldPrefix($, "invalid_encoding", ...quotedEscapeIssues),
|
|
68
|
+
];
|
|
56
69
|
|
|
57
70
|
export default grammar({
|
|
58
71
|
name: "gitattributes",
|
|
@@ -138,14 +151,17 @@ export default grammar({
|
|
|
138
151
|
$._macro_start,
|
|
139
152
|
optional(field("opening", $.quote_open)),
|
|
140
153
|
field("marker", $.macro_marker),
|
|
141
|
-
|
|
154
|
+
attributeName($),
|
|
142
155
|
quoteClose($),
|
|
143
156
|
optional($._attributes),
|
|
144
157
|
$._end,
|
|
145
158
|
),
|
|
146
159
|
_attributes: ($) =>
|
|
147
160
|
repeat1(
|
|
148
|
-
seq(
|
|
161
|
+
seq(
|
|
162
|
+
choice($._separator, issue($, "missing_attribute_separator")),
|
|
163
|
+
$.attribute,
|
|
164
|
+
),
|
|
149
165
|
),
|
|
150
166
|
attribute: ($) =>
|
|
151
167
|
seq(
|
|
@@ -153,7 +169,7 @@ export default grammar({
|
|
|
153
169
|
optional(
|
|
154
170
|
field("modifier", choice($.unset_marker, $.unspecified_marker)),
|
|
155
171
|
),
|
|
156
|
-
|
|
172
|
+
attributeName($),
|
|
157
173
|
optional(
|
|
158
174
|
seq(
|
|
159
175
|
field("operator", $.assignment_operator),
|
|
@@ -173,6 +189,7 @@ export default grammar({
|
|
|
173
189
|
$,
|
|
174
190
|
"invalid_encoding",
|
|
175
191
|
"invalid_name_character",
|
|
192
|
+
"incomplete_name_character",
|
|
176
193
|
"invalid_name_escape",
|
|
177
194
|
...quotedEscapeIssues,
|
|
178
195
|
),
|
|
@@ -203,15 +220,8 @@ export default grammar({
|
|
|
203
220
|
$.escape,
|
|
204
221
|
$.quoted_escape,
|
|
205
222
|
$.character_set,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"invalid_encoding",
|
|
209
|
-
"negative_pattern",
|
|
210
|
-
"invalid_escape",
|
|
211
|
-
"incomplete_escape",
|
|
212
|
-
...quotedEscapeIssues,
|
|
213
|
-
),
|
|
214
|
-
heldPrefix($, "invalid_encoding", ...quotedEscapeIssues),
|
|
223
|
+
issue($, "negative_pattern"),
|
|
224
|
+
...globIssues($),
|
|
215
225
|
),
|
|
216
226
|
),
|
|
217
227
|
),
|
|
@@ -233,21 +243,11 @@ export default grammar({
|
|
|
233
243
|
$.quoted_escape,
|
|
234
244
|
$.character_range,
|
|
235
245
|
$.character_class,
|
|
236
|
-
...
|
|
237
|
-
$,
|
|
238
|
-
"invalid_encoding",
|
|
239
|
-
"invalid_escape",
|
|
240
|
-
"incomplete_escape",
|
|
241
|
-
...quotedEscapeIssues,
|
|
242
|
-
),
|
|
243
|
-
heldPrefix($, "invalid_encoding", ...quotedEscapeIssues),
|
|
246
|
+
...globIssues($),
|
|
244
247
|
),
|
|
245
248
|
),
|
|
246
249
|
),
|
|
247
|
-
choice(
|
|
248
|
-
field("closing", $.set_close),
|
|
249
|
-
...issues($, "missing_set_close", "incomplete_set_close"),
|
|
250
|
-
),
|
|
250
|
+
choice(field("closing", $.set_close), missing($, "set_close")),
|
|
251
251
|
),
|
|
252
252
|
character_range: ($) =>
|
|
253
253
|
seq(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomanoasa/tree-sitter-gitattributes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Tree-sitter grammar for gitattributes.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"test:fuzz": "node --test --test-name-pattern=\"fixed-seed generated histories\" test/incremental.test.js",
|
|
30
30
|
"test:fuzz:corpus": "npm run tree-sitter -- fuzz-all --iterations 100 --edits 5",
|
|
31
31
|
"test:highlights": "node --test test/highlight.test.js",
|
|
32
|
-
"test:incremental": "node --test test/incremental.test.js",
|
|
32
|
+
"test:incremental": "node --test --test-concurrency=1 test/cst.test.js test/parser.test.js test/incremental.test.js",
|
|
33
33
|
"test:sanitize": "node scripts/check-c.js --sanitize",
|
|
34
34
|
"test:scanner": "node scripts/check-c.js",
|
|
35
35
|
"tree-sitter": "node scripts/tree-sitter.js"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@biomejs/biome": "2.5.
|
|
39
|
-
"@types/node": "26.5
|
|
40
|
-
"tree-sitter-cli": "0.27.
|
|
38
|
+
"@biomejs/biome": "2.5.15",
|
|
39
|
+
"@types/node": "26.6.5",
|
|
40
|
+
"tree-sitter-cli": "0.27.1",
|
|
41
41
|
"typescript": "7.0.2"
|
|
42
42
|
},
|
|
43
43
|
"allowScripts": {
|