tree-sitter-gram 0.1.8__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_gram-0.1.8/LICENSE +21 -0
- tree_sitter_gram-0.1.8/PKG-INFO +45 -0
- tree_sitter_gram-0.1.8/README.md +27 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram/__init__.py +42 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram/__init__.pyi +10 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram/binding.c +27 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram/py.typed +0 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram.egg-info/PKG-INFO +45 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram.egg-info/SOURCES.txt +15 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram.egg-info/dependency_links.txt +1 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram.egg-info/not-zip-safe +1 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram.egg-info/requires.txt +3 -0
- tree_sitter_gram-0.1.8/bindings/python/tree_sitter_gram.egg-info/top_level.txt +2 -0
- tree_sitter_gram-0.1.8/pyproject.toml +29 -0
- tree_sitter_gram-0.1.8/setup.cfg +4 -0
- tree_sitter_gram-0.1.8/setup.py +62 -0
- tree_sitter_gram-0.1.8/src/parser.c +3735 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Andreas Kollegger
|
|
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,45 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: tree-sitter-gram
|
|
3
|
+
Version: 0.1.8
|
|
4
|
+
Summary: Gram grammar for tree-sitter
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/tree-sitter/tree-sitter-gram
|
|
7
|
+
Keywords: incremental,parsing,tree-sitter,gram
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
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.22; extra == "core"
|
|
18
|
+
|
|
19
|
+
# tree-sitter-gram
|
|
20
|
+
|
|
21
|
+
A [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar
|
|
22
|
+
for [gram](https://gram-data.github.io) notation.
|
|
23
|
+
|
|
24
|
+
Gram is a subject-based notation for structured data.
|
|
25
|
+
|
|
26
|
+
If this is an object:
|
|
27
|
+
```
|
|
28
|
+
{
|
|
29
|
+
"name":"Andreas",
|
|
30
|
+
"roles":["author"]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Implicitly the object is a person. To become a subject, the implicit
|
|
35
|
+
information can be explicit.
|
|
36
|
+
|
|
37
|
+
As a subject:
|
|
38
|
+
```
|
|
39
|
+
(:Person {
|
|
40
|
+
name: "Andreas",
|
|
41
|
+
roles: ["author"]
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Learn more about `gram` at the [gram-data github org](https://github.com/gram-data) notation.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# tree-sitter-gram
|
|
2
|
+
|
|
3
|
+
A [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar
|
|
4
|
+
for [gram](https://gram-data.github.io) notation.
|
|
5
|
+
|
|
6
|
+
Gram is a subject-based notation for structured data.
|
|
7
|
+
|
|
8
|
+
If this is an object:
|
|
9
|
+
```
|
|
10
|
+
{
|
|
11
|
+
"name":"Andreas",
|
|
12
|
+
"roles":["author"]
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Implicitly the object is a person. To become a subject, the implicit
|
|
17
|
+
information can be explicit.
|
|
18
|
+
|
|
19
|
+
As a subject:
|
|
20
|
+
```
|
|
21
|
+
(:Person {
|
|
22
|
+
name: "Andreas",
|
|
23
|
+
roles: ["author"]
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Learn more about `gram` at the [gram-data github org](https://github.com/gram-data) notation.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Gram grammar for tree-sitter"""
|
|
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,27 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_gram(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_gram(), "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
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: tree-sitter-gram
|
|
3
|
+
Version: 0.1.8
|
|
4
|
+
Summary: Gram grammar for tree-sitter
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/tree-sitter/tree-sitter-gram
|
|
7
|
+
Keywords: incremental,parsing,tree-sitter,gram
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
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.22; extra == "core"
|
|
18
|
+
|
|
19
|
+
# tree-sitter-gram
|
|
20
|
+
|
|
21
|
+
A [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar
|
|
22
|
+
for [gram](https://gram-data.github.io) notation.
|
|
23
|
+
|
|
24
|
+
Gram is a subject-based notation for structured data.
|
|
25
|
+
|
|
26
|
+
If this is an object:
|
|
27
|
+
```
|
|
28
|
+
{
|
|
29
|
+
"name":"Andreas",
|
|
30
|
+
"roles":["author"]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Implicitly the object is a person. To become a subject, the implicit
|
|
35
|
+
information can be explicit.
|
|
36
|
+
|
|
37
|
+
As a subject:
|
|
38
|
+
```
|
|
39
|
+
(:Person {
|
|
40
|
+
name: "Andreas",
|
|
41
|
+
roles: ["author"]
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Learn more about `gram` at the [gram-data github org](https://github.com/gram-data) notation.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
bindings/python/tree_sitter_gram/__init__.py
|
|
6
|
+
bindings/python/tree_sitter_gram/__init__.pyi
|
|
7
|
+
bindings/python/tree_sitter_gram/binding.c
|
|
8
|
+
bindings/python/tree_sitter_gram/py.typed
|
|
9
|
+
bindings/python/tree_sitter_gram.egg-info/PKG-INFO
|
|
10
|
+
bindings/python/tree_sitter_gram.egg-info/SOURCES.txt
|
|
11
|
+
bindings/python/tree_sitter_gram.egg-info/dependency_links.txt
|
|
12
|
+
bindings/python/tree_sitter_gram.egg-info/not-zip-safe
|
|
13
|
+
bindings/python/tree_sitter_gram.egg-info/requires.txt
|
|
14
|
+
bindings/python/tree_sitter_gram.egg-info/top_level.txt
|
|
15
|
+
src/parser.c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tree-sitter-gram"
|
|
7
|
+
description = "Gram grammar for tree-sitter"
|
|
8
|
+
version = "0.1.8"
|
|
9
|
+
keywords = ["incremental", "parsing", "tree-sitter", "gram"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Topic :: Software Development :: Compilers",
|
|
14
|
+
"Topic :: Text Processing :: Linguistic",
|
|
15
|
+
"Typing :: Typed"
|
|
16
|
+
]
|
|
17
|
+
requires-python = ">=3.9"
|
|
18
|
+
license.text = "MIT"
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/tree-sitter/tree-sitter-gram"
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
core = ["tree-sitter~=0.22"]
|
|
26
|
+
|
|
27
|
+
[tool.cibuildwheel]
|
|
28
|
+
build = "cp39-*"
|
|
29
|
+
build-frontend = "build"
|
|
@@ -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_gram", "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_gram": ["*.pyi", "py.typed"],
|
|
30
|
+
"tree_sitter_gram.queries": ["*.scm"],
|
|
31
|
+
},
|
|
32
|
+
ext_package="tree_sitter_gram",
|
|
33
|
+
ext_modules=[
|
|
34
|
+
Extension(
|
|
35
|
+
name="_binding",
|
|
36
|
+
sources=[
|
|
37
|
+
"bindings/python/tree_sitter_gram/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
|
+
)
|