tree-sitter-toolang 0.0.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.
- tree_sitter_toolang-0.0.5/LICENSE +21 -0
- tree_sitter_toolang-0.0.5/PKG-INFO +150 -0
- tree_sitter_toolang-0.0.5/README.md +119 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang/__init__.py +46 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang/__init__.pyi +9 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang/binding.c +39 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang/py.typed +1 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang.egg-info/PKG-INFO +150 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang.egg-info/SOURCES.txt +17 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang.egg-info/dependency_links.txt +1 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang.egg-info/not-zip-safe +1 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang.egg-info/requires.txt +7 -0
- tree_sitter_toolang-0.0.5/bindings/python/tree_sitter_toolang.egg-info/top_level.txt +2 -0
- tree_sitter_toolang-0.0.5/pyproject.toml +45 -0
- tree_sitter_toolang-0.0.5/queries/highlights.scm +65 -0
- tree_sitter_toolang-0.0.5/queries/indents.scm +5 -0
- tree_sitter_toolang-0.0.5/queries/injections.scm +23 -0
- tree_sitter_toolang-0.0.5/queries/outline.scm +10 -0
- tree_sitter_toolang-0.0.5/queries/tags.scm +7 -0
- tree_sitter_toolang-0.0.5/setup.cfg +4 -0
- tree_sitter_toolang-0.0.5/setup.py +89 -0
- tree_sitter_toolang-0.0.5/src/parser.c +3253 -0
- tree_sitter_toolang-0.0.5/src/tree_sitter/alloc.h +54 -0
- tree_sitter_toolang-0.0.5/src/tree_sitter/array.h +291 -0
- tree_sitter_toolang-0.0.5/src/tree_sitter/parser.h +266 -0
- tree_sitter_toolang-0.0.5/tests/fixtures/cli.too +7 -0
- tree_sitter_toolang-0.0.5/tests/fixtures/smoke.too +4 -0
- tree_sitter_toolang-0.0.5/tests/test_binding.py +41 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brice Yan
|
|
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,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-toolang
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: Toolang grammar for tree-sitter
|
|
5
|
+
Author: Brice Yan
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/openhat-ai/tree-sitter-toolang
|
|
8
|
+
Project-URL: Repository, https://github.com/openhat-ai/tree-sitter-toolang
|
|
9
|
+
Project-URL: Issues, https://github.com/openhat-ai/tree-sitter-toolang/issues
|
|
10
|
+
Keywords: incremental,parsing,toolang,tree-sitter
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: C
|
|
19
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
20
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: core
|
|
26
|
+
Requires-Dist: tree-sitter~=0.25; extra == "core"
|
|
27
|
+
Provides-Extra: tests
|
|
28
|
+
Requires-Dist: pytest>=8; extra == "tests"
|
|
29
|
+
Requires-Dist: tree-sitter~=0.25; extra == "tests"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# tree-sitter-toolang
|
|
33
|
+
|
|
34
|
+
Tree-sitter grammar for Toolang.
|
|
35
|
+
|
|
36
|
+
This repository publishes:
|
|
37
|
+
|
|
38
|
+
- the npm grammar package `tree-sitter-toolang`
|
|
39
|
+
- the Python extension package `tree-sitter-toolang`
|
|
40
|
+
- the Rust crate `tree-sitter-toolang`
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
### Python
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m pip install tree-sitter-toolang tree-sitter
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import tree_sitter_toolang
|
|
52
|
+
from tree_sitter import Language, Parser
|
|
53
|
+
|
|
54
|
+
language = Language(tree_sitter_toolang.language())
|
|
55
|
+
parser = Parser(language)
|
|
56
|
+
tree = parser.parse(b"use skill a/b\n")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The Python package also exposes packaged query strings:
|
|
60
|
+
`HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`, `INDENTS_QUERY`, `OUTLINE_QUERY`, and
|
|
61
|
+
`TAGS_QUERY`.
|
|
62
|
+
|
|
63
|
+
### Tree-sitter CLI
|
|
64
|
+
|
|
65
|
+
Install `tree-sitter-toolang` or clone this repository, then make sure the
|
|
66
|
+
directory that contains `tree-sitter-toolang` is listed in your Tree-sitter
|
|
67
|
+
`parser-directories`.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
tree-sitter init-config
|
|
71
|
+
tree-sitter dump-languages
|
|
72
|
+
tree-sitter parse path/to/file.too
|
|
73
|
+
tree-sitter highlight path/to/file.too
|
|
74
|
+
tree-sitter tags path/to/file.too
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Installing the npm package alone does not make `tree-sitter dump-languages`
|
|
78
|
+
discover Toolang automatically. The package must still live under one of the
|
|
79
|
+
configured `parser-directories`, or the grammar path must be provided
|
|
80
|
+
explicitly.
|
|
81
|
+
|
|
82
|
+
### Rust
|
|
83
|
+
|
|
84
|
+
```toml
|
|
85
|
+
[dependencies]
|
|
86
|
+
tree-sitter = "0.25"
|
|
87
|
+
tree-sitter-toolang = "0.0.5"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```rust
|
|
91
|
+
let language = tree_sitter::Language::new(tree_sitter_toolang::LANGUAGE);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
Edit:
|
|
97
|
+
|
|
98
|
+
- `grammar.js`
|
|
99
|
+
- `queries/*.scm`
|
|
100
|
+
- `test/corpus/*.txt`
|
|
101
|
+
|
|
102
|
+
Regenerate and test:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm install
|
|
106
|
+
npm run generate
|
|
107
|
+
npm test
|
|
108
|
+
npm run test:cli
|
|
109
|
+
npm run build:wasm
|
|
110
|
+
cargo test
|
|
111
|
+
python -m pip install -e .[tests]
|
|
112
|
+
pytest tests
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Publishing
|
|
116
|
+
|
|
117
|
+
Trusted publishers are configured in GitHub Actions with
|
|
118
|
+
[release.yml](.github/workflows/release.yml).
|
|
119
|
+
|
|
120
|
+
Verify the npm package locally:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm publish --dry-run
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Verify the Python distributions locally:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python -m pip install --upgrade pip build twine
|
|
130
|
+
python -m build
|
|
131
|
+
python -m twine check dist/*
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Verify the Rust crate:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
cargo publish --dry-run
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Release checklist:
|
|
141
|
+
|
|
142
|
+
1. Bump the version in `package.json`, `pyproject.toml`, and `Cargo.toml`.
|
|
143
|
+
2. Confirm CI is green.
|
|
144
|
+
3. Push the version commit to `main`.
|
|
145
|
+
4. Create and push a matching tag such as `v0.0.6`.
|
|
146
|
+
5. GitHub Actions publishes npm and PyPI automatically.
|
|
147
|
+
6. Optionally publish the Rust crate to crates.io.
|
|
148
|
+
|
|
149
|
+
The release workflow skips npm or PyPI if that version already exists on the
|
|
150
|
+
registry. The git tag must match the package version.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# tree-sitter-toolang
|
|
2
|
+
|
|
3
|
+
Tree-sitter grammar for Toolang.
|
|
4
|
+
|
|
5
|
+
This repository publishes:
|
|
6
|
+
|
|
7
|
+
- the npm grammar package `tree-sitter-toolang`
|
|
8
|
+
- the Python extension package `tree-sitter-toolang`
|
|
9
|
+
- the Rust crate `tree-sitter-toolang`
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
### Python
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python -m pip install tree-sitter-toolang tree-sitter
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import tree_sitter_toolang
|
|
21
|
+
from tree_sitter import Language, Parser
|
|
22
|
+
|
|
23
|
+
language = Language(tree_sitter_toolang.language())
|
|
24
|
+
parser = Parser(language)
|
|
25
|
+
tree = parser.parse(b"use skill a/b\n")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The Python package also exposes packaged query strings:
|
|
29
|
+
`HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`, `INDENTS_QUERY`, `OUTLINE_QUERY`, and
|
|
30
|
+
`TAGS_QUERY`.
|
|
31
|
+
|
|
32
|
+
### Tree-sitter CLI
|
|
33
|
+
|
|
34
|
+
Install `tree-sitter-toolang` or clone this repository, then make sure the
|
|
35
|
+
directory that contains `tree-sitter-toolang` is listed in your Tree-sitter
|
|
36
|
+
`parser-directories`.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
tree-sitter init-config
|
|
40
|
+
tree-sitter dump-languages
|
|
41
|
+
tree-sitter parse path/to/file.too
|
|
42
|
+
tree-sitter highlight path/to/file.too
|
|
43
|
+
tree-sitter tags path/to/file.too
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Installing the npm package alone does not make `tree-sitter dump-languages`
|
|
47
|
+
discover Toolang automatically. The package must still live under one of the
|
|
48
|
+
configured `parser-directories`, or the grammar path must be provided
|
|
49
|
+
explicitly.
|
|
50
|
+
|
|
51
|
+
### Rust
|
|
52
|
+
|
|
53
|
+
```toml
|
|
54
|
+
[dependencies]
|
|
55
|
+
tree-sitter = "0.25"
|
|
56
|
+
tree-sitter-toolang = "0.0.5"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```rust
|
|
60
|
+
let language = tree_sitter::Language::new(tree_sitter_toolang::LANGUAGE);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
Edit:
|
|
66
|
+
|
|
67
|
+
- `grammar.js`
|
|
68
|
+
- `queries/*.scm`
|
|
69
|
+
- `test/corpus/*.txt`
|
|
70
|
+
|
|
71
|
+
Regenerate and test:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install
|
|
75
|
+
npm run generate
|
|
76
|
+
npm test
|
|
77
|
+
npm run test:cli
|
|
78
|
+
npm run build:wasm
|
|
79
|
+
cargo test
|
|
80
|
+
python -m pip install -e .[tests]
|
|
81
|
+
pytest tests
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Publishing
|
|
85
|
+
|
|
86
|
+
Trusted publishers are configured in GitHub Actions with
|
|
87
|
+
[release.yml](.github/workflows/release.yml).
|
|
88
|
+
|
|
89
|
+
Verify the npm package locally:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm publish --dry-run
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Verify the Python distributions locally:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python -m pip install --upgrade pip build twine
|
|
99
|
+
python -m build
|
|
100
|
+
python -m twine check dist/*
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Verify the Rust crate:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
cargo publish --dry-run
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Release checklist:
|
|
110
|
+
|
|
111
|
+
1. Bump the version in `package.json`, `pyproject.toml`, and `Cargo.toml`.
|
|
112
|
+
2. Confirm CI is green.
|
|
113
|
+
3. Push the version commit to `main`.
|
|
114
|
+
4. Create and push a matching tag such as `v0.0.6`.
|
|
115
|
+
5. GitHub Actions publishes npm and PyPI automatically.
|
|
116
|
+
6. Optionally publish the Rust crate to crates.io.
|
|
117
|
+
|
|
118
|
+
The release workflow skips npm or PyPI if that version already exists on the
|
|
119
|
+
registry. The git tag must match the package version.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Toolang grammar for tree-sitter."""
|
|
2
|
+
|
|
3
|
+
from importlib.resources import files as _files
|
|
4
|
+
|
|
5
|
+
from ._binding import language
|
|
6
|
+
|
|
7
|
+
_QUERY_FILES = {
|
|
8
|
+
"HIGHLIGHTS_QUERY": "highlights.scm",
|
|
9
|
+
"INJECTIONS_QUERY": "injections.scm",
|
|
10
|
+
"INDENTS_QUERY": "indents.scm",
|
|
11
|
+
"OUTLINE_QUERY": "outline.scm",
|
|
12
|
+
"TAGS_QUERY": "tags.scm",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
__all__ = ["language", *_QUERY_FILES]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _get_query(name: str) -> str:
|
|
19
|
+
query = _files(f"{__package__}.queries") / _QUERY_FILES[name]
|
|
20
|
+
contents = query.read_text()
|
|
21
|
+
globals()[name] = contents
|
|
22
|
+
return contents
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def __getattr__(name: str) -> str:
|
|
26
|
+
if name in _QUERY_FILES:
|
|
27
|
+
return _get_query(name)
|
|
28
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def __dir__() -> list[str]:
|
|
32
|
+
return sorted(
|
|
33
|
+
__all__
|
|
34
|
+
+ [
|
|
35
|
+
"__all__",
|
|
36
|
+
"__builtins__",
|
|
37
|
+
"__cached__",
|
|
38
|
+
"__doc__",
|
|
39
|
+
"__file__",
|
|
40
|
+
"__loader__",
|
|
41
|
+
"__name__",
|
|
42
|
+
"__package__",
|
|
43
|
+
"__path__",
|
|
44
|
+
"__spec__",
|
|
45
|
+
]
|
|
46
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_toolang(void);
|
|
6
|
+
|
|
7
|
+
static PyObject *binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_toolang(), "tree_sitter.Language", NULL);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static PyMethodDef methods[] = {
|
|
12
|
+
{
|
|
13
|
+
"language",
|
|
14
|
+
binding_language,
|
|
15
|
+
METH_NOARGS,
|
|
16
|
+
"Get the tree-sitter language for this grammar.",
|
|
17
|
+
},
|
|
18
|
+
{NULL, NULL, 0, NULL},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
static struct PyModuleDef_Slot slots[] = {
|
|
22
|
+
#ifdef Py_GIL_DISABLED
|
|
23
|
+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
|
24
|
+
#endif
|
|
25
|
+
{0, NULL},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static struct PyModuleDef module = {
|
|
29
|
+
.m_base = PyModuleDef_HEAD_INIT,
|
|
30
|
+
.m_name = "_binding",
|
|
31
|
+
.m_doc = NULL,
|
|
32
|
+
.m_size = 0,
|
|
33
|
+
.m_methods = methods,
|
|
34
|
+
.m_slots = slots,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
PyMODINIT_FUNC PyInit__binding(void) {
|
|
38
|
+
return PyModuleDef_Init(&module);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-toolang
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: Toolang grammar for tree-sitter
|
|
5
|
+
Author: Brice Yan
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/openhat-ai/tree-sitter-toolang
|
|
8
|
+
Project-URL: Repository, https://github.com/openhat-ai/tree-sitter-toolang
|
|
9
|
+
Project-URL: Issues, https://github.com/openhat-ai/tree-sitter-toolang/issues
|
|
10
|
+
Keywords: incremental,parsing,toolang,tree-sitter
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: C
|
|
19
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
20
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: core
|
|
26
|
+
Requires-Dist: tree-sitter~=0.25; extra == "core"
|
|
27
|
+
Provides-Extra: tests
|
|
28
|
+
Requires-Dist: pytest>=8; extra == "tests"
|
|
29
|
+
Requires-Dist: tree-sitter~=0.25; extra == "tests"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# tree-sitter-toolang
|
|
33
|
+
|
|
34
|
+
Tree-sitter grammar for Toolang.
|
|
35
|
+
|
|
36
|
+
This repository publishes:
|
|
37
|
+
|
|
38
|
+
- the npm grammar package `tree-sitter-toolang`
|
|
39
|
+
- the Python extension package `tree-sitter-toolang`
|
|
40
|
+
- the Rust crate `tree-sitter-toolang`
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
### Python
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m pip install tree-sitter-toolang tree-sitter
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import tree_sitter_toolang
|
|
52
|
+
from tree_sitter import Language, Parser
|
|
53
|
+
|
|
54
|
+
language = Language(tree_sitter_toolang.language())
|
|
55
|
+
parser = Parser(language)
|
|
56
|
+
tree = parser.parse(b"use skill a/b\n")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The Python package also exposes packaged query strings:
|
|
60
|
+
`HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`, `INDENTS_QUERY`, `OUTLINE_QUERY`, and
|
|
61
|
+
`TAGS_QUERY`.
|
|
62
|
+
|
|
63
|
+
### Tree-sitter CLI
|
|
64
|
+
|
|
65
|
+
Install `tree-sitter-toolang` or clone this repository, then make sure the
|
|
66
|
+
directory that contains `tree-sitter-toolang` is listed in your Tree-sitter
|
|
67
|
+
`parser-directories`.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
tree-sitter init-config
|
|
71
|
+
tree-sitter dump-languages
|
|
72
|
+
tree-sitter parse path/to/file.too
|
|
73
|
+
tree-sitter highlight path/to/file.too
|
|
74
|
+
tree-sitter tags path/to/file.too
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Installing the npm package alone does not make `tree-sitter dump-languages`
|
|
78
|
+
discover Toolang automatically. The package must still live under one of the
|
|
79
|
+
configured `parser-directories`, or the grammar path must be provided
|
|
80
|
+
explicitly.
|
|
81
|
+
|
|
82
|
+
### Rust
|
|
83
|
+
|
|
84
|
+
```toml
|
|
85
|
+
[dependencies]
|
|
86
|
+
tree-sitter = "0.25"
|
|
87
|
+
tree-sitter-toolang = "0.0.5"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```rust
|
|
91
|
+
let language = tree_sitter::Language::new(tree_sitter_toolang::LANGUAGE);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
Edit:
|
|
97
|
+
|
|
98
|
+
- `grammar.js`
|
|
99
|
+
- `queries/*.scm`
|
|
100
|
+
- `test/corpus/*.txt`
|
|
101
|
+
|
|
102
|
+
Regenerate and test:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm install
|
|
106
|
+
npm run generate
|
|
107
|
+
npm test
|
|
108
|
+
npm run test:cli
|
|
109
|
+
npm run build:wasm
|
|
110
|
+
cargo test
|
|
111
|
+
python -m pip install -e .[tests]
|
|
112
|
+
pytest tests
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Publishing
|
|
116
|
+
|
|
117
|
+
Trusted publishers are configured in GitHub Actions with
|
|
118
|
+
[release.yml](.github/workflows/release.yml).
|
|
119
|
+
|
|
120
|
+
Verify the npm package locally:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm publish --dry-run
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Verify the Python distributions locally:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python -m pip install --upgrade pip build twine
|
|
130
|
+
python -m build
|
|
131
|
+
python -m twine check dist/*
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Verify the Rust crate:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
cargo publish --dry-run
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Release checklist:
|
|
141
|
+
|
|
142
|
+
1. Bump the version in `package.json`, `pyproject.toml`, and `Cargo.toml`.
|
|
143
|
+
2. Confirm CI is green.
|
|
144
|
+
3. Push the version commit to `main`.
|
|
145
|
+
4. Create and push a matching tag such as `v0.0.6`.
|
|
146
|
+
5. GitHub Actions publishes npm and PyPI automatically.
|
|
147
|
+
6. Optionally publish the Rust crate to crates.io.
|
|
148
|
+
|
|
149
|
+
The release workflow skips npm or PyPI if that version already exists on the
|
|
150
|
+
registry. The git tag must match the package version.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.cfg
|
|
5
|
+
setup.py
|
|
6
|
+
bindings/python/tree_sitter_toolang/__init__.py
|
|
7
|
+
bindings/python/tree_sitter_toolang/__init__.pyi
|
|
8
|
+
bindings/python/tree_sitter_toolang/binding.c
|
|
9
|
+
bindings/python/tree_sitter_toolang/py.typed
|
|
10
|
+
bindings/python/tree_sitter_toolang.egg-info/PKG-INFO
|
|
11
|
+
bindings/python/tree_sitter_toolang.egg-info/SOURCES.txt
|
|
12
|
+
bindings/python/tree_sitter_toolang.egg-info/dependency_links.txt
|
|
13
|
+
bindings/python/tree_sitter_toolang.egg-info/not-zip-safe
|
|
14
|
+
bindings/python/tree_sitter_toolang.egg-info/requires.txt
|
|
15
|
+
bindings/python/tree_sitter_toolang.egg-info/top_level.txt
|
|
16
|
+
src/parser.c
|
|
17
|
+
tests/test_binding.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=62.4.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tree-sitter-toolang"
|
|
7
|
+
version = "0.0.5"
|
|
8
|
+
description = "Toolang grammar for tree-sitter"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
keywords = ["incremental", "parsing", "toolang", "tree-sitter"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: C",
|
|
23
|
+
"Topic :: Software Development :: Compilers",
|
|
24
|
+
"Topic :: Text Processing :: Linguistic",
|
|
25
|
+
"Typing :: Typed",
|
|
26
|
+
]
|
|
27
|
+
authors = [
|
|
28
|
+
{ name = "Brice Yan" },
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/openhat-ai/tree-sitter-toolang"
|
|
33
|
+
Repository = "https://github.com/openhat-ai/tree-sitter-toolang"
|
|
34
|
+
Issues = "https://github.com/openhat-ai/tree-sitter-toolang/issues"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
core = ["tree-sitter~=0.25"]
|
|
38
|
+
tests = ["pytest>=8", "tree-sitter~=0.25"]
|
|
39
|
+
|
|
40
|
+
[tool.cibuildwheel]
|
|
41
|
+
build = "cp310-*"
|
|
42
|
+
archs = ["auto64"]
|
|
43
|
+
build-frontend = "build"
|
|
44
|
+
test-requires = ["pytest>=8", "tree-sitter~=0.25"]
|
|
45
|
+
test-command = "pytest {project}/tests"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
; Source of truth for Toolang Tree-sitter highlight captures.
|
|
2
|
+
; Maintain this file in this repository and consume it from tooling.
|
|
3
|
+
|
|
4
|
+
(comment) @comment
|
|
5
|
+
(inline_comment) @comment
|
|
6
|
+
|
|
7
|
+
(use_keyword) @keyword
|
|
8
|
+
(thunk_keyword) @keyword
|
|
9
|
+
(decl_kind) @keyword
|
|
10
|
+
|
|
11
|
+
(cap_kind) @type
|
|
12
|
+
(collection_subject) @property
|
|
13
|
+
(model_subject) @property
|
|
14
|
+
(language) @property
|
|
15
|
+
|
|
16
|
+
(assign_operator) @keyword
|
|
17
|
+
(remove_operator) @operator
|
|
18
|
+
(arrow) @operator
|
|
19
|
+
|
|
20
|
+
(colon) @punctuation.delimiter
|
|
21
|
+
(comma) @punctuation.delimiter
|
|
22
|
+
(lparen) @punctuation.delimiter
|
|
23
|
+
(rparen) @punctuation.delimiter
|
|
24
|
+
(question) @punctuation.special
|
|
25
|
+
(fence_open) @punctuation.special
|
|
26
|
+
(fence_close) @punctuation.special
|
|
27
|
+
|
|
28
|
+
(reference) @constant
|
|
29
|
+
(prompt_text) @string
|
|
30
|
+
(fence_text) @string
|
|
31
|
+
|
|
32
|
+
(collection_directive
|
|
33
|
+
operator: (assign_operator)
|
|
34
|
+
values: (directive_values
|
|
35
|
+
(directive_value) @constant))
|
|
36
|
+
|
|
37
|
+
(collection_directive
|
|
38
|
+
operator: (remove_operator)
|
|
39
|
+
values: (directive_values
|
|
40
|
+
(directive_value) @string.special))
|
|
41
|
+
|
|
42
|
+
(model_directive
|
|
43
|
+
values: (directive_values
|
|
44
|
+
(directive_value) @type))
|
|
45
|
+
|
|
46
|
+
(declaration_header
|
|
47
|
+
name: (identifier) @type)
|
|
48
|
+
|
|
49
|
+
(declaration_header
|
|
50
|
+
language: (language) @property)
|
|
51
|
+
|
|
52
|
+
(parameter
|
|
53
|
+
name: (identifier) @property)
|
|
54
|
+
|
|
55
|
+
(thunk_header
|
|
56
|
+
name: (identifier) @function)
|
|
57
|
+
|
|
58
|
+
(thunk_header
|
|
59
|
+
output: (identifier) @type)
|
|
60
|
+
|
|
61
|
+
(thunk_input
|
|
62
|
+
value: (identifier) @variable)
|
|
63
|
+
|
|
64
|
+
(use_statement
|
|
65
|
+
reference: (reference) @constant)
|