tree-sitter-rake 0.4.0b0__tar.gz
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.
- tree_sitter_rake-0.4.0b0/LICENSE +21 -0
- tree_sitter_rake-0.4.0b0/PKG-INFO +34 -0
- tree_sitter_rake-0.4.0b0/README.md +15 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake/__init__.py +43 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake/__init__.pyi +17 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake/binding.c +35 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake/py.typed +0 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake.egg-info/PKG-INFO +34 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake.egg-info/SOURCES.txt +15 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake.egg-info/dependency_links.txt +1 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake.egg-info/not-zip-safe +1 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake.egg-info/requires.txt +3 -0
- tree_sitter_rake-0.4.0b0/bindings/python/tree_sitter_rake.egg-info/top_level.txt +2 -0
- tree_sitter_rake-0.4.0b0/pyproject.toml +30 -0
- tree_sitter_rake-0.4.0b0/queries/highlights.scm +144 -0
- tree_sitter_rake-0.4.0b0/setup.cfg +4 -0
- tree_sitter_rake-0.4.0b0/setup.py +77 -0
- tree_sitter_rake-0.4.0b0/src/parser.c +23034 -0
- tree_sitter_rake-0.4.0b0/src/tree_sitter/alloc.h +54 -0
- tree_sitter_rake-0.4.0b0/src/tree_sitter/array.h +336 -0
- tree_sitter_rake-0.4.0b0/src/tree_sitter/parser.h +286 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Kieran Hannigan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-rake
|
|
3
|
+
Version: 0.4.0b0
|
|
4
|
+
Summary: Tree-sitter grammar for Rake, a vector-first SIMD language
|
|
5
|
+
Author: Kieran Rosenberg
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rakelang/tree-sitter-rake
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,rake
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Provides-Extra: core
|
|
17
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# Tree-sitter Rake
|
|
21
|
+
|
|
22
|
+
This repository provides the Tree-sitter grammar and highlighting queries for
|
|
23
|
+
[Rake](https://rake-lang.org), together with C, Go, Node.js, Python, Rust and
|
|
24
|
+
Swift bindings generated from Tree-sitter's package templates.
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm test
|
|
28
|
+
npm run test:differential
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The first command regenerates the parser and runs its corpus and highlighting
|
|
32
|
+
tests. The differential check parses every source file in Rake's compiler test
|
|
33
|
+
manifest with both Tree-sitter and the current compiler, then compares whether
|
|
34
|
+
each parser accepts it.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Tree-sitter Rake
|
|
2
|
+
|
|
3
|
+
This repository provides the Tree-sitter grammar and highlighting queries for
|
|
4
|
+
[Rake](https://rake-lang.org), together with C, Go, Node.js, Python, Rust and
|
|
5
|
+
Swift bindings generated from Tree-sitter's package templates.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm test
|
|
9
|
+
npm run test:differential
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The first command regenerates the parser and runs its corpus and highlighting
|
|
13
|
+
tests. The differential check parses every source file in Rake's compiler test
|
|
14
|
+
manifest with both Tree-sitter and the current compiler, then compares whether
|
|
15
|
+
each parser accepts it.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Tree-sitter grammar for Rake, a vector-first SIMD language."""
|
|
2
|
+
|
|
3
|
+
from importlib.resources import files as _files
|
|
4
|
+
|
|
5
|
+
from ._binding import language
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _get_query(name, file):
|
|
9
|
+
try:
|
|
10
|
+
query = _files(f"{__package__}") / file
|
|
11
|
+
globals()[name] = query.read_text()
|
|
12
|
+
except FileNotFoundError:
|
|
13
|
+
globals()[name] = None
|
|
14
|
+
return globals()[name]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def __getattr__(name):
|
|
18
|
+
if name == "HIGHLIGHTS_QUERY":
|
|
19
|
+
return _get_query("HIGHLIGHTS_QUERY", "queries/highlights.scm")
|
|
20
|
+
if name == "INJECTIONS_QUERY":
|
|
21
|
+
return _get_query("INJECTIONS_QUERY", "queries/injections.scm")
|
|
22
|
+
if name == "LOCALS_QUERY":
|
|
23
|
+
return _get_query("LOCALS_QUERY", "queries/locals.scm")
|
|
24
|
+
if name == "TAGS_QUERY":
|
|
25
|
+
return _get_query("TAGS_QUERY", "queries/tags.scm")
|
|
26
|
+
|
|
27
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"language",
|
|
32
|
+
"HIGHLIGHTS_QUERY",
|
|
33
|
+
"INJECTIONS_QUERY",
|
|
34
|
+
"LOCALS_QUERY",
|
|
35
|
+
"TAGS_QUERY",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def __dir__():
|
|
40
|
+
return sorted(__all__ + [
|
|
41
|
+
"__all__", "__builtins__", "__cached__", "__doc__", "__file__",
|
|
42
|
+
"__loader__", "__name__", "__package__", "__path__", "__spec__",
|
|
43
|
+
])
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Final
|
|
2
|
+
from typing_extensions import CapsuleType
|
|
3
|
+
|
|
4
|
+
HIGHLIGHTS_QUERY: Final[str] | None
|
|
5
|
+
"""The syntax highlighting query for this grammar."""
|
|
6
|
+
|
|
7
|
+
INJECTIONS_QUERY: Final[str] | None
|
|
8
|
+
"""The language injection query for this grammar."""
|
|
9
|
+
|
|
10
|
+
LOCALS_QUERY: Final[str] | None
|
|
11
|
+
"""The local variable query for this grammar."""
|
|
12
|
+
|
|
13
|
+
TAGS_QUERY: Final[str] | None
|
|
14
|
+
"""The symbol tagging query for this grammar."""
|
|
15
|
+
|
|
16
|
+
def language() -> CapsuleType:
|
|
17
|
+
"""The tree-sitter language function for this grammar."""
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_rake(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_rake(), "tree_sitter.Language", NULL);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static struct PyModuleDef_Slot slots[] = {
|
|
12
|
+
#ifdef Py_GIL_DISABLED
|
|
13
|
+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
|
14
|
+
#endif
|
|
15
|
+
{0, NULL}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
static PyMethodDef methods[] = {
|
|
19
|
+
{"language", _binding_language, METH_NOARGS,
|
|
20
|
+
"Get the tree-sitter language for this grammar."},
|
|
21
|
+
{NULL, NULL, 0, NULL}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
static struct PyModuleDef module = {
|
|
25
|
+
.m_base = PyModuleDef_HEAD_INIT,
|
|
26
|
+
.m_name = "_binding",
|
|
27
|
+
.m_doc = NULL,
|
|
28
|
+
.m_size = 0,
|
|
29
|
+
.m_methods = methods,
|
|
30
|
+
.m_slots = slots,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
PyMODINIT_FUNC PyInit__binding(void) {
|
|
34
|
+
return PyModuleDef_Init(&module);
|
|
35
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-rake
|
|
3
|
+
Version: 0.4.0b0
|
|
4
|
+
Summary: Tree-sitter grammar for Rake, a vector-first SIMD language
|
|
5
|
+
Author: Kieran Rosenberg
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rakelang/tree-sitter-rake
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,rake
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Provides-Extra: core
|
|
17
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# Tree-sitter Rake
|
|
21
|
+
|
|
22
|
+
This repository provides the Tree-sitter grammar and highlighting queries for
|
|
23
|
+
[Rake](https://rake-lang.org), together with C, Go, Node.js, Python, Rust and
|
|
24
|
+
Swift bindings generated from Tree-sitter's package templates.
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm test
|
|
28
|
+
npm run test:differential
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The first command regenerates the parser and runs its corpus and highlighting
|
|
32
|
+
tests. The differential check parses every source file in Rake's compiler test
|
|
33
|
+
manifest with both Tree-sitter and the current compiler, then compares whether
|
|
34
|
+
each parser accepts it.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
bindings/python/tree_sitter_rake/__init__.py
|
|
6
|
+
bindings/python/tree_sitter_rake/__init__.pyi
|
|
7
|
+
bindings/python/tree_sitter_rake/binding.c
|
|
8
|
+
bindings/python/tree_sitter_rake/py.typed
|
|
9
|
+
bindings/python/tree_sitter_rake.egg-info/PKG-INFO
|
|
10
|
+
bindings/python/tree_sitter_rake.egg-info/SOURCES.txt
|
|
11
|
+
bindings/python/tree_sitter_rake.egg-info/dependency_links.txt
|
|
12
|
+
bindings/python/tree_sitter_rake.egg-info/not-zip-safe
|
|
13
|
+
bindings/python/tree_sitter_rake.egg-info/requires.txt
|
|
14
|
+
bindings/python/tree_sitter_rake.egg-info/top_level.txt
|
|
15
|
+
src/parser.c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=62.4.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tree-sitter-rake"
|
|
7
|
+
description = "Tree-sitter grammar for Rake, a vector-first SIMD language"
|
|
8
|
+
version = "0.4.0-beta"
|
|
9
|
+
keywords = ["incremental", "parsing", "tree-sitter", "rake"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Topic :: Software Development :: Compilers",
|
|
13
|
+
"Topic :: Text Processing :: Linguistic",
|
|
14
|
+
"Typing :: Typed",
|
|
15
|
+
]
|
|
16
|
+
authors = [{ name = "Kieran Rosenberg" }]
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
license = "MIT"
|
|
19
|
+
license-files = ["LICENSE"]
|
|
20
|
+
readme = "README.md"
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/rakelang/tree-sitter-rake"
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
core = ["tree-sitter~=0.24"]
|
|
27
|
+
|
|
28
|
+
[tool.cibuildwheel]
|
|
29
|
+
build = "cp310-*"
|
|
30
|
+
build-frontend = "build"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
; Rake canonical syntax highlighting
|
|
2
|
+
|
|
3
|
+
(identifier) @variable
|
|
4
|
+
|
|
5
|
+
[
|
|
6
|
+
(line_comment)
|
|
7
|
+
(block_comment)
|
|
8
|
+
] @comment
|
|
9
|
+
|
|
10
|
+
[
|
|
11
|
+
"stack"
|
|
12
|
+
"record"
|
|
13
|
+
"crunch"
|
|
14
|
+
"rake"
|
|
15
|
+
"run"
|
|
16
|
+
"slow"
|
|
17
|
+
"extern"
|
|
18
|
+
"state"
|
|
19
|
+
"embed"
|
|
20
|
+
"const"
|
|
21
|
+
"let"
|
|
22
|
+
"return"
|
|
23
|
+
"yield"
|
|
24
|
+
] @keyword
|
|
25
|
+
|
|
26
|
+
[
|
|
27
|
+
"tine"
|
|
28
|
+
"when"
|
|
29
|
+
"through"
|
|
30
|
+
"else"
|
|
31
|
+
"into"
|
|
32
|
+
"sweep"
|
|
33
|
+
"for"
|
|
34
|
+
"in"
|
|
35
|
+
"using"
|
|
36
|
+
"up"
|
|
37
|
+
"to"
|
|
38
|
+
"from"
|
|
39
|
+
"by"
|
|
40
|
+
"if"
|
|
41
|
+
"then"
|
|
42
|
+
"while"
|
|
43
|
+
"repeat"
|
|
44
|
+
"unchecked"
|
|
45
|
+
"ptr"
|
|
46
|
+
"mut"
|
|
47
|
+
] @keyword
|
|
48
|
+
|
|
49
|
+
(break_statement) @keyword
|
|
50
|
+
(continue_statement) @keyword
|
|
51
|
+
|
|
52
|
+
[
|
|
53
|
+
"pack"
|
|
54
|
+
"stack"
|
|
55
|
+
] @keyword
|
|
56
|
+
|
|
57
|
+
(storage_type) @type.builtin
|
|
58
|
+
(rack_type) @type.builtin
|
|
59
|
+
(mask_type) @type.builtin
|
|
60
|
+
(type_identifier) @type
|
|
61
|
+
(record_definition name: (type_identifier) @type)
|
|
62
|
+
(record_expression record: (type_identifier) @type)
|
|
63
|
+
|
|
64
|
+
(stack_definition name: (type_identifier) @type)
|
|
65
|
+
(crunch_definition name: (identifier) @function)
|
|
66
|
+
(rake_definition name: (identifier) @function)
|
|
67
|
+
(run_definition name: (identifier) @function)
|
|
68
|
+
(slow_definition name: (identifier) @function)
|
|
69
|
+
(extern_definition name: (identifier) @function)
|
|
70
|
+
(conversion_expression kind: _ @function.builtin)
|
|
71
|
+
(call_expression function: (identifier) @function)
|
|
72
|
+
(call_expression function: "fma" @function.builtin)
|
|
73
|
+
(shuffle_expression "shuffle" @function)
|
|
74
|
+
(static_move_expression function: _ @function)
|
|
75
|
+
|
|
76
|
+
(field_group name: (identifier) @property)
|
|
77
|
+
(record_field_group name: (identifier) @property)
|
|
78
|
+
(field_initializer field: (identifier) @property)
|
|
79
|
+
(field_expression field: (identifier) @property)
|
|
80
|
+
|
|
81
|
+
(value_parameter name: (identifier) @variable.parameter)
|
|
82
|
+
(scalar_parameter name: (scalar_name) @variable.parameter)
|
|
83
|
+
(scalar_variable name: (scalar_name) @variable)
|
|
84
|
+
(uniform_binding name: (scalar_name) @variable)
|
|
85
|
+
|
|
86
|
+
(let_statement name: (identifier) @variable)
|
|
87
|
+
(fused_binding name: (identifier) @variable)
|
|
88
|
+
(mutable_binding name: (identifier) @variable)
|
|
89
|
+
(assignment_statement target: (primary_expression (identifier) @variable))
|
|
90
|
+
(through_statement name: (identifier) @variable)
|
|
91
|
+
(traversal_statement binding: (identifier) @variable)
|
|
92
|
+
|
|
93
|
+
; Rake marks one idea with each symbol: a tine is a mask, angle brackets a
|
|
94
|
+
; uniform, and the bars and arrows of a fused binding or sweep a data flow.
|
|
95
|
+
(tine "#" @tag (tine_name) @tag)
|
|
96
|
+
(scalar_parameter "<" @constant ">" @constant)
|
|
97
|
+
(scalar_expression "<" @constant ">" @constant) @constant
|
|
98
|
+
|
|
99
|
+
(fused_binding "|" @operator.flow "<|" @operator.flow)
|
|
100
|
+
(sweep_arm "|" @operator.flow "=>" @operator.flow)
|
|
101
|
+
(sweep_arm selector: "_" @constant.builtin)
|
|
102
|
+
|
|
103
|
+
[
|
|
104
|
+
"->"
|
|
105
|
+
":="
|
|
106
|
+
"<-"
|
|
107
|
+
"="
|
|
108
|
+
"+"
|
|
109
|
+
"-"
|
|
110
|
+
"*"
|
|
111
|
+
"/"
|
|
112
|
+
"%"
|
|
113
|
+
"<"
|
|
114
|
+
"<="
|
|
115
|
+
">"
|
|
116
|
+
">="
|
|
117
|
+
"!="
|
|
118
|
+
"and"
|
|
119
|
+
"or"
|
|
120
|
+
"not"
|
|
121
|
+
] @operator
|
|
122
|
+
|
|
123
|
+
(integer_literal) @number
|
|
124
|
+
(string_literal) @string
|
|
125
|
+
(float_literal) @number
|
|
126
|
+
(boolean_literal) @boolean
|
|
127
|
+
(lanes) @constant.builtin
|
|
128
|
+
(lane_index) @constant.builtin
|
|
129
|
+
|
|
130
|
+
[
|
|
131
|
+
"("
|
|
132
|
+
")"
|
|
133
|
+
"{"
|
|
134
|
+
"}"
|
|
135
|
+
"["
|
|
136
|
+
"]"
|
|
137
|
+
] @punctuation.bracket
|
|
138
|
+
|
|
139
|
+
[
|
|
140
|
+
","
|
|
141
|
+
";"
|
|
142
|
+
":"
|
|
143
|
+
"."
|
|
144
|
+
] @punctuation.delimiter
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from os import path
|
|
2
|
+
from sysconfig import get_config_var
|
|
3
|
+
|
|
4
|
+
from setuptools import Extension, find_packages, setup
|
|
5
|
+
from setuptools.command.build import build
|
|
6
|
+
from setuptools.command.build_ext import build_ext
|
|
7
|
+
from setuptools.command.egg_info import egg_info
|
|
8
|
+
from wheel.bdist_wheel import bdist_wheel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Build(build):
|
|
12
|
+
def run(self):
|
|
13
|
+
if path.isdir("queries"):
|
|
14
|
+
dest = path.join(self.build_lib, "tree_sitter_rake", "queries")
|
|
15
|
+
self.copy_tree("queries", dest)
|
|
16
|
+
super().run()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BuildExt(build_ext):
|
|
20
|
+
def build_extension(self, ext: Extension):
|
|
21
|
+
if self.compiler.compiler_type != "msvc":
|
|
22
|
+
ext.extra_compile_args = ["-std=c11", "-fvisibility=hidden"]
|
|
23
|
+
else:
|
|
24
|
+
ext.extra_compile_args = ["/std:c11", "/utf-8"]
|
|
25
|
+
if path.exists("src/scanner.c"):
|
|
26
|
+
ext.sources.append("src/scanner.c")
|
|
27
|
+
if ext.py_limited_api:
|
|
28
|
+
ext.define_macros.append(("Py_LIMITED_API", "0x030A0000"))
|
|
29
|
+
super().build_extension(ext)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class BdistWheel(bdist_wheel):
|
|
33
|
+
def get_tag(self):
|
|
34
|
+
python, abi, platform = super().get_tag()
|
|
35
|
+
if python.startswith("cp") and not get_config_var("Py_GIL_DISABLED"):
|
|
36
|
+
python, abi = "cp310", "abi3"
|
|
37
|
+
return python, abi, platform
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class EggInfo(egg_info):
|
|
41
|
+
def find_sources(self):
|
|
42
|
+
super().find_sources()
|
|
43
|
+
self.filelist.recursive_include("queries", "*.scm")
|
|
44
|
+
self.filelist.include("src/tree_sitter/*.h")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
setup(
|
|
48
|
+
packages=find_packages("bindings/python"),
|
|
49
|
+
package_dir={"": "bindings/python"},
|
|
50
|
+
package_data={
|
|
51
|
+
"tree_sitter_rake": ["*.pyi", "py.typed"],
|
|
52
|
+
"tree_sitter_rake.queries": ["*.scm"],
|
|
53
|
+
},
|
|
54
|
+
ext_package="tree_sitter_rake",
|
|
55
|
+
ext_modules=[
|
|
56
|
+
Extension(
|
|
57
|
+
name="_binding",
|
|
58
|
+
sources=[
|
|
59
|
+
"bindings/python/tree_sitter_rake/binding.c",
|
|
60
|
+
"src/parser.c",
|
|
61
|
+
],
|
|
62
|
+
define_macros=[
|
|
63
|
+
("PY_SSIZE_T_CLEAN", None),
|
|
64
|
+
("TREE_SITTER_HIDE_SYMBOLS", None),
|
|
65
|
+
],
|
|
66
|
+
include_dirs=["src"],
|
|
67
|
+
py_limited_api=not get_config_var("Py_GIL_DISABLED"),
|
|
68
|
+
)
|
|
69
|
+
],
|
|
70
|
+
cmdclass={
|
|
71
|
+
"build": Build,
|
|
72
|
+
"build_ext": BuildExt,
|
|
73
|
+
"bdist_wheel": BdistWheel,
|
|
74
|
+
"egg_info": EggInfo,
|
|
75
|
+
},
|
|
76
|
+
zip_safe=False
|
|
77
|
+
)
|