tree-sitter-ruby-magikdidi24 0.25.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.
- tree_sitter_ruby_magikdidi24-0.25.0/LICENSE +22 -0
- tree_sitter_ruby_magikdidi24-0.25.0/PKG-INFO +81 -0
- tree_sitter_ruby_magikdidi24-0.25.0/README.md +61 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby/__init__.py +40 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby/__init__.pyi +8 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby/binding.c +35 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby/py.typed +0 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby_magikdidi24.egg-info/PKG-INFO +81 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby_magikdidi24.egg-info/SOURCES.txt +15 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby_magikdidi24.egg-info/dependency_links.txt +1 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby_magikdidi24.egg-info/not-zip-safe +1 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby_magikdidi24.egg-info/requires.txt +3 -0
- tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby_magikdidi24.egg-info/top_level.txt +2 -0
- tree_sitter_ruby_magikdidi24-0.25.0/pyproject.toml +34 -0
- tree_sitter_ruby_magikdidi24-0.25.0/queries/highlights.scm +178 -0
- tree_sitter_ruby_magikdidi24-0.25.0/queries/injections.scm +38 -0
- tree_sitter_ruby_magikdidi24-0.25.0/queries/locals.scm +57 -0
- tree_sitter_ruby_magikdidi24-0.25.0/queries/tags.scm +84 -0
- tree_sitter_ruby_magikdidi24-0.25.0/setup.cfg +4 -0
- tree_sitter_ruby_magikdidi24-0.25.0/setup.py +79 -0
- tree_sitter_ruby_magikdidi24-0.25.0/src/locals.h +319 -0
- tree_sitter_ruby_magikdidi24-0.25.0/src/parser.c +617331 -0
- tree_sitter_ruby_magikdidi24-0.25.0/src/scanner.c +1311 -0
- tree_sitter_ruby_magikdidi24-0.25.0/src/tree_sitter/alloc.h +54 -0
- tree_sitter_ruby_magikdidi24-0.25.0/src/tree_sitter/array.h +336 -0
- tree_sitter_ruby_magikdidi24-0.25.0/src/tree_sitter/parser.h +286 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Rob Rix
|
|
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.
|
|
22
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-ruby-magikdidi24
|
|
3
|
+
Version: 0.25.0
|
|
4
|
+
Summary: Ruby grammar for tree-sitter
|
|
5
|
+
Author-email: Max Brunsfeld <maxbrunsfeld@gmail.com>, Amaan Qureshi <amaanq12@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Magikdidi24/tree-sitter-ruby
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,ruby
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
12
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Provides-Extra: core
|
|
18
|
+
Requires-Dist: tree-sitter~=0.25; extra == "core"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# tree-sitter-ruby
|
|
22
|
+
|
|
23
|
+
[![CI][ci]](https://github.com/Magikdidi24/tree-sitter-ruby/actions/workflows/ci.yml)
|
|
24
|
+
[![release][release]](https://github.com/Magikdidi24/tree-sitter-ruby/releases/latest)
|
|
25
|
+
[![playground][playground]](https://magikdidi24.github.io/tree-sitter-ruby/)
|
|
26
|
+
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
|
|
27
|
+
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
|
|
28
|
+
|
|
29
|
+
Ruby grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), a maintained fork of
|
|
30
|
+
[tree-sitter/tree-sitter-ruby](https://github.com/tree-sitter/tree-sitter-ruby). Try it in the
|
|
31
|
+
[playground](https://magikdidi24.github.io/tree-sitter-ruby/).
|
|
32
|
+
|
|
33
|
+
#### Install
|
|
34
|
+
|
|
35
|
+
The import names are the upstream ones (`tree_sitter_ruby`), so only the dependency changes:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
cargo add tree-sitter-ruby-magikdidi24 --git https://github.com/Magikdidi24/tree-sitter-ruby --tag v0.25.0
|
|
39
|
+
npm install github:Magikdidi24/tree-sitter-ruby#v0.25.0
|
|
40
|
+
pip install git+https://github.com/Magikdidi24/tree-sitter-ruby@v0.25.0
|
|
41
|
+
go get github.com/Magikdidi24/tree-sitter-ruby@v0.25.0
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Development
|
|
45
|
+
|
|
46
|
+
The parser is generated for ABI 15, which tree-sitter 0.25 and newer runtimes read (Neovim 0.11, py-tree-sitter 0.25,
|
|
47
|
+
node-tree-sitter 0.25, the Rust crate 0.25):
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm ci
|
|
51
|
+
node_modules/.bin/tree-sitter generate
|
|
52
|
+
node_modules/.bin/tree-sitter test
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Older runtimes (Neovim 0.10, tree-sitter 0.22 to 0.24) need a parser for ABI 14: `node_modules/.bin/tree-sitter generate --abi 14`.
|
|
56
|
+
|
|
57
|
+
Deno can load `grammar.js` instead of Node, and lints it:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
TREE_SITTER_JS_RUNTIME=deno node_modules/.bin/tree-sitter generate
|
|
61
|
+
deno lint
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`bundle exec ruby script/prism_diff.rb DIR` compares the trees with [Prism](https://github.com/ruby/prism) on the Ruby files in `DIR`.
|
|
65
|
+
|
|
66
|
+
#### Local variables
|
|
67
|
+
|
|
68
|
+
Like Ruby, the parser reads `x +1` as `x + 1` when `x` is a local variable, and as the call `x(+1)` otherwise. The external
|
|
69
|
+
scanner tracks assignments, parameters, `for` and `rescue =>` variables, numbered parameters, and the scopes of blocks,
|
|
70
|
+
methods, classes and modules. Variables bound by pattern matching (`in [x]`, `=> x`) are not tracked, so there `x +1`
|
|
71
|
+
stays a call.
|
|
72
|
+
|
|
73
|
+
#### References
|
|
74
|
+
|
|
75
|
+
- [AST Format of the Whitequark parser](https://github.com/whitequark/parser/blob/master/doc/AST_FORMAT.md)
|
|
76
|
+
|
|
77
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/Magikdidi24/tree-sitter-ruby/ci.yml?branch=master&logo=github&label=CI
|
|
78
|
+
[release]: https://img.shields.io/github/v/release/Magikdidi24/tree-sitter-ruby?logo=github
|
|
79
|
+
[playground]: https://img.shields.io/badge/playground-try%20it-blue?logo=webassembly
|
|
80
|
+
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
|
|
81
|
+
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# tree-sitter-ruby
|
|
2
|
+
|
|
3
|
+
[![CI][ci]](https://github.com/Magikdidi24/tree-sitter-ruby/actions/workflows/ci.yml)
|
|
4
|
+
[![release][release]](https://github.com/Magikdidi24/tree-sitter-ruby/releases/latest)
|
|
5
|
+
[![playground][playground]](https://magikdidi24.github.io/tree-sitter-ruby/)
|
|
6
|
+
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
|
|
7
|
+
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
|
|
8
|
+
|
|
9
|
+
Ruby grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), a maintained fork of
|
|
10
|
+
[tree-sitter/tree-sitter-ruby](https://github.com/tree-sitter/tree-sitter-ruby). Try it in the
|
|
11
|
+
[playground](https://magikdidi24.github.io/tree-sitter-ruby/).
|
|
12
|
+
|
|
13
|
+
#### Install
|
|
14
|
+
|
|
15
|
+
The import names are the upstream ones (`tree_sitter_ruby`), so only the dependency changes:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
cargo add tree-sitter-ruby-magikdidi24 --git https://github.com/Magikdidi24/tree-sitter-ruby --tag v0.25.0
|
|
19
|
+
npm install github:Magikdidi24/tree-sitter-ruby#v0.25.0
|
|
20
|
+
pip install git+https://github.com/Magikdidi24/tree-sitter-ruby@v0.25.0
|
|
21
|
+
go get github.com/Magikdidi24/tree-sitter-ruby@v0.25.0
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Development
|
|
25
|
+
|
|
26
|
+
The parser is generated for ABI 15, which tree-sitter 0.25 and newer runtimes read (Neovim 0.11, py-tree-sitter 0.25,
|
|
27
|
+
node-tree-sitter 0.25, the Rust crate 0.25):
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm ci
|
|
31
|
+
node_modules/.bin/tree-sitter generate
|
|
32
|
+
node_modules/.bin/tree-sitter test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Older runtimes (Neovim 0.10, tree-sitter 0.22 to 0.24) need a parser for ABI 14: `node_modules/.bin/tree-sitter generate --abi 14`.
|
|
36
|
+
|
|
37
|
+
Deno can load `grammar.js` instead of Node, and lints it:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
TREE_SITTER_JS_RUNTIME=deno node_modules/.bin/tree-sitter generate
|
|
41
|
+
deno lint
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`bundle exec ruby script/prism_diff.rb DIR` compares the trees with [Prism](https://github.com/ruby/prism) on the Ruby files in `DIR`.
|
|
45
|
+
|
|
46
|
+
#### Local variables
|
|
47
|
+
|
|
48
|
+
Like Ruby, the parser reads `x +1` as `x + 1` when `x` is a local variable, and as the call `x(+1)` otherwise. The external
|
|
49
|
+
scanner tracks assignments, parameters, `for` and `rescue =>` variables, numbered parameters, and the scopes of blocks,
|
|
50
|
+
methods, classes and modules. Variables bound by pattern matching (`in [x]`, `=> x`) are not tracked, so there `x +1`
|
|
51
|
+
stays a call.
|
|
52
|
+
|
|
53
|
+
#### References
|
|
54
|
+
|
|
55
|
+
- [AST Format of the Whitequark parser](https://github.com/whitequark/parser/blob/master/doc/AST_FORMAT.md)
|
|
56
|
+
|
|
57
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/Magikdidi24/tree-sitter-ruby/ci.yml?branch=master&logo=github&label=CI
|
|
58
|
+
[release]: https://img.shields.io/github/v/release/Magikdidi24/tree-sitter-ruby?logo=github
|
|
59
|
+
[playground]: https://img.shields.io/badge/playground-try%20it-blue?logo=webassembly
|
|
60
|
+
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
|
|
61
|
+
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Ruby 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
|
+
if name == "HIGHLIGHTS_QUERY":
|
|
16
|
+
return _get_query("HIGHLIGHTS_QUERY", "highlights.scm")
|
|
17
|
+
if name == "INJECTIONS_QUERY":
|
|
18
|
+
return _get_query("INJECTIONS_QUERY", "injections.scm")
|
|
19
|
+
if name == "LOCALS_QUERY":
|
|
20
|
+
return _get_query("LOCALS_QUERY", "locals.scm")
|
|
21
|
+
if name == "TAGS_QUERY":
|
|
22
|
+
return _get_query("TAGS_QUERY", "tags.scm")
|
|
23
|
+
|
|
24
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"language",
|
|
29
|
+
"HIGHLIGHTS_QUERY",
|
|
30
|
+
"INJECTIONS_QUERY",
|
|
31
|
+
"LOCALS_QUERY",
|
|
32
|
+
"TAGS_QUERY",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __dir__():
|
|
37
|
+
return sorted(__all__ + [
|
|
38
|
+
"__all__", "__builtins__", "__cached__", "__doc__", "__file__",
|
|
39
|
+
"__loader__", "__name__", "__package__", "__path__", "__spec__",
|
|
40
|
+
])
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_ruby(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_ruby(), "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
|
tree_sitter_ruby_magikdidi24-0.25.0/bindings/python/tree_sitter_ruby_magikdidi24.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-ruby-magikdidi24
|
|
3
|
+
Version: 0.25.0
|
|
4
|
+
Summary: Ruby grammar for tree-sitter
|
|
5
|
+
Author-email: Max Brunsfeld <maxbrunsfeld@gmail.com>, Amaan Qureshi <amaanq12@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Magikdidi24/tree-sitter-ruby
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,ruby
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
12
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Provides-Extra: core
|
|
18
|
+
Requires-Dist: tree-sitter~=0.25; extra == "core"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# tree-sitter-ruby
|
|
22
|
+
|
|
23
|
+
[![CI][ci]](https://github.com/Magikdidi24/tree-sitter-ruby/actions/workflows/ci.yml)
|
|
24
|
+
[![release][release]](https://github.com/Magikdidi24/tree-sitter-ruby/releases/latest)
|
|
25
|
+
[![playground][playground]](https://magikdidi24.github.io/tree-sitter-ruby/)
|
|
26
|
+
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
|
|
27
|
+
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
|
|
28
|
+
|
|
29
|
+
Ruby grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), a maintained fork of
|
|
30
|
+
[tree-sitter/tree-sitter-ruby](https://github.com/tree-sitter/tree-sitter-ruby). Try it in the
|
|
31
|
+
[playground](https://magikdidi24.github.io/tree-sitter-ruby/).
|
|
32
|
+
|
|
33
|
+
#### Install
|
|
34
|
+
|
|
35
|
+
The import names are the upstream ones (`tree_sitter_ruby`), so only the dependency changes:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
cargo add tree-sitter-ruby-magikdidi24 --git https://github.com/Magikdidi24/tree-sitter-ruby --tag v0.25.0
|
|
39
|
+
npm install github:Magikdidi24/tree-sitter-ruby#v0.25.0
|
|
40
|
+
pip install git+https://github.com/Magikdidi24/tree-sitter-ruby@v0.25.0
|
|
41
|
+
go get github.com/Magikdidi24/tree-sitter-ruby@v0.25.0
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Development
|
|
45
|
+
|
|
46
|
+
The parser is generated for ABI 15, which tree-sitter 0.25 and newer runtimes read (Neovim 0.11, py-tree-sitter 0.25,
|
|
47
|
+
node-tree-sitter 0.25, the Rust crate 0.25):
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm ci
|
|
51
|
+
node_modules/.bin/tree-sitter generate
|
|
52
|
+
node_modules/.bin/tree-sitter test
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Older runtimes (Neovim 0.10, tree-sitter 0.22 to 0.24) need a parser for ABI 14: `node_modules/.bin/tree-sitter generate --abi 14`.
|
|
56
|
+
|
|
57
|
+
Deno can load `grammar.js` instead of Node, and lints it:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
TREE_SITTER_JS_RUNTIME=deno node_modules/.bin/tree-sitter generate
|
|
61
|
+
deno lint
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`bundle exec ruby script/prism_diff.rb DIR` compares the trees with [Prism](https://github.com/ruby/prism) on the Ruby files in `DIR`.
|
|
65
|
+
|
|
66
|
+
#### Local variables
|
|
67
|
+
|
|
68
|
+
Like Ruby, the parser reads `x +1` as `x + 1` when `x` is a local variable, and as the call `x(+1)` otherwise. The external
|
|
69
|
+
scanner tracks assignments, parameters, `for` and `rescue =>` variables, numbered parameters, and the scopes of blocks,
|
|
70
|
+
methods, classes and modules. Variables bound by pattern matching (`in [x]`, `=> x`) are not tracked, so there `x +1`
|
|
71
|
+
stays a call.
|
|
72
|
+
|
|
73
|
+
#### References
|
|
74
|
+
|
|
75
|
+
- [AST Format of the Whitequark parser](https://github.com/whitequark/parser/blob/master/doc/AST_FORMAT.md)
|
|
76
|
+
|
|
77
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/Magikdidi24/tree-sitter-ruby/ci.yml?branch=master&logo=github&label=CI
|
|
78
|
+
[release]: https://img.shields.io/github/v/release/Magikdidi24/tree-sitter-ruby?logo=github
|
|
79
|
+
[playground]: https://img.shields.io/badge/playground-try%20it-blue?logo=webassembly
|
|
80
|
+
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
|
|
81
|
+
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
bindings/python/tree_sitter_ruby/__init__.py
|
|
6
|
+
bindings/python/tree_sitter_ruby/__init__.pyi
|
|
7
|
+
bindings/python/tree_sitter_ruby/binding.c
|
|
8
|
+
bindings/python/tree_sitter_ruby/py.typed
|
|
9
|
+
bindings/python/tree_sitter_ruby_magikdidi24.egg-info/PKG-INFO
|
|
10
|
+
bindings/python/tree_sitter_ruby_magikdidi24.egg-info/SOURCES.txt
|
|
11
|
+
bindings/python/tree_sitter_ruby_magikdidi24.egg-info/dependency_links.txt
|
|
12
|
+
bindings/python/tree_sitter_ruby_magikdidi24.egg-info/not-zip-safe
|
|
13
|
+
bindings/python/tree_sitter_ruby_magikdidi24.egg-info/requires.txt
|
|
14
|
+
bindings/python/tree_sitter_ruby_magikdidi24.egg-info/top_level.txt
|
|
15
|
+
src/parser.c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=71"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
# This fork's distribution; the module keeps the upstream name, `import tree_sitter_ruby`
|
|
7
|
+
name = "tree-sitter-ruby-magikdidi24"
|
|
8
|
+
description = "Ruby grammar for tree-sitter"
|
|
9
|
+
version = "0.25.0"
|
|
10
|
+
keywords = ["incremental", "parsing", "tree-sitter", "ruby"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Topic :: Software Development :: Compilers",
|
|
15
|
+
"Topic :: Text Processing :: Linguistic",
|
|
16
|
+
"Typing :: Typed",
|
|
17
|
+
]
|
|
18
|
+
authors = [
|
|
19
|
+
{ name = "Max Brunsfeld", email = "maxbrunsfeld@gmail.com" },
|
|
20
|
+
{ name = "Amaan Qureshi", email = "amaanq12@gmail.com" },
|
|
21
|
+
]
|
|
22
|
+
requires-python = ">=3.10"
|
|
23
|
+
license.text = "MIT"
|
|
24
|
+
readme = "README.md"
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/Magikdidi24/tree-sitter-ruby"
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
core = ["tree-sitter~=0.25"]
|
|
31
|
+
|
|
32
|
+
[tool.cibuildwheel]
|
|
33
|
+
build = "cp310-*"
|
|
34
|
+
build-frontend = "build"
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
(identifier) @variable
|
|
2
|
+
|
|
3
|
+
((identifier) @function.method
|
|
4
|
+
(#is-not? local))
|
|
5
|
+
|
|
6
|
+
[
|
|
7
|
+
"BEGIN"
|
|
8
|
+
"END"
|
|
9
|
+
"alias"
|
|
10
|
+
"and"
|
|
11
|
+
"begin"
|
|
12
|
+
"break"
|
|
13
|
+
"case"
|
|
14
|
+
"class"
|
|
15
|
+
"def"
|
|
16
|
+
"do"
|
|
17
|
+
"else"
|
|
18
|
+
"elsif"
|
|
19
|
+
"end"
|
|
20
|
+
"ensure"
|
|
21
|
+
"for"
|
|
22
|
+
"if"
|
|
23
|
+
"in"
|
|
24
|
+
"module"
|
|
25
|
+
"next"
|
|
26
|
+
"not"
|
|
27
|
+
"or"
|
|
28
|
+
"rescue"
|
|
29
|
+
"redo"
|
|
30
|
+
"retry"
|
|
31
|
+
"return"
|
|
32
|
+
"then"
|
|
33
|
+
"undef"
|
|
34
|
+
"unless"
|
|
35
|
+
"until"
|
|
36
|
+
"when"
|
|
37
|
+
"while"
|
|
38
|
+
"yield"
|
|
39
|
+
] @keyword
|
|
40
|
+
|
|
41
|
+
(constant) @constructor
|
|
42
|
+
|
|
43
|
+
; Function calls
|
|
44
|
+
|
|
45
|
+
"defined?" @function.method.builtin
|
|
46
|
+
|
|
47
|
+
(call
|
|
48
|
+
method: [(identifier) (constant)] @function.method)
|
|
49
|
+
|
|
50
|
+
((identifier) @function.method.builtin
|
|
51
|
+
(#any-of? @function.method.builtin
|
|
52
|
+
"require" "require_relative" "load" "autoload"
|
|
53
|
+
"attr_reader" "attr_writer" "attr_accessor"
|
|
54
|
+
"include" "extend" "prepend" "raise" "fail"))
|
|
55
|
+
|
|
56
|
+
((identifier) @keyword
|
|
57
|
+
(#match? @keyword "^(private|protected|public)$"))
|
|
58
|
+
|
|
59
|
+
; Function definitions
|
|
60
|
+
|
|
61
|
+
(alias (identifier) @function.method)
|
|
62
|
+
(setter (identifier) @function.method)
|
|
63
|
+
(method name: [(identifier) (constant)] @function.method)
|
|
64
|
+
(singleton_method name: [(identifier) (constant)] @function.method)
|
|
65
|
+
|
|
66
|
+
; Identifiers
|
|
67
|
+
|
|
68
|
+
[
|
|
69
|
+
(class_variable)
|
|
70
|
+
(instance_variable)
|
|
71
|
+
] @property
|
|
72
|
+
|
|
73
|
+
(global_variable) @variable
|
|
74
|
+
|
|
75
|
+
((identifier) @constant.builtin
|
|
76
|
+
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
|
|
77
|
+
|
|
78
|
+
(hash_splat_nil
|
|
79
|
+
"**" @operator) @constant.builtin
|
|
80
|
+
|
|
81
|
+
((constant) @constant
|
|
82
|
+
(#match? @constant "^[A-Z\\d_]+$"))
|
|
83
|
+
|
|
84
|
+
[
|
|
85
|
+
(self)
|
|
86
|
+
(super)
|
|
87
|
+
] @variable.builtin
|
|
88
|
+
|
|
89
|
+
(block_parameter (identifier) @variable.parameter)
|
|
90
|
+
(block_parameters (identifier) @variable.parameter)
|
|
91
|
+
(destructured_parameter (identifier) @variable.parameter)
|
|
92
|
+
(hash_splat_parameter (identifier) @variable.parameter)
|
|
93
|
+
(lambda_parameters (identifier) @variable.parameter)
|
|
94
|
+
(method_parameters (identifier) @variable.parameter)
|
|
95
|
+
(splat_parameter (identifier) @variable.parameter)
|
|
96
|
+
|
|
97
|
+
(keyword_parameter name: (identifier) @variable.parameter)
|
|
98
|
+
(optional_parameter name: (identifier) @variable.parameter)
|
|
99
|
+
|
|
100
|
+
; Literals
|
|
101
|
+
|
|
102
|
+
[
|
|
103
|
+
(string)
|
|
104
|
+
(bare_string)
|
|
105
|
+
(subshell)
|
|
106
|
+
(heredoc_body)
|
|
107
|
+
(heredoc_beginning)
|
|
108
|
+
] @string
|
|
109
|
+
|
|
110
|
+
[
|
|
111
|
+
(simple_symbol)
|
|
112
|
+
(delimited_symbol)
|
|
113
|
+
(hash_key_symbol)
|
|
114
|
+
(bare_symbol)
|
|
115
|
+
] @string.special.symbol
|
|
116
|
+
|
|
117
|
+
(regex) @string.regexp
|
|
118
|
+
(escape_sequence) @escape
|
|
119
|
+
|
|
120
|
+
[
|
|
121
|
+
(integer)
|
|
122
|
+
(float)
|
|
123
|
+
(rational)
|
|
124
|
+
(complex)
|
|
125
|
+
] @number
|
|
126
|
+
|
|
127
|
+
(character) @string
|
|
128
|
+
|
|
129
|
+
(uninterpreted) @comment
|
|
130
|
+
|
|
131
|
+
[
|
|
132
|
+
(nil)
|
|
133
|
+
(true)
|
|
134
|
+
(false)
|
|
135
|
+
(file)
|
|
136
|
+
(line)
|
|
137
|
+
(encoding)
|
|
138
|
+
] @constant.builtin
|
|
139
|
+
|
|
140
|
+
(comment) @comment
|
|
141
|
+
|
|
142
|
+
; Operators
|
|
143
|
+
|
|
144
|
+
[
|
|
145
|
+
"=" "=>" "->"
|
|
146
|
+
"!" "!=" "!~" "%" "%=" "&" "&&" "&&=" "&=" "*" "**" "**=" "*="
|
|
147
|
+
"+" "+=" "-" "-=" "/=" "<" "<<" "<<=" "<=" "<=>" "==" "==="
|
|
148
|
+
"=~" ">" ">=" ">>" ">>=" "^" "^=" "|" "|=" "||" "||=" "~" ".." "..."
|
|
149
|
+
] @operator
|
|
150
|
+
|
|
151
|
+
(binary "/" @operator) ; "/" also delimits regex literals
|
|
152
|
+
|
|
153
|
+
(conditional ["?" ":"] @operator)
|
|
154
|
+
|
|
155
|
+
[
|
|
156
|
+
","
|
|
157
|
+
";"
|
|
158
|
+
"."
|
|
159
|
+
"&."
|
|
160
|
+
"::"
|
|
161
|
+
] @punctuation.delimiter
|
|
162
|
+
|
|
163
|
+
[
|
|
164
|
+
"("
|
|
165
|
+
")"
|
|
166
|
+
"["
|
|
167
|
+
"]"
|
|
168
|
+
"{"
|
|
169
|
+
"}"
|
|
170
|
+
"%w("
|
|
171
|
+
"%i("
|
|
172
|
+
] @punctuation.bracket
|
|
173
|
+
|
|
174
|
+
(block_parameters "|" @punctuation.bracket)
|
|
175
|
+
|
|
176
|
+
(interpolation
|
|
177
|
+
"#{" @punctuation.special
|
|
178
|
+
"}" @punctuation.special) @embedded
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
((regex
|
|
2
|
+
(string_content) @injection.content)
|
|
3
|
+
(#set! injection.language "regex"))
|
|
4
|
+
|
|
5
|
+
((subshell
|
|
6
|
+
(string_content) @injection.content)
|
|
7
|
+
(#set! injection.language "bash"))
|
|
8
|
+
|
|
9
|
+
; Heredocs whose label names a language, e.g. `<<~SQL`
|
|
10
|
+
((heredoc_body
|
|
11
|
+
(heredoc_content) @injection.content
|
|
12
|
+
(heredoc_end) @_label)
|
|
13
|
+
(#eq? @_label "SQL")
|
|
14
|
+
(#set! injection.language "sql"))
|
|
15
|
+
|
|
16
|
+
((heredoc_body
|
|
17
|
+
(heredoc_content) @injection.content
|
|
18
|
+
(heredoc_end) @_label)
|
|
19
|
+
(#any-of? @_label "GRAPHQL" "GQL")
|
|
20
|
+
(#set! injection.language "graphql"))
|
|
21
|
+
|
|
22
|
+
((heredoc_body
|
|
23
|
+
(heredoc_content) @injection.content
|
|
24
|
+
(heredoc_end) @_label)
|
|
25
|
+
(#eq? @_label "HTML")
|
|
26
|
+
(#set! injection.language "html"))
|
|
27
|
+
|
|
28
|
+
((heredoc_body
|
|
29
|
+
(heredoc_content) @injection.content
|
|
30
|
+
(heredoc_end) @_label)
|
|
31
|
+
(#any-of? @_label "SH" "BASH" "SHELL")
|
|
32
|
+
(#set! injection.language "bash"))
|
|
33
|
+
|
|
34
|
+
((heredoc_body
|
|
35
|
+
(heredoc_content) @injection.content
|
|
36
|
+
(heredoc_end) @_label)
|
|
37
|
+
(#eq? @_label "RUBY")
|
|
38
|
+
(#set! injection.language "ruby"))
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
; Scopes
|
|
2
|
+
|
|
3
|
+
; `def`, `class`, `module` and `class << x` bodies do not see outer locals, but a superclass (`class A < base`) and
|
|
4
|
+
; the object of `class << obj` are read outside
|
|
5
|
+
([
|
|
6
|
+
(method)
|
|
7
|
+
(singleton_method)
|
|
8
|
+
(module)
|
|
9
|
+
] @local.scope
|
|
10
|
+
(#set! local.scope-inherits false))
|
|
11
|
+
|
|
12
|
+
([
|
|
13
|
+
(class body: (_) @local.scope)
|
|
14
|
+
(singleton_class body: (_) @local.scope)
|
|
15
|
+
]
|
|
16
|
+
(#set! local.scope-inherits false))
|
|
17
|
+
|
|
18
|
+
[
|
|
19
|
+
(lambda)
|
|
20
|
+
(block)
|
|
21
|
+
(do_block)
|
|
22
|
+
] @local.scope
|
|
23
|
+
|
|
24
|
+
; Definitions
|
|
25
|
+
|
|
26
|
+
(block_parameter (identifier) @local.definition)
|
|
27
|
+
(block_parameters (identifier) @local.definition)
|
|
28
|
+
(destructured_parameter (identifier) @local.definition)
|
|
29
|
+
(hash_splat_parameter (identifier) @local.definition)
|
|
30
|
+
(lambda_parameters (identifier) @local.definition)
|
|
31
|
+
(method_parameters (identifier) @local.definition)
|
|
32
|
+
(splat_parameter (identifier) @local.definition)
|
|
33
|
+
|
|
34
|
+
(keyword_parameter name: (identifier) @local.definition)
|
|
35
|
+
(optional_parameter name: (identifier) @local.definition)
|
|
36
|
+
|
|
37
|
+
(exception_variable (identifier) @local.definition)
|
|
38
|
+
(for pattern: (identifier) @local.definition)
|
|
39
|
+
|
|
40
|
+
; Pattern matching bindings: `in x`, `in [x, *y]`, `in {k: x}`, `in T => x`
|
|
41
|
+
(in_clause pattern: (identifier) @local.definition)
|
|
42
|
+
(match_pattern pattern: (identifier) @local.definition)
|
|
43
|
+
(test_pattern pattern: (identifier) @local.definition)
|
|
44
|
+
(array_pattern (identifier) @local.definition)
|
|
45
|
+
(find_pattern (identifier) @local.definition)
|
|
46
|
+
(keyword_pattern value: (identifier) @local.definition)
|
|
47
|
+
(as_pattern name: (identifier) @local.definition)
|
|
48
|
+
|
|
49
|
+
; References
|
|
50
|
+
|
|
51
|
+
(identifier) @local.reference
|
|
52
|
+
|
|
53
|
+
(assignment left: (identifier) @local.definition)
|
|
54
|
+
(operator_assignment left: (identifier) @local.definition)
|
|
55
|
+
(left_assignment_list (identifier) @local.definition)
|
|
56
|
+
(rest_assignment (identifier) @local.definition)
|
|
57
|
+
(destructured_left_assignment (identifier) @local.definition)
|