tree-sitter-faust 1.1.5__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Karl Hiner
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,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-faust
3
+ Version: 1.1.5
4
+ Summary: Tree-sitter grammar for the Faust audio programming language
5
+ Author: Karl Hiner
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/khiner/tree-sitter-faust
8
+ Keywords: incremental,parsing,tree-sitter,faust
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.9
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-faust
21
+
22
+ [Tree-sitter](https://tree-sitter.github.io/) grammar for the [Faust audio programming language](https://faustdoc.grame.fr/manual/syntax/).
23
+
24
+ Every Faust syntax feature should be supported.
25
+ If you encounter any errors parsing a valid Faust program, please file an issue and I'll fix it!
26
+ Also, please file an issue or pull request if you have any suggestions for improving the grammar.
27
+
28
+ The npm package is [here](https://www.npmjs.com/package/tree-sitter-faust).
29
+
30
+ ## Python
31
+
32
+ ```shell
33
+ pip install tree-sitter-faust[core]
34
+ ```
35
+
36
+ ```python
37
+ from tree_sitter import Language, Parser
38
+ from tree_sitter_faust import language
39
+
40
+ code = 'import("stdfaust.lib"); process = os.osc(440) * 0.5;'
41
+
42
+ parser = Parser(Language(language()))
43
+ tree = parser.parse(code.encode())
44
+ ```
45
+
46
+ Bundled queries are also available as `HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`, and `LOCALS_QUERY`.
47
+
48
+ ## Install `nvim-treesitter` language parser
49
+
50
+ The parser and queries are available as an [nvim-treesitter language](https://github.com/nvim-treesitter/nvim-treesitter/?tab=readme-ov-file#supported-languages).
51
+
52
+ Install with the `nvim` command:
53
+ ```nvim
54
+ :TSInstall faust
55
+ ```
56
+
57
+ ## Commands
58
+
59
+ ```shell
60
+ $ npm run build # generate and build
61
+ $ npm run generate # tree-sitter generate
62
+ $ npm test # tree-sitter test
63
+ $ npm run parse # tree-sitter parse
64
+ ```
65
+
66
+ See [tree-sitter's documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers#tool-overview) for details on tree-sitter CLI commands.
67
+
68
+ ## Resources
69
+
70
+ - [Faust syntax documentation](https://faustdoc.grame.fr/manual/syntax/)
71
+ - Faust Bison [parser](https://github.com/grame-cncm/faust/blob/master-dev/compiler/parser/faustparser.y) and Flex [lexer](https://github.com/grame-cncm/faust/blob/master-dev/compiler/parser/faustlexer.l) source
72
+ - [Faust box-tester](https://github.com/grame-cncm/faust/blob/master-dev/tools/benchmark/box-tester.cpp)
73
+
74
+ ## TODO
75
+
76
+ - Add `playground` script for `tree-sitter build-wasm && tree-sitter web-ui`?
77
+ - Saw this [here](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations)
@@ -0,0 +1,58 @@
1
+ # tree-sitter-faust
2
+
3
+ [Tree-sitter](https://tree-sitter.github.io/) grammar for the [Faust audio programming language](https://faustdoc.grame.fr/manual/syntax/).
4
+
5
+ Every Faust syntax feature should be supported.
6
+ If you encounter any errors parsing a valid Faust program, please file an issue and I'll fix it!
7
+ Also, please file an issue or pull request if you have any suggestions for improving the grammar.
8
+
9
+ The npm package is [here](https://www.npmjs.com/package/tree-sitter-faust).
10
+
11
+ ## Python
12
+
13
+ ```shell
14
+ pip install tree-sitter-faust[core]
15
+ ```
16
+
17
+ ```python
18
+ from tree_sitter import Language, Parser
19
+ from tree_sitter_faust import language
20
+
21
+ code = 'import("stdfaust.lib"); process = os.osc(440) * 0.5;'
22
+
23
+ parser = Parser(Language(language()))
24
+ tree = parser.parse(code.encode())
25
+ ```
26
+
27
+ Bundled queries are also available as `HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`, and `LOCALS_QUERY`.
28
+
29
+ ## Install `nvim-treesitter` language parser
30
+
31
+ The parser and queries are available as an [nvim-treesitter language](https://github.com/nvim-treesitter/nvim-treesitter/?tab=readme-ov-file#supported-languages).
32
+
33
+ Install with the `nvim` command:
34
+ ```nvim
35
+ :TSInstall faust
36
+ ```
37
+
38
+ ## Commands
39
+
40
+ ```shell
41
+ $ npm run build # generate and build
42
+ $ npm run generate # tree-sitter generate
43
+ $ npm test # tree-sitter test
44
+ $ npm run parse # tree-sitter parse
45
+ ```
46
+
47
+ See [tree-sitter's documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers#tool-overview) for details on tree-sitter CLI commands.
48
+
49
+ ## Resources
50
+
51
+ - [Faust syntax documentation](https://faustdoc.grame.fr/manual/syntax/)
52
+ - Faust Bison [parser](https://github.com/grame-cncm/faust/blob/master-dev/compiler/parser/faustparser.y) and Flex [lexer](https://github.com/grame-cncm/faust/blob/master-dev/compiler/parser/faustlexer.l) source
53
+ - [Faust box-tester](https://github.com/grame-cncm/faust/blob/master-dev/tools/benchmark/box-tester.cpp)
54
+
55
+ ## TODO
56
+
57
+ - Add `playground` script for `tree-sitter build-wasm && tree-sitter web-ui`?
58
+ - Saw this [here](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations)
@@ -0,0 +1,37 @@
1
+ """Tree-sitter grammar for the Faust audio programming 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
+ query = _files(f"{__package__}.queries") / file
10
+ globals()[name] = query.read_text()
11
+ return globals()[name]
12
+
13
+
14
+ def __getattr__(name):
15
+ if name == "HIGHLIGHTS_QUERY":
16
+ return _get_query("HIGHLIGHTS_QUERY", "highlights.scm")
17
+ if name == "INJECTIONS_QUERY":
18
+ return _get_query("INJECTIONS_QUERY", "injections.scm")
19
+ if name == "LOCALS_QUERY":
20
+ return _get_query("LOCALS_QUERY", "locals.scm")
21
+
22
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
23
+
24
+
25
+ __all__ = [
26
+ "language",
27
+ "HIGHLIGHTS_QUERY",
28
+ "INJECTIONS_QUERY",
29
+ "LOCALS_QUERY",
30
+ ]
31
+
32
+
33
+ def __dir__():
34
+ return sorted(__all__ + [
35
+ "__all__", "__builtins__", "__cached__", "__doc__", "__file__",
36
+ "__loader__", "__name__", "__package__", "__path__", "__spec__",
37
+ ])
@@ -0,0 +1,7 @@
1
+ from typing import Final
2
+
3
+ HIGHLIGHTS_QUERY: Final[str]
4
+ INJECTIONS_QUERY: Final[str]
5
+ LOCALS_QUERY: Final[str]
6
+
7
+ def language() -> object: ...
@@ -0,0 +1,27 @@
1
+ #include <Python.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ TSLanguage *tree_sitter_faust(void);
6
+
7
+ static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
8
+ return PyCapsule_New(tree_sitter_faust(), "tree_sitter.Language", NULL);
9
+ }
10
+
11
+ static PyMethodDef methods[] = {
12
+ {"language", _binding_language, METH_NOARGS,
13
+ "Get the tree-sitter language for this grammar."},
14
+ {NULL, NULL, 0, NULL}
15
+ };
16
+
17
+ static struct PyModuleDef module = {
18
+ .m_base = PyModuleDef_HEAD_INIT,
19
+ .m_name = "_binding",
20
+ .m_doc = NULL,
21
+ .m_size = -1,
22
+ .m_methods = methods
23
+ };
24
+
25
+ PyMODINIT_FUNC PyInit__binding(void) {
26
+ return PyModule_Create(&module);
27
+ }
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-faust
3
+ Version: 1.1.5
4
+ Summary: Tree-sitter grammar for the Faust audio programming language
5
+ Author: Karl Hiner
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/khiner/tree-sitter-faust
8
+ Keywords: incremental,parsing,tree-sitter,faust
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.9
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-faust
21
+
22
+ [Tree-sitter](https://tree-sitter.github.io/) grammar for the [Faust audio programming language](https://faustdoc.grame.fr/manual/syntax/).
23
+
24
+ Every Faust syntax feature should be supported.
25
+ If you encounter any errors parsing a valid Faust program, please file an issue and I'll fix it!
26
+ Also, please file an issue or pull request if you have any suggestions for improving the grammar.
27
+
28
+ The npm package is [here](https://www.npmjs.com/package/tree-sitter-faust).
29
+
30
+ ## Python
31
+
32
+ ```shell
33
+ pip install tree-sitter-faust[core]
34
+ ```
35
+
36
+ ```python
37
+ from tree_sitter import Language, Parser
38
+ from tree_sitter_faust import language
39
+
40
+ code = 'import("stdfaust.lib"); process = os.osc(440) * 0.5;'
41
+
42
+ parser = Parser(Language(language()))
43
+ tree = parser.parse(code.encode())
44
+ ```
45
+
46
+ Bundled queries are also available as `HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`, and `LOCALS_QUERY`.
47
+
48
+ ## Install `nvim-treesitter` language parser
49
+
50
+ The parser and queries are available as an [nvim-treesitter language](https://github.com/nvim-treesitter/nvim-treesitter/?tab=readme-ov-file#supported-languages).
51
+
52
+ Install with the `nvim` command:
53
+ ```nvim
54
+ :TSInstall faust
55
+ ```
56
+
57
+ ## Commands
58
+
59
+ ```shell
60
+ $ npm run build # generate and build
61
+ $ npm run generate # tree-sitter generate
62
+ $ npm test # tree-sitter test
63
+ $ npm run parse # tree-sitter parse
64
+ ```
65
+
66
+ See [tree-sitter's documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers#tool-overview) for details on tree-sitter CLI commands.
67
+
68
+ ## Resources
69
+
70
+ - [Faust syntax documentation](https://faustdoc.grame.fr/manual/syntax/)
71
+ - Faust Bison [parser](https://github.com/grame-cncm/faust/blob/master-dev/compiler/parser/faustparser.y) and Flex [lexer](https://github.com/grame-cncm/faust/blob/master-dev/compiler/parser/faustlexer.l) source
72
+ - [Faust box-tester](https://github.com/grame-cncm/faust/blob/master-dev/tools/benchmark/box-tester.cpp)
73
+
74
+ ## TODO
75
+
76
+ - Add `playground` script for `tree-sitter build-wasm && tree-sitter web-ui`?
77
+ - Saw this [here](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations)
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ bindings/python/tree_sitter_faust/__init__.py
6
+ bindings/python/tree_sitter_faust/__init__.pyi
7
+ bindings/python/tree_sitter_faust/binding.c
8
+ bindings/python/tree_sitter_faust/py.typed
9
+ bindings/python/tree_sitter_faust.egg-info/PKG-INFO
10
+ bindings/python/tree_sitter_faust.egg-info/SOURCES.txt
11
+ bindings/python/tree_sitter_faust.egg-info/dependency_links.txt
12
+ bindings/python/tree_sitter_faust.egg-info/not-zip-safe
13
+ bindings/python/tree_sitter_faust.egg-info/requires.txt
14
+ bindings/python/tree_sitter_faust.egg-info/top_level.txt
15
+ src/parser.c
@@ -0,0 +1,3 @@
1
+
2
+ [core]
3
+ tree-sitter~=0.24
@@ -0,0 +1,2 @@
1
+ _binding
2
+ tree_sitter_faust
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=62.4.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tree-sitter-faust"
7
+ description = "Tree-sitter grammar for the Faust audio programming language"
8
+ version = "1.1.5"
9
+ keywords = ["incremental", "parsing", "tree-sitter", "faust"]
10
+ classifiers = [
11
+ "Intended Audience :: Developers",
12
+ "Topic :: Software Development :: Compilers",
13
+ "Topic :: Text Processing :: Linguistic",
14
+ "Typing :: Typed",
15
+ ]
16
+ authors = [
17
+ {name = "Karl Hiner"},
18
+ ]
19
+ requires-python = ">=3.9"
20
+ license.text = "MIT"
21
+ readme = "README.md"
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/khiner/tree-sitter-faust"
25
+
26
+ [project.optional-dependencies]
27
+ core = ["tree-sitter~=0.24"]
28
+
29
+ [tool.cibuildwheel]
30
+ build = "cp39-*"
31
+ build-frontend = "build"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ from os.path import isdir, join
2
+ from platform import system
3
+
4
+ from setuptools import Extension, find_packages, setup
5
+ from setuptools.command.build import build
6
+ from wheel.bdist_wheel import bdist_wheel
7
+
8
+
9
+ class Build(build):
10
+ def run(self):
11
+ if isdir("queries"):
12
+ dest = join(self.build_lib, "tree_sitter_faust", "queries")
13
+ self.copy_tree("queries", dest)
14
+ super().run()
15
+
16
+
17
+ class BdistWheel(bdist_wheel):
18
+ def get_tag(self):
19
+ python, abi, platform = super().get_tag()
20
+ if python.startswith("cp"):
21
+ python, abi = "cp39", "abi3"
22
+ return python, abi, platform
23
+
24
+
25
+ setup(
26
+ packages=find_packages("bindings/python"),
27
+ package_dir={"": "bindings/python"},
28
+ package_data={
29
+ "tree_sitter_faust": ["*.pyi", "py.typed"],
30
+ "tree_sitter_faust.queries": ["*.scm"],
31
+ },
32
+ ext_package="tree_sitter_faust",
33
+ ext_modules=[
34
+ Extension(
35
+ name="_binding",
36
+ sources=[
37
+ "bindings/python/tree_sitter_faust/binding.c",
38
+ "src/parser.c",
39
+ # NOTE: if your language uses an external scanner, add it here.
40
+ ],
41
+ extra_compile_args=[
42
+ "-std=c11",
43
+ "-fvisibility=hidden",
44
+ ] if system() != "Windows" else [
45
+ "/std:c11",
46
+ "/utf-8",
47
+ ],
48
+ define_macros=[
49
+ ("Py_LIMITED_API", "0x03090000"),
50
+ ("PY_SSIZE_T_CLEAN", None),
51
+ ("TREE_SITTER_HIDE_SYMBOLS", None),
52
+ ],
53
+ include_dirs=["src"],
54
+ py_limited_api=True,
55
+ )
56
+ ],
57
+ cmdclass={
58
+ "build": Build,
59
+ "bdist_wheel": BdistWheel
60
+ },
61
+ zip_safe=False
62
+ )