@konomanoasa/tree-sitter-gitattributes 0.4.2 → 0.6.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/Cargo.toml +3 -3
- package/README.md +0 -4
- package/bindings/python/__init__.py +9 -0
- package/bindings/python/binding.c +34 -0
- package/bindings/python/binding.pyi +3 -0
- package/bindings/python/py.typed +0 -0
- package/grammar.js +3 -2
- package/package.json +10 -8
- package/pyproject.toml +60 -0
- package/setup.py +28 -0
- package/src/grammar.json +25 -4
- package/src/parser.c +2078 -1541
- package/src/scanner.c +27 -4
- package/test/bindings.test.rs +23 -2
- package/tree-sitter.json +2 -2
package/Cargo.toml
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "konomanoasa-tree-sitter-gitattributes"
|
|
3
|
-
version = "0.
|
|
4
|
-
edition = "2024"
|
|
3
|
+
version = "0.6.0"
|
|
5
4
|
description = "Tree-sitter grammar for gitattributes."
|
|
6
5
|
readme = "README.md"
|
|
7
|
-
repository = "https://github.com/konomanoasa/tree-sitter-gitattributes"
|
|
8
6
|
license = "MIT"
|
|
7
|
+
repository = "https://github.com/konomanoasa/tree-sitter-gitattributes"
|
|
8
|
+
edition = "2024"
|
|
9
9
|
build = "bindings/rust/build.rs"
|
|
10
10
|
links = "tree-sitter-gitattributes"
|
|
11
11
|
include = [
|
package/README.md
CHANGED
|
@@ -26,10 +26,6 @@ npm test
|
|
|
26
26
|
- [Git 2.55.0 gitattributes manual](https://git-scm.com/docs/gitattributes/2.55.0)
|
|
27
27
|
- [Git 2.55.0 gitignore manual](https://git-scm.com/docs/gitignore/2.55.0)
|
|
28
28
|
|
|
29
|
-
## Used By
|
|
30
|
-
|
|
31
|
-
[gitfile-ts-mode](https://github.com/konomanoasa/gitfile-ts-mode)
|
|
32
|
-
|
|
33
29
|
## License
|
|
34
30
|
|
|
35
31
|
[MIT](LICENSE)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
#include "tree_sitter/parser.h"
|
|
4
|
+
|
|
5
|
+
const TSLanguage *tree_sitter_gitattributes(void);
|
|
6
|
+
|
|
7
|
+
static PyObject *language(PyObject *self, PyObject *args) {
|
|
8
|
+
(void)self;
|
|
9
|
+
(void)args;
|
|
10
|
+
return PyCapsule_New(
|
|
11
|
+
(void *)tree_sitter_gitattributes(),
|
|
12
|
+
"tree_sitter.Language",
|
|
13
|
+
NULL
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static PyMethodDef methods[] = {
|
|
18
|
+
{"language",
|
|
19
|
+
language,
|
|
20
|
+
METH_NOARGS,
|
|
21
|
+
"Return the gitattributes language capsule."},
|
|
22
|
+
{NULL, NULL, 0, NULL},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
static struct PyModuleDef module = {
|
|
26
|
+
PyModuleDef_HEAD_INIT,
|
|
27
|
+
.m_name = "binding",
|
|
28
|
+
.m_size = -1,
|
|
29
|
+
.m_methods = methods,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
PyMODINIT_FUNC PyInit_binding(void) {
|
|
33
|
+
return PyModule_Create(&module);
|
|
34
|
+
}
|
|
File without changes
|
package/grammar.js
CHANGED
|
@@ -76,6 +76,7 @@ export default grammar({
|
|
|
76
76
|
$._rule_start,
|
|
77
77
|
$._macro_start,
|
|
78
78
|
$._eof,
|
|
79
|
+
$.line_ending,
|
|
79
80
|
$._layout,
|
|
80
81
|
$._separator,
|
|
81
82
|
$._attribute_start,
|
|
@@ -120,7 +121,7 @@ export default grammar({
|
|
|
120
121
|
...issueKinds.map(([name]) => $[`_${name}`]),
|
|
121
122
|
$._error_sentinel,
|
|
122
123
|
],
|
|
123
|
-
extras: () => [],
|
|
124
|
+
extras: ($) => [$._unmatchable],
|
|
124
125
|
rules: {
|
|
125
126
|
document: ($) =>
|
|
126
127
|
repeat(
|
|
@@ -129,7 +130,7 @@ export default grammar({
|
|
|
129
130
|
choice($.blank_line, $.comment, $.attribute_rule, $.macro_definition),
|
|
130
131
|
),
|
|
131
132
|
),
|
|
132
|
-
|
|
133
|
+
_unmatchable: () => token(seq(/[\s\S]/, /[^\s\S]/)),
|
|
133
134
|
_end: ($) => seq(optional($._layout), choice($.line_ending, $._eof)),
|
|
134
135
|
blank_line: ($) => seq($._blank_start, $._end),
|
|
135
136
|
comment: ($) =>
|
package/package.json
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomanoasa/tree-sitter-gitattributes",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.6.0",
|
|
5
4
|
"description": "Tree-sitter grammar for gitattributes.",
|
|
6
5
|
"license": "MIT",
|
|
7
6
|
"repository": "git+https://github.com/konomanoasa/tree-sitter-gitattributes.git",
|
|
7
|
+
"type": "module",
|
|
8
8
|
"files": [
|
|
9
9
|
"Cargo.toml",
|
|
10
|
+
"bindings/python/*.c",
|
|
11
|
+
"bindings/python/*.py",
|
|
12
|
+
"bindings/python/*.pyi",
|
|
13
|
+
"bindings/python/py.typed",
|
|
10
14
|
"bindings/rust/*.rs",
|
|
11
15
|
"grammar.js",
|
|
16
|
+
"pyproject.toml",
|
|
12
17
|
"queries/*.scm",
|
|
18
|
+
"setup.py",
|
|
13
19
|
"src/*.c",
|
|
14
20
|
"src/*.json",
|
|
15
21
|
"src/tree_sitter/*.h",
|
|
@@ -25,13 +31,9 @@
|
|
|
25
31
|
"check:queries": "npm run tree-sitter -- check-queries",
|
|
26
32
|
"format": "biome format --write .",
|
|
27
33
|
"generate": "npm run tree-sitter -- generate-all",
|
|
28
|
-
"test": "npm run tree-sitter -- test-corpus --rebuild && node --test --test-concurrency=1
|
|
29
|
-
"test:fuzz": "
|
|
30
|
-
"test:fuzz:corpus": "npm run tree-sitter -- fuzz-all --iterations 100 --edits 5",
|
|
31
|
-
"test:highlights": "node --test test/highlight.test.js",
|
|
32
|
-
"test:incremental": "node --test --test-concurrency=1 test/cst.test.js test/parser.test.js test/incremental.test.js",
|
|
34
|
+
"test": "npm run tree-sitter -- test-corpus --rebuild && node --test --test-concurrency=1 test/build.test.js test/cst.test.js test/highlight.test.js test/incremental.test.js test/parser.test.js && node scripts/check-c.js --test",
|
|
35
|
+
"test:fuzz": "npm run tree-sitter -- fuzz-all --iterations 100 --edits 5",
|
|
33
36
|
"test:sanitize": "node scripts/check-c.js --sanitize",
|
|
34
|
-
"test:scanner": "node scripts/check-c.js",
|
|
35
37
|
"tree-sitter": "node scripts/tree-sitter.js"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
package/pyproject.toml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "konomanoasa-tree-sitter-gitattributes"
|
|
3
|
+
version = "0.6.0"
|
|
4
|
+
description = "Tree-sitter grammar for gitattributes."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
|
|
9
|
+
[project.urls]
|
|
10
|
+
Repository = "https://github.com/konomanoasa/tree-sitter-gitattributes"
|
|
11
|
+
|
|
12
|
+
[dependency-groups]
|
|
13
|
+
dev = [
|
|
14
|
+
"poethepoet==0.49.0",
|
|
15
|
+
"ruff==0.17.3",
|
|
16
|
+
"setuptools==84.2.1",
|
|
17
|
+
"tree-sitter==0.26.0",
|
|
18
|
+
"twine==7.0.0",
|
|
19
|
+
"ty==0.0.95",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["setuptools==84.2.1"]
|
|
24
|
+
build-backend = "setuptools.build_meta"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
include-package-data = false
|
|
28
|
+
packages = ["tree_sitter_gitattributes", "tree_sitter_gitattributes.queries"]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.package-dir]
|
|
31
|
+
tree_sitter_gitattributes = "bindings/python"
|
|
32
|
+
"tree_sitter_gitattributes.queries" = "queries"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.package-data]
|
|
35
|
+
tree_sitter_gitattributes = ["*.pyi", "py.typed"]
|
|
36
|
+
"tree_sitter_gitattributes.queries" = ["*.scm"]
|
|
37
|
+
|
|
38
|
+
[tool.poe]
|
|
39
|
+
executor.type = "simple"
|
|
40
|
+
|
|
41
|
+
[tool.poe.tasks]
|
|
42
|
+
build = "uv build --no-sources"
|
|
43
|
+
check = [
|
|
44
|
+
{ cmd = "ruff check setup.py bindings/python test/bindings.test.py" },
|
|
45
|
+
{ cmd = "ty check setup.py bindings/python test/bindings.test.py" },
|
|
46
|
+
{ cmd = "ruff format --check setup.py bindings/python test/bindings.test.py" },
|
|
47
|
+
]
|
|
48
|
+
format = "ruff format setup.py bindings/python test/bindings.test.py"
|
|
49
|
+
test = "python test/bindings.test.py"
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
indent-width = 4
|
|
53
|
+
line-length = 80
|
|
54
|
+
|
|
55
|
+
[tool.ruff.format]
|
|
56
|
+
indent-style = "space"
|
|
57
|
+
skip-magic-trailing-comma = true
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint.isort]
|
|
60
|
+
split-on-trailing-comma = false
|
package/setup.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from setuptools import Extension, setup
|
|
5
|
+
|
|
6
|
+
Path("dist/metadata").mkdir(parents=True, exist_ok=True)
|
|
7
|
+
|
|
8
|
+
setup(
|
|
9
|
+
options={
|
|
10
|
+
"build": {"build_base": "dist/build"},
|
|
11
|
+
"egg_info": {"egg_base": "dist/metadata"},
|
|
12
|
+
},
|
|
13
|
+
ext_modules=[
|
|
14
|
+
Extension(
|
|
15
|
+
"tree_sitter_gitattributes.binding",
|
|
16
|
+
sources=[
|
|
17
|
+
"bindings/python/binding.c",
|
|
18
|
+
"src/parser.c",
|
|
19
|
+
"src/scanner.c",
|
|
20
|
+
],
|
|
21
|
+
include_dirs=["src"],
|
|
22
|
+
depends=["src/tree_sitter/alloc.h", "src/tree_sitter/parser.h"],
|
|
23
|
+
extra_compile_args=["/std:c17", "/utf-8"]
|
|
24
|
+
if sys.platform == "win32"
|
|
25
|
+
else ["-std=c17"],
|
|
26
|
+
)
|
|
27
|
+
],
|
|
28
|
+
)
|
package/src/grammar.json
CHANGED
|
@@ -35,9 +35,21 @@
|
|
|
35
35
|
]
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
-
"
|
|
39
|
-
"type": "
|
|
40
|
-
"
|
|
38
|
+
"_unmatchable": {
|
|
39
|
+
"type": "TOKEN",
|
|
40
|
+
"content": {
|
|
41
|
+
"type": "SEQ",
|
|
42
|
+
"members": [
|
|
43
|
+
{
|
|
44
|
+
"type": "PATTERN",
|
|
45
|
+
"value": "[\\s\\S]"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"type": "PATTERN",
|
|
49
|
+
"value": "[^\\s\\S]"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
41
53
|
},
|
|
42
54
|
"_end": {
|
|
43
55
|
"type": "SEQ",
|
|
@@ -1680,7 +1692,12 @@
|
|
|
1680
1692
|
"value": "invalid_syntax"
|
|
1681
1693
|
}
|
|
1682
1694
|
},
|
|
1683
|
-
"extras": [
|
|
1695
|
+
"extras": [
|
|
1696
|
+
{
|
|
1697
|
+
"type": "SYMBOL",
|
|
1698
|
+
"name": "_unmatchable"
|
|
1699
|
+
}
|
|
1700
|
+
],
|
|
1684
1701
|
"conflicts": [],
|
|
1685
1702
|
"precedences": [],
|
|
1686
1703
|
"externals": [
|
|
@@ -1708,6 +1725,10 @@
|
|
|
1708
1725
|
"type": "SYMBOL",
|
|
1709
1726
|
"name": "_eof"
|
|
1710
1727
|
},
|
|
1728
|
+
{
|
|
1729
|
+
"type": "SYMBOL",
|
|
1730
|
+
"name": "line_ending"
|
|
1731
|
+
},
|
|
1711
1732
|
{
|
|
1712
1733
|
"type": "SYMBOL",
|
|
1713
1734
|
"name": "_layout"
|