tree-sitter-bloblang 0.2.1__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_bloblang-0.2.1/LICENSE +21 -0
- tree_sitter_bloblang-0.2.1/PKG-INFO +79 -0
- tree_sitter_bloblang-0.2.1/README.md +60 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang/__init__.py +42 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang/__init__.pyi +10 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang/binding.c +35 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang/py.typed +0 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang.egg-info/PKG-INFO +79 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang.egg-info/SOURCES.txt +15 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang.egg-info/dependency_links.txt +1 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang.egg-info/not-zip-safe +1 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang.egg-info/requires.txt +3 -0
- tree_sitter_bloblang-0.2.1/bindings/python/tree_sitter_bloblang.egg-info/top_level.txt +2 -0
- tree_sitter_bloblang-0.2.1/pyproject.toml +29 -0
- tree_sitter_bloblang-0.2.1/queries/highlights.scm +110 -0
- tree_sitter_bloblang-0.2.1/queries/locals.scm +15 -0
- tree_sitter_bloblang-0.2.1/setup.cfg +4 -0
- tree_sitter_bloblang-0.2.1/setup.py +77 -0
- tree_sitter_bloblang-0.2.1/src/parser.c +12331 -0
- tree_sitter_bloblang-0.2.1/src/tree_sitter/alloc.h +54 -0
- tree_sitter_bloblang-0.2.1/src/tree_sitter/array.h +336 -0
- tree_sitter_bloblang-0.2.1/src/tree_sitter/parser.h +286 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Henrik Christensen
|
|
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,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-bloblang
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: parser for bento bloblang
|
|
5
|
+
Author-email: Henrik Christensen <henrik@hsctech.eu>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://codeberg.org/hsctech/blobl_sitter
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,bloblang
|
|
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 Grammar for Bento Bloblang
|
|
21
|
+
|
|
22
|
+
This project aims to create a Tree-sitter grammar for Bento Bloblang, a powerful data transformation language used in the Bento ecosystem.
|
|
23
|
+
|
|
24
|
+
## About Bloblang
|
|
25
|
+
|
|
26
|
+
Bloblang is a declarative mapping language designed for transforming data structures. It's used in Bento for processing and manipulating data in pipelines.
|
|
27
|
+
|
|
28
|
+
## Project Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
.
|
|
32
|
+
├── grammar.js # Tree-sitter grammar definition
|
|
33
|
+
├── bindings/ # Language bindings (Node.js, etc.)
|
|
34
|
+
├── queries/ # Syntax highlighting queries
|
|
35
|
+
├── src/ # Supporting code
|
|
36
|
+
└── tests/ # Test cases
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Getting Started
|
|
40
|
+
|
|
41
|
+
### Prerequisites
|
|
42
|
+
|
|
43
|
+
- Node.js (for building and testing)
|
|
44
|
+
- Tree-sitter CLI
|
|
45
|
+
|
|
46
|
+
### Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Building
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Testing
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm test
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Grammar Development
|
|
65
|
+
|
|
66
|
+
The grammar is defined in `grammar.js` using Tree-sitter's JavaScript DSL. Key components include:
|
|
67
|
+
|
|
68
|
+
- Lexical rules (tokens, keywords, operators)
|
|
69
|
+
- Syntax rules (expressions, statements, mappings)
|
|
70
|
+
- Error recovery patterns
|
|
71
|
+
|
|
72
|
+
## Resources
|
|
73
|
+
|
|
74
|
+
- [Bento Bloblang Documentation](https://github.com/warpstreamlabs/bento/tree/main/website/docs/guides/bloblang)
|
|
75
|
+
- [Tree-sitter Documentation](https://tree-sitter.github.io/tree-sitter/)
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
|
|
79
|
+
Contributions are welcome! Please open issues for bugs or feature requests, and submit pull requests for improvements.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Tree-sitter Grammar for Bento Bloblang
|
|
2
|
+
|
|
3
|
+
This project aims to create a Tree-sitter grammar for Bento Bloblang, a powerful data transformation language used in the Bento ecosystem.
|
|
4
|
+
|
|
5
|
+
## About Bloblang
|
|
6
|
+
|
|
7
|
+
Bloblang is a declarative mapping language designed for transforming data structures. It's used in Bento for processing and manipulating data in pipelines.
|
|
8
|
+
|
|
9
|
+
## Project Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
.
|
|
13
|
+
├── grammar.js # Tree-sitter grammar definition
|
|
14
|
+
├── bindings/ # Language bindings (Node.js, etc.)
|
|
15
|
+
├── queries/ # Syntax highlighting queries
|
|
16
|
+
├── src/ # Supporting code
|
|
17
|
+
└── tests/ # Test cases
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
|
|
24
|
+
- Node.js (for building and testing)
|
|
25
|
+
- Tree-sitter CLI
|
|
26
|
+
|
|
27
|
+
### Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Building
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Testing
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm test
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Grammar Development
|
|
46
|
+
|
|
47
|
+
The grammar is defined in `grammar.js` using Tree-sitter's JavaScript DSL. Key components include:
|
|
48
|
+
|
|
49
|
+
- Lexical rules (tokens, keywords, operators)
|
|
50
|
+
- Syntax rules (expressions, statements, mappings)
|
|
51
|
+
- Error recovery patterns
|
|
52
|
+
|
|
53
|
+
## Resources
|
|
54
|
+
|
|
55
|
+
- [Bento Bloblang Documentation](https://github.com/warpstreamlabs/bento/tree/main/website/docs/guides/bloblang)
|
|
56
|
+
- [Tree-sitter Documentation](https://tree-sitter.github.io/tree-sitter/)
|
|
57
|
+
|
|
58
|
+
## Contributing
|
|
59
|
+
|
|
60
|
+
Contributions are welcome! Please open issues for bugs or feature requests, and submit pull requests for improvements.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""parser for bento bloblang"""
|
|
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,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_bloblang(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_bloblang(), "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
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-bloblang
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: parser for bento bloblang
|
|
5
|
+
Author-email: Henrik Christensen <henrik@hsctech.eu>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://codeberg.org/hsctech/blobl_sitter
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,bloblang
|
|
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 Grammar for Bento Bloblang
|
|
21
|
+
|
|
22
|
+
This project aims to create a Tree-sitter grammar for Bento Bloblang, a powerful data transformation language used in the Bento ecosystem.
|
|
23
|
+
|
|
24
|
+
## About Bloblang
|
|
25
|
+
|
|
26
|
+
Bloblang is a declarative mapping language designed for transforming data structures. It's used in Bento for processing and manipulating data in pipelines.
|
|
27
|
+
|
|
28
|
+
## Project Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
.
|
|
32
|
+
├── grammar.js # Tree-sitter grammar definition
|
|
33
|
+
├── bindings/ # Language bindings (Node.js, etc.)
|
|
34
|
+
├── queries/ # Syntax highlighting queries
|
|
35
|
+
├── src/ # Supporting code
|
|
36
|
+
└── tests/ # Test cases
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Getting Started
|
|
40
|
+
|
|
41
|
+
### Prerequisites
|
|
42
|
+
|
|
43
|
+
- Node.js (for building and testing)
|
|
44
|
+
- Tree-sitter CLI
|
|
45
|
+
|
|
46
|
+
### Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Building
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Testing
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm test
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Grammar Development
|
|
65
|
+
|
|
66
|
+
The grammar is defined in `grammar.js` using Tree-sitter's JavaScript DSL. Key components include:
|
|
67
|
+
|
|
68
|
+
- Lexical rules (tokens, keywords, operators)
|
|
69
|
+
- Syntax rules (expressions, statements, mappings)
|
|
70
|
+
- Error recovery patterns
|
|
71
|
+
|
|
72
|
+
## Resources
|
|
73
|
+
|
|
74
|
+
- [Bento Bloblang Documentation](https://github.com/warpstreamlabs/bento/tree/main/website/docs/guides/bloblang)
|
|
75
|
+
- [Tree-sitter Documentation](https://tree-sitter.github.io/tree-sitter/)
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
|
|
79
|
+
Contributions are welcome! Please open issues for bugs or feature requests, and submit pull requests for improvements.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
bindings/python/tree_sitter_bloblang/__init__.py
|
|
6
|
+
bindings/python/tree_sitter_bloblang/__init__.pyi
|
|
7
|
+
bindings/python/tree_sitter_bloblang/binding.c
|
|
8
|
+
bindings/python/tree_sitter_bloblang/py.typed
|
|
9
|
+
bindings/python/tree_sitter_bloblang.egg-info/PKG-INFO
|
|
10
|
+
bindings/python/tree_sitter_bloblang.egg-info/SOURCES.txt
|
|
11
|
+
bindings/python/tree_sitter_bloblang.egg-info/dependency_links.txt
|
|
12
|
+
bindings/python/tree_sitter_bloblang.egg-info/not-zip-safe
|
|
13
|
+
bindings/python/tree_sitter_bloblang.egg-info/requires.txt
|
|
14
|
+
bindings/python/tree_sitter_bloblang.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>=62.4.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tree-sitter-bloblang"
|
|
7
|
+
description = "parser for bento bloblang"
|
|
8
|
+
version = "0.2.1"
|
|
9
|
+
keywords = ["incremental", "parsing", "tree-sitter", "bloblang"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Topic :: Software Development :: Compilers",
|
|
13
|
+
"Topic :: Text Processing :: Linguistic",
|
|
14
|
+
"Typing :: Typed",
|
|
15
|
+
]
|
|
16
|
+
authors = [{ name = "Henrik Christensen", email = "henrik@hsctech.eu" }]
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
license.text = "MIT"
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://codeberg.org/hsctech/blobl_sitter"
|
|
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,110 @@
|
|
|
1
|
+
; Bloblang highlights for tree-sitter
|
|
2
|
+
; =====================================
|
|
3
|
+
|
|
4
|
+
; Keywords — only anonymous tokens from the grammar are valid as string patterns.
|
|
5
|
+
; "root" and "this" are named node types, so they are captured below via (root)/(this).
|
|
6
|
+
[
|
|
7
|
+
"let"
|
|
8
|
+
"meta"
|
|
9
|
+
"map"
|
|
10
|
+
"import"
|
|
11
|
+
"if"
|
|
12
|
+
"else"
|
|
13
|
+
"match"
|
|
14
|
+
] @keyword
|
|
15
|
+
|
|
16
|
+
; Operators
|
|
17
|
+
[
|
|
18
|
+
"="
|
|
19
|
+
"=>"
|
|
20
|
+
"->"
|
|
21
|
+
"+"
|
|
22
|
+
"-"
|
|
23
|
+
"*"
|
|
24
|
+
"/"
|
|
25
|
+
"%"
|
|
26
|
+
"!"
|
|
27
|
+
">"
|
|
28
|
+
">="
|
|
29
|
+
"<"
|
|
30
|
+
"<="
|
|
31
|
+
"=="
|
|
32
|
+
"!="
|
|
33
|
+
"&&"
|
|
34
|
+
"||"
|
|
35
|
+
"|"
|
|
36
|
+
] @operator
|
|
37
|
+
|
|
38
|
+
; Punctuation
|
|
39
|
+
["{" "}"] @punctuation.bracket
|
|
40
|
+
["[" "]"] @punctuation.bracket
|
|
41
|
+
["(" ")"] @punctuation.bracket
|
|
42
|
+
["." "," ":"] @punctuation.delimiter
|
|
43
|
+
|
|
44
|
+
; Literals
|
|
45
|
+
(number) @constant.numeric
|
|
46
|
+
(boolean) @constant.builtin
|
|
47
|
+
(null) @constant.builtin
|
|
48
|
+
|
|
49
|
+
; Strings
|
|
50
|
+
(string) @string
|
|
51
|
+
|
|
52
|
+
; Comments
|
|
53
|
+
(comment) @comment
|
|
54
|
+
|
|
55
|
+
; Variables ($var)
|
|
56
|
+
(variable) @variable.parameter
|
|
57
|
+
|
|
58
|
+
; Metadata (@key)
|
|
59
|
+
(metadata) @variable.special
|
|
60
|
+
|
|
61
|
+
; Wildcard in match
|
|
62
|
+
(wildcard) @constant.builtin
|
|
63
|
+
|
|
64
|
+
; map Name { }
|
|
65
|
+
(map_definition
|
|
66
|
+
name: (identifier) @namespace)
|
|
67
|
+
|
|
68
|
+
; import "path"
|
|
69
|
+
(import_statement
|
|
70
|
+
path: (string) @string.special)
|
|
71
|
+
|
|
72
|
+
; let foo = ... (name is plain identifier)
|
|
73
|
+
(let_statement
|
|
74
|
+
name: (identifier) @variable.parameter)
|
|
75
|
+
|
|
76
|
+
; Built-in functions: call_expression where function is a plain identifier
|
|
77
|
+
(call_expression
|
|
78
|
+
function: (identifier) @function.builtin
|
|
79
|
+
(#match? @function.builtin
|
|
80
|
+
"^(uuid_v4|now|hostname|range|content|timestamp|timestamp_unix|timestamp_unix_nano|random_int|env|var|count|batch_size|ksuid|nanoid|error|errored|metadata|deleted|throw)$"))
|
|
81
|
+
|
|
82
|
+
; Other plain function calls
|
|
83
|
+
(call_expression
|
|
84
|
+
function: (identifier) @function)
|
|
85
|
+
|
|
86
|
+
; Built-in method calls: call_expression where function is member_expression
|
|
87
|
+
(call_expression
|
|
88
|
+
function: (member_expression
|
|
89
|
+
property: (identifier) @function.builtin)
|
|
90
|
+
(#match? @function.builtin
|
|
91
|
+
"^(map_each|apply|catch|or|exists|not_null|length|string|number|bool|bytes|type|uppercase|lowercase|trim|reverse|sort|unique|flatten|explode|collapse|parse_json|format_json|parse_yaml|format_yaml|parse_csv|format_csv|encode|decode|hash|hmac|split|join|replace|replace_all|contains|has_prefix|has_suffix|index|slice|keys|values|items|assign|merge|filter|find|find_all|all|any|sum|min|max|abs|floor|ceil|round|round_precise|log|pow|sqrt|format|timediff_days_absolute|ts_strptime|re_match|re_find|re_find_all|re_replace|re_replace_all|re_split|xpath|jmespath|not|not_null|satser)$"))
|
|
92
|
+
|
|
93
|
+
; Other method calls
|
|
94
|
+
(call_expression
|
|
95
|
+
function: (member_expression
|
|
96
|
+
property: (identifier) @function.method))
|
|
97
|
+
|
|
98
|
+
; Arrow function parameter
|
|
99
|
+
(arrow_function
|
|
100
|
+
param: (identifier) @variable.parameter)
|
|
101
|
+
|
|
102
|
+
; Named arguments
|
|
103
|
+
(named_argument
|
|
104
|
+
name: (identifier) @variable.parameter)
|
|
105
|
+
|
|
106
|
+
; root and this keywords in member expressions and assignments
|
|
107
|
+
(member_expression object: (root) @keyword)
|
|
108
|
+
(member_expression object: (this) @keyword)
|
|
109
|
+
(assignment left: (root) @keyword)
|
|
110
|
+
(assignment left: (this) @keyword)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
; Bloblang locals for tree-sitter
|
|
2
|
+
|
|
3
|
+
; Map definitions create a scope
|
|
4
|
+
(map_definition) @local.scope
|
|
5
|
+
|
|
6
|
+
; let foo = ... defines a local variable
|
|
7
|
+
(let_statement
|
|
8
|
+
name: (identifier) @local.definition)
|
|
9
|
+
|
|
10
|
+
; $var references
|
|
11
|
+
(variable) @local.reference
|
|
12
|
+
|
|
13
|
+
; arrow function parameter
|
|
14
|
+
(arrow_function
|
|
15
|
+
param: (identifier) @local.definition)
|
|
@@ -0,0 +1,77 @@
|
|
|
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_bloblang", "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"):
|
|
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
|
+
|
|
46
|
+
|
|
47
|
+
setup(
|
|
48
|
+
packages=find_packages("bindings/python"),
|
|
49
|
+
package_dir={"": "bindings/python"},
|
|
50
|
+
package_data={
|
|
51
|
+
"tree_sitter_bloblang": ["*.pyi", "py.typed"],
|
|
52
|
+
"tree_sitter_bloblang.queries": ["*.scm"],
|
|
53
|
+
},
|
|
54
|
+
ext_package="tree_sitter_bloblang",
|
|
55
|
+
ext_modules=[
|
|
56
|
+
Extension(
|
|
57
|
+
name="_binding",
|
|
58
|
+
sources=[
|
|
59
|
+
"bindings/python/tree_sitter_bloblang/binding.c",
|
|
60
|
+
"src/parser.c",
|
|
61
|
+
],
|
|
62
|
+
define_macros=[
|
|
63
|
+
("PY_SSIZE_T_CLEAN", None),
|
|
64
|
+
("TREE_SITTER_HIDE_SYMBOLS", None),
|
|
65
|
+
],
|
|
66
|
+
include_dirs=["src"],
|
|
67
|
+
py_limited_api=not get_config_var("Py_GIL_DISABLED"),
|
|
68
|
+
)
|
|
69
|
+
],
|
|
70
|
+
cmdclass={
|
|
71
|
+
"build": Build,
|
|
72
|
+
"build_ext": BuildExt,
|
|
73
|
+
"bdist_wheel": BdistWheel,
|
|
74
|
+
"egg_info": EggInfo,
|
|
75
|
+
},
|
|
76
|
+
zip_safe=False
|
|
77
|
+
)
|