tree-sitter-strudel 0.1.0__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.
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-strudel
3
+ Version: 0.1.0
4
+ Summary: Parser for Strudel, a Tidal Cycles base live coding tool
5
+ Author-email: Zedro <45104292+PedroZappa@users.noreply.github.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/pedrozappa/tree-sitter-strdl
8
+ Keywords: incremental,parsing,tree-sitter,strudel
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-strdl
21
+
22
+ Tree-sitter parser for Strudel, a Tidal Cycles based live coding tool.
23
+
24
+ ___
25
+
26
+ - [Tree-sitter](https://tree-sitter.github.io/tree-sitter/)
27
+ - [Strudel.cc](https://strudel.cc/)
28
+ - [Tidal Cycles ](https://tidalcycles.org/)
@@ -0,0 +1,9 @@
1
+ # tree-sitter-strdl
2
+
3
+ Tree-sitter parser for Strudel, a Tidal Cycles based live coding tool.
4
+
5
+ ___
6
+
7
+ - [Tree-sitter](https://tree-sitter.github.io/tree-sitter/)
8
+ - [Strudel.cc](https://strudel.cc/)
9
+ - [Tidal Cycles ](https://tidalcycles.org/)
@@ -0,0 +1,42 @@
1
+ """Parser for Strudel, a Tidal Cycles base live coding tool"""
2
+
3
+ from importlib.resources import files as _files
4
+
5
+ from ._binding import language
6
+
7
+
8
+ def _get_query(name, file):
9
+ query = _files(f"{__package__}.queries") / file
10
+ globals()[name] = query.read_text()
11
+ return globals()[name]
12
+
13
+
14
+ def __getattr__(name):
15
+ # NOTE: uncomment these to include any queries that this grammar contains:
16
+
17
+ # if name == "HIGHLIGHTS_QUERY":
18
+ # return _get_query("HIGHLIGHTS_QUERY", "highlights.scm")
19
+ # if name == "INJECTIONS_QUERY":
20
+ # return _get_query("INJECTIONS_QUERY", "injections.scm")
21
+ # if name == "LOCALS_QUERY":
22
+ # return _get_query("LOCALS_QUERY", "locals.scm")
23
+ # if name == "TAGS_QUERY":
24
+ # return _get_query("TAGS_QUERY", "tags.scm")
25
+
26
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
27
+
28
+
29
+ __all__ = [
30
+ "language",
31
+ # "HIGHLIGHTS_QUERY",
32
+ # "INJECTIONS_QUERY",
33
+ # "LOCALS_QUERY",
34
+ # "TAGS_QUERY",
35
+ ]
36
+
37
+
38
+ def __dir__():
39
+ return sorted(__all__ + [
40
+ "__all__", "__builtins__", "__cached__", "__doc__", "__file__",
41
+ "__loader__", "__name__", "__package__", "__path__", "__spec__",
42
+ ])
@@ -0,0 +1,10 @@
1
+ from typing import Final
2
+
3
+ # NOTE: uncomment these to include any queries that this grammar contains:
4
+
5
+ # HIGHLIGHTS_QUERY: Final[str]
6
+ # INJECTIONS_QUERY: Final[str]
7
+ # LOCALS_QUERY: Final[str]
8
+ # TAGS_QUERY: Final[str]
9
+
10
+ def language() -> object: ...
@@ -0,0 +1,35 @@
1
+ #include <Python.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ TSLanguage *tree_sitter_strudel(void);
6
+
7
+ static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
8
+ return PyCapsule_New(tree_sitter_strudel(), "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
+ }
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-strudel
3
+ Version: 0.1.0
4
+ Summary: Parser for Strudel, a Tidal Cycles base live coding tool
5
+ Author-email: Zedro <45104292+PedroZappa@users.noreply.github.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/pedrozappa/tree-sitter-strdl
8
+ Keywords: incremental,parsing,tree-sitter,strudel
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-strdl
21
+
22
+ Tree-sitter parser for Strudel, a Tidal Cycles based live coding tool.
23
+
24
+ ___
25
+
26
+ - [Tree-sitter](https://tree-sitter.github.io/tree-sitter/)
27
+ - [Strudel.cc](https://strudel.cc/)
28
+ - [Tidal Cycles ](https://tidalcycles.org/)
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ bindings/python/tree_sitter_strudel/__init__.py
6
+ bindings/python/tree_sitter_strudel/__init__.pyi
7
+ bindings/python/tree_sitter_strudel/binding.c
8
+ bindings/python/tree_sitter_strudel/py.typed
9
+ bindings/python/tree_sitter_strudel.egg-info/PKG-INFO
10
+ bindings/python/tree_sitter_strudel.egg-info/SOURCES.txt
11
+ bindings/python/tree_sitter_strudel.egg-info/dependency_links.txt
12
+ bindings/python/tree_sitter_strudel.egg-info/not-zip-safe
13
+ bindings/python/tree_sitter_strudel.egg-info/requires.txt
14
+ bindings/python/tree_sitter_strudel.egg-info/top_level.txt
15
+ src/parser.c
@@ -0,0 +1,2 @@
1
+ _binding
2
+ tree_sitter_strudel
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=62.4.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tree-sitter-strudel"
7
+ description = "Parser for Strudel, a Tidal Cycles base live coding tool"
8
+ version = "0.1.0"
9
+ keywords = ["incremental", "parsing", "tree-sitter", "strudel"]
10
+ classifiers = [
11
+ "Intended Audience :: Developers",
12
+ "Topic :: Software Development :: Compilers",
13
+ "Topic :: Text Processing :: Linguistic",
14
+ "Typing :: Typed",
15
+ ]
16
+ authors = [{ name = "Zedro", email = "45104292+PedroZappa@users.noreply.github.com " }]
17
+ requires-python = ">=3.10"
18
+ license.text = "MIT"
19
+ readme = "README.md"
20
+
21
+ [project.urls]
22
+ Homepage = "https://github.com/pedrozappa/tree-sitter-strdl"
23
+
24
+ [project.optional-dependencies]
25
+ core = ["tree-sitter~=0.24"]
26
+
27
+ [tool.cibuildwheel]
28
+ build = "cp310-*"
29
+ build-frontend = "build"
@@ -0,0 +1,64 @@
1
+ ; ---------------------------------------------------------------------------
2
+ ; Strudel syntax-highlighting rules
3
+ ; ---------------------------------------------------------------------------
4
+ ; CAPTURE NAMING
5
+ ; 1. Specific > generic – put the most specific patterns first.
6
+ ; 2. Use the standard highlight names recognised by tree-sitter-highlight[10].
7
+ ; ---------------------------------------------------------------------------
8
+
9
+ ; ──────────────────────────────────────────────────────────────────────────
10
+ ; Keywords
11
+ ; ──────────────────────────────────────────────────────────────────────────
12
+ "var" @keyword ; variable declaration
13
+ "let" @keyword
14
+ "const" @keyword
15
+ "$:" @keyword ; default assignment prefix
16
+
17
+ ; ──────────────────────────────────────────────────────────────────────────
18
+ ; Punctuation & Operators
19
+ ; ──────────────────────────────────────────────────────────────────────────
20
+ "=" @operator
21
+ "." @punctuation.delimiter
22
+ "," @punctuation.delimiter
23
+ ":" @punctuation.delimiter
24
+ ";" @punctuation.delimiter
25
+ "(" @punctuation.bracket
26
+ ")" @punctuation.bracket
27
+
28
+ ; ──────────────────────────────────────────────────────────────────────────
29
+ ; Literals
30
+ ; ──────────────────────────────────────────────────────────────────────────
31
+ (string) @string
32
+ (number) @number
33
+ (comment) @comment
34
+
35
+ ; ──────────────────────────────────────────────────────────────────────────
36
+ ; Identifiers
37
+ ; ──────────────────────────────────────────────────────────────────────────
38
+ ; 1. Function call identifiers
39
+ (function_call
40
+ (identifier) @function.call)
41
+
42
+ ; 2. Method call identifiers (after the dot)
43
+ (method_call
44
+ (identifier) @function.method)
45
+
46
+ ; 3. Variable declarations: names on the LHS
47
+ (variable_declarator
48
+ name: (identifier) @variable)
49
+
50
+ ; 4. All remaining identifiers default to variable
51
+ (identifier) @variable
52
+
53
+ ; ──────────────────────────────────────────────────────────────────────────
54
+ ; Expressions & Chains
55
+ ; ──────────────────────────────────────────────────────────────────────────
56
+ ; Highlight the leading identifier of a chained method sequence
57
+ (chained_method
58
+ (_
59
+ .
60
+ (identifier) @function.method))
61
+
62
+ ; Nothing else is needed here because the above identifier rules
63
+ ; already take care of nested names inside the chain.
64
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,77 @@
1
+ from os import path
2
+ from platform import system
3
+ from sysconfig import get_config_var
4
+
5
+ from setuptools import Extension, find_packages, setup
6
+ from setuptools.command.build import build
7
+ from setuptools.command.egg_info import egg_info
8
+ from wheel.bdist_wheel import bdist_wheel
9
+
10
+ sources = [
11
+ "bindings/python/tree_sitter_strudel/binding.c",
12
+ "src/parser.c",
13
+ ]
14
+ if path.exists("src/scanner.c"):
15
+ sources.append("src/scanner.c")
16
+
17
+ macros: list[tuple[str, str | None]] = [
18
+ ("PY_SSIZE_T_CLEAN", None),
19
+ ("TREE_SITTER_HIDE_SYMBOLS", None),
20
+ ]
21
+ if limited_api := not get_config_var("Py_GIL_DISABLED"):
22
+ macros.append(("Py_LIMITED_API", "0x030A0000"))
23
+
24
+ if system() != "Windows":
25
+ cflags = ["-std=c11", "-fvisibility=hidden"]
26
+ else:
27
+ cflags = ["/std:c11", "/utf-8"]
28
+
29
+
30
+ class Build(build):
31
+ def run(self):
32
+ if path.isdir("queries"):
33
+ dest = path.join(self.build_lib, "tree_sitter_strudel", "queries")
34
+ self.copy_tree("queries", dest)
35
+ super().run()
36
+
37
+
38
+ class BdistWheel(bdist_wheel):
39
+ def get_tag(self):
40
+ python, abi, platform = super().get_tag()
41
+ if python.startswith("cp"):
42
+ python, abi = "cp310", "abi3"
43
+ return python, abi, platform
44
+
45
+
46
+ class EggInfo(egg_info):
47
+ def find_sources(self):
48
+ super().find_sources()
49
+ self.filelist.recursive_include("queries", "*.scm")
50
+ self.filelist.include("src/tree_sitter/*.h")
51
+
52
+
53
+ setup(
54
+ packages=find_packages("bindings/python"),
55
+ package_dir={"": "bindings/python"},
56
+ package_data={
57
+ "tree_sitter_strudel": ["*.pyi", "py.typed"],
58
+ "tree_sitter_strudel.queries": ["*.scm"],
59
+ },
60
+ ext_package="tree_sitter_strudel",
61
+ ext_modules=[
62
+ Extension(
63
+ name="_binding",
64
+ sources=sources,
65
+ extra_compile_args=cflags,
66
+ define_macros=macros,
67
+ include_dirs=["src"],
68
+ py_limited_api=limited_api,
69
+ )
70
+ ],
71
+ cmdclass={
72
+ "build": Build,
73
+ "bdist_wheel": BdistWheel,
74
+ "egg_info": EggInfo,
75
+ },
76
+ zip_safe=False
77
+ )