tree-sitter-bash-orchard 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.
Files changed (22) hide show
  1. tree_sitter_bash_orchard-0.1.0/LICENSE +21 -0
  2. tree_sitter_bash_orchard-0.1.0/PKG-INFO +51 -0
  3. tree_sitter_bash_orchard-0.1.0/README.md +32 -0
  4. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard/__init__.py +43 -0
  5. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard/__init__.pyi +17 -0
  6. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard/binding.c +35 -0
  7. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard/py.typed +0 -0
  8. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard.egg-info/PKG-INFO +51 -0
  9. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard.egg-info/SOURCES.txt +15 -0
  10. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard.egg-info/dependency_links.txt +1 -0
  11. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard.egg-info/not-zip-safe +1 -0
  12. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard.egg-info/requires.txt +3 -0
  13. tree_sitter_bash_orchard-0.1.0/bindings/python/tree_sitter_bash_orchard.egg-info/top_level.txt +2 -0
  14. tree_sitter_bash_orchard-0.1.0/pyproject.toml +29 -0
  15. tree_sitter_bash_orchard-0.1.0/queries/highlights.scm +56 -0
  16. tree_sitter_bash_orchard-0.1.0/setup.cfg +4 -0
  17. tree_sitter_bash_orchard-0.1.0/setup.py +78 -0
  18. tree_sitter_bash_orchard-0.1.0/src/parser.c +350601 -0
  19. tree_sitter_bash_orchard-0.1.0/src/scanner.c +1217 -0
  20. tree_sitter_bash_orchard-0.1.0/src/tree_sitter/alloc.h +54 -0
  21. tree_sitter_bash_orchard-0.1.0/src/tree_sitter/array.h +336 -0
  22. tree_sitter_bash_orchard-0.1.0/src/tree_sitter/parser.h +286 -0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
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,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-bash-orchard
3
+ Version: 0.1.0
4
+ Summary: Parser for Bash files
5
+ Author-email: Max Brunsfeld <maxbrunsfeld@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://codeberg.org/grammar-orchard/tree-sitter-bash-orchard
8
+ Keywords: incremental,parsing,tree-sitter,bash-orchard
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-bash-orchard
21
+
22
+ [![crates][crates]](https://crates.io/crates/tree-sitter-bash-orchard)
23
+ [![pypi][pypi]](https://pypi.org/project/tree-sitter-bash-orchard)
24
+ [![npm][npm]](https://www.npmjs.com/package/tree-sitter-bash-orchard)
25
+
26
+ This is a tree-sitter grammar for Bash.
27
+
28
+ ### Using it
29
+
30
+ You can obtain this parser in various formats:
31
+ * as an archive from [the Releases page](/grammar-orchard/tree-sitter-bash-orchard/releases), which contains all the generated files (bindings, parser code)
32
+ * as a Rust crate: `cargo add tree-sitter-bash-orchard`
33
+ * as a Python package: `pip install tree-sitter-bash-orchard`
34
+ * as an NPM package: `npm install tree-sitter-bash-orchard`
35
+ * As a Git repository with generated files checked-in, via the [GitHub mirror](https://github.com/grammar-orchard/tree-sitter-bash-orchard)
36
+
37
+ ### Contributing
38
+
39
+ Contributions are welcome, so are co-maintainers.
40
+
41
+ Unlike many grammar repositories, this one does not track generated files.
42
+ After cloning this repository, you'll need to run `tree-sitter generate` to obtain the parser.
43
+ If you want to use it via bindings, you'll also need to run `tree-sitter init`.
44
+
45
+ ### Origin
46
+
47
+ This project was forked from https://github.com/tree-sitter/tree-sitter-bash, to [ease the use of and collaboration on this grammar](https://codeberg.org/grammar-orchard#for-contributors).
48
+
49
+ [crates]: https://img.shields.io/crates/v/tree-sitter-bash-orchard?logo=rust
50
+ [pypi]: https://img.shields.io/pypi/v/tree-sitter-bash-orchard?logo=pypi&logoColor=ffd242
51
+ [npm]: https://img.shields.io/npm/v/tree-sitter-bash-orchard?logo=npm
@@ -0,0 +1,32 @@
1
+ # tree-sitter-bash-orchard
2
+
3
+ [![crates][crates]](https://crates.io/crates/tree-sitter-bash-orchard)
4
+ [![pypi][pypi]](https://pypi.org/project/tree-sitter-bash-orchard)
5
+ [![npm][npm]](https://www.npmjs.com/package/tree-sitter-bash-orchard)
6
+
7
+ This is a tree-sitter grammar for Bash.
8
+
9
+ ### Using it
10
+
11
+ You can obtain this parser in various formats:
12
+ * as an archive from [the Releases page](/grammar-orchard/tree-sitter-bash-orchard/releases), which contains all the generated files (bindings, parser code)
13
+ * as a Rust crate: `cargo add tree-sitter-bash-orchard`
14
+ * as a Python package: `pip install tree-sitter-bash-orchard`
15
+ * as an NPM package: `npm install tree-sitter-bash-orchard`
16
+ * As a Git repository with generated files checked-in, via the [GitHub mirror](https://github.com/grammar-orchard/tree-sitter-bash-orchard)
17
+
18
+ ### Contributing
19
+
20
+ Contributions are welcome, so are co-maintainers.
21
+
22
+ Unlike many grammar repositories, this one does not track generated files.
23
+ After cloning this repository, you'll need to run `tree-sitter generate` to obtain the parser.
24
+ If you want to use it via bindings, you'll also need to run `tree-sitter init`.
25
+
26
+ ### Origin
27
+
28
+ This project was forked from https://github.com/tree-sitter/tree-sitter-bash, to [ease the use of and collaboration on this grammar](https://codeberg.org/grammar-orchard#for-contributors).
29
+
30
+ [crates]: https://img.shields.io/crates/v/tree-sitter-bash-orchard?logo=rust
31
+ [pypi]: https://img.shields.io/pypi/v/tree-sitter-bash-orchard?logo=pypi&logoColor=ffd242
32
+ [npm]: https://img.shields.io/npm/v/tree-sitter-bash-orchard?logo=npm
@@ -0,0 +1,43 @@
1
+ """Parser for Bash files"""
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_bash_orchard(void);
6
+
7
+ static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
8
+ return PyCapsule_New(tree_sitter_bash_orchard(), "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,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-bash-orchard
3
+ Version: 0.1.0
4
+ Summary: Parser for Bash files
5
+ Author-email: Max Brunsfeld <maxbrunsfeld@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://codeberg.org/grammar-orchard/tree-sitter-bash-orchard
8
+ Keywords: incremental,parsing,tree-sitter,bash-orchard
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-bash-orchard
21
+
22
+ [![crates][crates]](https://crates.io/crates/tree-sitter-bash-orchard)
23
+ [![pypi][pypi]](https://pypi.org/project/tree-sitter-bash-orchard)
24
+ [![npm][npm]](https://www.npmjs.com/package/tree-sitter-bash-orchard)
25
+
26
+ This is a tree-sitter grammar for Bash.
27
+
28
+ ### Using it
29
+
30
+ You can obtain this parser in various formats:
31
+ * as an archive from [the Releases page](/grammar-orchard/tree-sitter-bash-orchard/releases), which contains all the generated files (bindings, parser code)
32
+ * as a Rust crate: `cargo add tree-sitter-bash-orchard`
33
+ * as a Python package: `pip install tree-sitter-bash-orchard`
34
+ * as an NPM package: `npm install tree-sitter-bash-orchard`
35
+ * As a Git repository with generated files checked-in, via the [GitHub mirror](https://github.com/grammar-orchard/tree-sitter-bash-orchard)
36
+
37
+ ### Contributing
38
+
39
+ Contributions are welcome, so are co-maintainers.
40
+
41
+ Unlike many grammar repositories, this one does not track generated files.
42
+ After cloning this repository, you'll need to run `tree-sitter generate` to obtain the parser.
43
+ If you want to use it via bindings, you'll also need to run `tree-sitter init`.
44
+
45
+ ### Origin
46
+
47
+ This project was forked from https://github.com/tree-sitter/tree-sitter-bash, to [ease the use of and collaboration on this grammar](https://codeberg.org/grammar-orchard#for-contributors).
48
+
49
+ [crates]: https://img.shields.io/crates/v/tree-sitter-bash-orchard?logo=rust
50
+ [pypi]: https://img.shields.io/pypi/v/tree-sitter-bash-orchard?logo=pypi&logoColor=ffd242
51
+ [npm]: https://img.shields.io/npm/v/tree-sitter-bash-orchard?logo=npm
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ bindings/python/tree_sitter_bash_orchard/__init__.py
6
+ bindings/python/tree_sitter_bash_orchard/__init__.pyi
7
+ bindings/python/tree_sitter_bash_orchard/binding.c
8
+ bindings/python/tree_sitter_bash_orchard/py.typed
9
+ bindings/python/tree_sitter_bash_orchard.egg-info/PKG-INFO
10
+ bindings/python/tree_sitter_bash_orchard.egg-info/SOURCES.txt
11
+ bindings/python/tree_sitter_bash_orchard.egg-info/dependency_links.txt
12
+ bindings/python/tree_sitter_bash_orchard.egg-info/not-zip-safe
13
+ bindings/python/tree_sitter_bash_orchard.egg-info/requires.txt
14
+ bindings/python/tree_sitter_bash_orchard.egg-info/top_level.txt
15
+ src/parser.c
@@ -0,0 +1,2 @@
1
+ _binding
2
+ tree_sitter_bash_orchard
@@ -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-bash-orchard"
7
+ description = "Parser for Bash files"
8
+ version = "0.1.0"
9
+ keywords = ["incremental", "parsing", "tree-sitter", "bash-orchard"]
10
+ classifiers = [
11
+ "Intended Audience :: Developers",
12
+ "Topic :: Software Development :: Compilers",
13
+ "Topic :: Text Processing :: Linguistic",
14
+ "Typing :: Typed",
15
+ ]
16
+ authors = [{ name = "Max Brunsfeld", email = "maxbrunsfeld@gmail.com" }]
17
+ requires-python = ">=3.10"
18
+ license.text = "MIT"
19
+ readme = "README.md"
20
+
21
+ [project.urls]
22
+ Homepage = "https://codeberg.org/grammar-orchard/tree-sitter-bash-orchard"
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,56 @@
1
+ [
2
+ (string)
3
+ (raw_string)
4
+ (heredoc_body)
5
+ (heredoc_start)
6
+ ] @string
7
+
8
+ (command_name) @function
9
+
10
+ (variable_name) @property
11
+
12
+ [
13
+ "case"
14
+ "do"
15
+ "done"
16
+ "elif"
17
+ "else"
18
+ "esac"
19
+ "export"
20
+ "fi"
21
+ "for"
22
+ "function"
23
+ "if"
24
+ "in"
25
+ "select"
26
+ "then"
27
+ "unset"
28
+ "until"
29
+ "while"
30
+ ] @keyword
31
+
32
+ (comment) @comment
33
+
34
+ (function_definition name: (word) @function)
35
+
36
+ (file_descriptor) @number
37
+
38
+ [
39
+ (command_substitution)
40
+ (process_substitution)
41
+ (expansion)
42
+ ]@embedded
43
+
44
+ [
45
+ "$"
46
+ "&&"
47
+ ">"
48
+ ">>"
49
+ "<"
50
+ "|"
51
+ ] @operator
52
+
53
+ (
54
+ (command (_) @constant)
55
+ (#match? @constant "^-")
56
+ )
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,78 @@
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_bash_orchard", "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
+ self.filelist.include("src/*.c")
46
+
47
+
48
+ setup(
49
+ packages=find_packages("bindings/python"),
50
+ package_dir={"": "bindings/python"},
51
+ package_data={
52
+ "tree_sitter_bash_orchard": ["*.pyi", "py.typed"],
53
+ "tree_sitter_bash_orchard.queries": ["*.scm"],
54
+ },
55
+ ext_package="tree_sitter_bash_orchard",
56
+ ext_modules=[
57
+ Extension(
58
+ name="_binding",
59
+ sources=[
60
+ "bindings/python/tree_sitter_bash_orchard/binding.c",
61
+ "src/parser.c",
62
+ ],
63
+ define_macros=[
64
+ ("PY_SSIZE_T_CLEAN", None),
65
+ ("TREE_SITTER_HIDE_SYMBOLS", None),
66
+ ],
67
+ include_dirs=["src"],
68
+ py_limited_api=not get_config_var("Py_GIL_DISABLED"),
69
+ )
70
+ ],
71
+ cmdclass={
72
+ "build": Build,
73
+ "build_ext": BuildExt,
74
+ "bdist_wheel": BdistWheel,
75
+ "egg_info": EggInfo,
76
+ },
77
+ zip_safe=False
78
+ )