pharo-tree-sitter 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,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Pharo-LLM
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,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: pharo-tree-sitter
3
+ Version: 0.1.0
4
+ Summary: Pharo grammar for tree-sitter
5
+ Author-email: Kilian Kier <kierkilian@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/kilian-kier/tree-sitter-pharo
8
+ Keywords: incremental,parsing,tree-sitter,pharo
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
+ Requires-Dist: tree-sitter~=0.24
17
+ Provides-Extra: core
18
+ Dynamic: license-file
19
+
20
+ # Tree-Sitter Grammar for Pharo Smalltalk
21
+
22
+ An adaptation of the [Tree-Sitter Smalltalk grammar](https://github.com/tom95/tree-sitter-smalltalk) for Pharo.
23
+ It also includes parsing whole files (in Tonel format).
24
+
25
+ ## Python Package
26
+
27
+ Install the package locally from this repository:
28
+
29
+ ```sh
30
+ python3 -m pip install .
31
+ ```
32
+
33
+ After the package is published to PyPI, install it with:
34
+
35
+ ```sh
36
+ python3 -m pip install pharo-tree-sitter
37
+ ```
38
+
39
+ Use it from Python with the `tree_sitter_pharo` import:
40
+
41
+ ```python
42
+ import tree_sitter
43
+ import tree_sitter_pharo
44
+
45
+ PHARO_LANGUAGE = tree_sitter.Language(tree_sitter_pharo.language())
46
+ print(tree_sitter_pharo.HIGHLIGHTS_QUERY)
47
+ ```
48
+
49
+ Build the source distribution and wheel:
50
+
51
+ ```sh
52
+ python3 -m pip install build twine
53
+ python3 -m build
54
+ ```
55
+
56
+ Upload the package to PyPI:
57
+
58
+ ```sh
59
+ python3 -m twine upload dist/*
60
+ ```
@@ -0,0 +1,41 @@
1
+ # Tree-Sitter Grammar for Pharo Smalltalk
2
+
3
+ An adaptation of the [Tree-Sitter Smalltalk grammar](https://github.com/tom95/tree-sitter-smalltalk) for Pharo.
4
+ It also includes parsing whole files (in Tonel format).
5
+
6
+ ## Python Package
7
+
8
+ Install the package locally from this repository:
9
+
10
+ ```sh
11
+ python3 -m pip install .
12
+ ```
13
+
14
+ After the package is published to PyPI, install it with:
15
+
16
+ ```sh
17
+ python3 -m pip install pharo-tree-sitter
18
+ ```
19
+
20
+ Use it from Python with the `tree_sitter_pharo` import:
21
+
22
+ ```python
23
+ import tree_sitter
24
+ import tree_sitter_pharo
25
+
26
+ PHARO_LANGUAGE = tree_sitter.Language(tree_sitter_pharo.language())
27
+ print(tree_sitter_pharo.HIGHLIGHTS_QUERY)
28
+ ```
29
+
30
+ Build the source distribution and wheel:
31
+
32
+ ```sh
33
+ python3 -m pip install build twine
34
+ python3 -m build
35
+ ```
36
+
37
+ Upload the package to PyPI:
38
+
39
+ ```sh
40
+ python3 -m twine upload dist/*
41
+ ```
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: pharo-tree-sitter
3
+ Version: 0.1.0
4
+ Summary: Pharo grammar for tree-sitter
5
+ Author-email: Kilian Kier <kierkilian@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/kilian-kier/tree-sitter-pharo
8
+ Keywords: incremental,parsing,tree-sitter,pharo
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
+ Requires-Dist: tree-sitter~=0.24
17
+ Provides-Extra: core
18
+ Dynamic: license-file
19
+
20
+ # Tree-Sitter Grammar for Pharo Smalltalk
21
+
22
+ An adaptation of the [Tree-Sitter Smalltalk grammar](https://github.com/tom95/tree-sitter-smalltalk) for Pharo.
23
+ It also includes parsing whole files (in Tonel format).
24
+
25
+ ## Python Package
26
+
27
+ Install the package locally from this repository:
28
+
29
+ ```sh
30
+ python3 -m pip install .
31
+ ```
32
+
33
+ After the package is published to PyPI, install it with:
34
+
35
+ ```sh
36
+ python3 -m pip install pharo-tree-sitter
37
+ ```
38
+
39
+ Use it from Python with the `tree_sitter_pharo` import:
40
+
41
+ ```python
42
+ import tree_sitter
43
+ import tree_sitter_pharo
44
+
45
+ PHARO_LANGUAGE = tree_sitter.Language(tree_sitter_pharo.language())
46
+ print(tree_sitter_pharo.HIGHLIGHTS_QUERY)
47
+ ```
48
+
49
+ Build the source distribution and wheel:
50
+
51
+ ```sh
52
+ python3 -m pip install build twine
53
+ python3 -m build
54
+ ```
55
+
56
+ Upload the package to PyPI:
57
+
58
+ ```sh
59
+ python3 -m twine upload dist/*
60
+ ```
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ bindings/python/pharo_tree_sitter.egg-info/PKG-INFO
6
+ bindings/python/pharo_tree_sitter.egg-info/SOURCES.txt
7
+ bindings/python/pharo_tree_sitter.egg-info/dependency_links.txt
8
+ bindings/python/pharo_tree_sitter.egg-info/not-zip-safe
9
+ bindings/python/pharo_tree_sitter.egg-info/requires.txt
10
+ bindings/python/pharo_tree_sitter.egg-info/top_level.txt
11
+ bindings/python/tree_sitter_pharo/__init__.py
12
+ bindings/python/tree_sitter_pharo/__init__.pyi
13
+ bindings/python/tree_sitter_pharo/binding.c
14
+ bindings/python/tree_sitter_pharo/py.typed
15
+ src/parser.c
16
+ src/scanner.c
@@ -0,0 +1,3 @@
1
+ tree-sitter~=0.24
2
+
3
+ [core]
@@ -0,0 +1,2 @@
1
+ _binding
2
+ tree_sitter_pharo
@@ -0,0 +1,43 @@
1
+ """Pharo grammar for tree-sitter"""
2
+
3
+ from importlib.resources import files as _files
4
+ from pathlib import Path as _Path
5
+
6
+ from ._binding import language
7
+
8
+
9
+ def _get_query(name, file):
10
+ query = _files(__package__) / "queries" / file
11
+ if not query.is_file():
12
+ query = _Path(__file__).resolve().parents[3] / "queries" / file
13
+ globals()[name] = query.read_text()
14
+ return globals()[name]
15
+
16
+
17
+ def __getattr__(name):
18
+ if name == "HIGHLIGHTS_QUERY":
19
+ return _get_query("HIGHLIGHTS_QUERY", "highlights.scm")
20
+ # if name == "INJECTIONS_QUERY":
21
+ # return _get_query("INJECTIONS_QUERY", "injections.scm")
22
+ # if name == "LOCALS_QUERY":
23
+ # return _get_query("LOCALS_QUERY", "locals.scm")
24
+ # if name == "TAGS_QUERY":
25
+ # return _get_query("TAGS_QUERY", "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,8 @@
1
+ from typing import Final
2
+
3
+ HIGHLIGHTS_QUERY: Final[str]
4
+ # INJECTIONS_QUERY: Final[str]
5
+ # LOCALS_QUERY: Final[str]
6
+ # TAGS_QUERY: Final[str]
7
+
8
+ def language() -> object: ...
@@ -0,0 +1,35 @@
1
+ #include <Python.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ TSLanguage *tree_sitter_pharo(void);
6
+
7
+ static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
8
+ return PyCapsule_New(tree_sitter_pharo(), "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,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pharo-tree-sitter"
7
+ description = "Pharo grammar for tree-sitter"
8
+ version = "0.1.0"
9
+ keywords = ["incremental", "parsing", "tree-sitter", "pharo"]
10
+ classifiers = [
11
+ "Intended Audience :: Developers",
12
+ "Topic :: Software Development :: Compilers",
13
+ "Topic :: Text Processing :: Linguistic",
14
+ "Typing :: Typed",
15
+ ]
16
+ authors = [{ name = "Kilian Kier", email = "kierkilian@gmail.com" }]
17
+ requires-python = ">=3.10"
18
+ license = "MIT"
19
+ license-files = ["LICENSE"]
20
+ readme = "README.md"
21
+ dependencies = ["tree-sitter~=0.24"]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/kilian-kier/tree-sitter-pharo"
25
+
26
+ [project.optional-dependencies]
27
+ core = []
28
+
29
+ [tool.cibuildwheel]
30
+ build = "cp310-*"
31
+ build-frontend = "build"
@@ -0,0 +1,34 @@
1
+ [(self) (true) (false) (thisContext) (super) (nil)] @keyword
2
+
3
+ (pragma) @annotation
4
+
5
+ (number) @number
6
+
7
+ (string) @string
8
+ (symbol) @string
9
+ (character) @string
10
+ (comment) @comment
11
+ (block "|" @punctuation)
12
+
13
+ (identifier) @variable
14
+ (block_argument) @variable
15
+
16
+ ";" @punctuation
17
+ "." @punctuation
18
+
19
+ (unary_message (_) (unary_identifier) @variable.part)
20
+ (binary_operator) @variable.part
21
+ (keyword) @variable.part
22
+
23
+ ["^" "[" "]" "{" "}"] @important
24
+
25
+ ["(" ")"] @punctuation
26
+
27
+ (keyword_selector (keyword) @major_declaration.part) @structure.part
28
+ (binary_selector (binary_operator) @major_declaration.part) @structure.part
29
+ (unary_selector (unary_identifier) @major_declaration.part) @structure.part
30
+
31
+ [(pragma_keyword_selector) (pragma_unary_selector)] @structure.part
32
+
33
+ (temporaries) @punctuation.part
34
+ (temporaries (identifier) @punctuation)
@@ -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.bdist_wheel import bdist_wheel
7
+ from setuptools.command.build import build
8
+ from setuptools.command.egg_info import egg_info
9
+
10
+ sources = [
11
+ "bindings/python/tree_sitter_pharo/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_pharo", "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_pharo": ["*.pyi", "py.typed"],
58
+ "tree_sitter_pharo.queries": ["*.scm"],
59
+ },
60
+ ext_package="tree_sitter_pharo",
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
+ )