tree-sitter-enforce 0.4.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_enforce-0.4.0/LICENSE +22 -0
- tree_sitter_enforce-0.4.0/PKG-INFO +70 -0
- tree_sitter_enforce-0.4.0/README.md +51 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce/__init__.py +43 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce/__init__.pyi +17 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce/binding.c +35 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce/py.typed +0 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce.egg-info/PKG-INFO +70 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce.egg-info/SOURCES.txt +15 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce.egg-info/dependency_links.txt +1 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce.egg-info/not-zip-safe +1 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce.egg-info/requires.txt +3 -0
- tree_sitter_enforce-0.4.0/bindings/python/tree_sitter_enforce.egg-info/top_level.txt +2 -0
- tree_sitter_enforce-0.4.0/pyproject.toml +29 -0
- tree_sitter_enforce-0.4.0/queries/aerial.scm +44 -0
- tree_sitter_enforce-0.4.0/queries/context.scm +23 -0
- tree_sitter_enforce-0.4.0/queries/folds.scm +10 -0
- tree_sitter_enforce-0.4.0/queries/highlights.scm +195 -0
- tree_sitter_enforce-0.4.0/queries/indents.scm +42 -0
- tree_sitter_enforce-0.4.0/queries/injections.scm +13 -0
- tree_sitter_enforce-0.4.0/queries/locals.scm +40 -0
- tree_sitter_enforce-0.4.0/queries/tags.scm +9 -0
- tree_sitter_enforce-0.4.0/queries/textobjects.scm +58 -0
- tree_sitter_enforce-0.4.0/setup.cfg +4 -0
- tree_sitter_enforce-0.4.0/setup.py +77 -0
- tree_sitter_enforce-0.4.0/src/parser.c +47690 -0
- tree_sitter_enforce-0.4.0/src/tree_sitter/alloc.h +54 -0
- tree_sitter_enforce-0.4.0/src/tree_sitter/array.h +330 -0
- tree_sitter_enforce-0.4.0/src/tree_sitter/parser.h +286 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Simone Vicinanza
|
|
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,70 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-enforce
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Enforce Script
|
|
5
|
+
Author-email: simonvic <simonvic.dev@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/simonvic/tree-sitter-enforce
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,enforce
|
|
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-enforce
|
|
21
|
+
|
|
22
|
+
[![CI][ci]](https://github.com/simonvic/tree-sitter-enforce/actions/workflows/publish.yml)
|
|
23
|
+
|
|
24
|
+
Enforce grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
|
|
25
|
+
|
|
26
|
+
This grammar intends to be a close approximation of the
|
|
27
|
+
[Enforce](https://community.bistudio.com/wiki/DayZ:Enforce_Script_Syntax)
|
|
28
|
+
script "specification".
|
|
29
|
+
|
|
30
|
+
> [!NOTE]
|
|
31
|
+
> We don't have official specification; some opinionated choices may have been
|
|
32
|
+
> taken (e.g. mandatory semicolon terminated statements)
|
|
33
|
+
>
|
|
34
|
+
> Read more about it
|
|
35
|
+
> [here](https://github.com/simonvic/tree-sitter-enforce/issues/7)
|
|
36
|
+
|
|
37
|
+
## Getting started
|
|
38
|
+
|
|
39
|
+
### neovim
|
|
40
|
+
|
|
41
|
+
Neovim doesn't recognize the Enforce filetype, and since it uses `.c` file
|
|
42
|
+
extension, you need to add a custom language filetype; add the following
|
|
43
|
+
somewhere in your `init.lua`
|
|
44
|
+
|
|
45
|
+
```lua
|
|
46
|
+
vim.filetype.add({
|
|
47
|
+
pattern = {
|
|
48
|
+
[".*/scripts/.*/.*%.c"] = "enforce",
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
*The pattern will match all `.c` files in a `scripts/some_module/` directory.
|
|
54
|
+
You may have to modify the pattern to suit your needs.*
|
|
55
|
+
|
|
56
|
+
To install the parser, you can use
|
|
57
|
+
[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) plugin
|
|
58
|
+
and run `:TSInstall enforce`
|
|
59
|
+
|
|
60
|
+
### VSCode
|
|
61
|
+
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> This has not been tested. Use at your own discretion
|
|
64
|
+
|
|
65
|
+
You can use `tree-sitter-vscode` plugin.
|
|
66
|
+
You'll likely need `tree-sitter-enforce.wasm`, which you can find in the
|
|
67
|
+
[releases](https://github.com/simonvic/tree-sitter-enforce/releases)
|
|
68
|
+
or you can clone this repository and build it with tree-sitter
|
|
69
|
+
|
|
70
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/simonvic/tree-sitter-enforce/publish.yml?logo=github&label=CI
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# tree-sitter-enforce
|
|
2
|
+
|
|
3
|
+
[![CI][ci]](https://github.com/simonvic/tree-sitter-enforce/actions/workflows/publish.yml)
|
|
4
|
+
|
|
5
|
+
Enforce grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
|
|
6
|
+
|
|
7
|
+
This grammar intends to be a close approximation of the
|
|
8
|
+
[Enforce](https://community.bistudio.com/wiki/DayZ:Enforce_Script_Syntax)
|
|
9
|
+
script "specification".
|
|
10
|
+
|
|
11
|
+
> [!NOTE]
|
|
12
|
+
> We don't have official specification; some opinionated choices may have been
|
|
13
|
+
> taken (e.g. mandatory semicolon terminated statements)
|
|
14
|
+
>
|
|
15
|
+
> Read more about it
|
|
16
|
+
> [here](https://github.com/simonvic/tree-sitter-enforce/issues/7)
|
|
17
|
+
|
|
18
|
+
## Getting started
|
|
19
|
+
|
|
20
|
+
### neovim
|
|
21
|
+
|
|
22
|
+
Neovim doesn't recognize the Enforce filetype, and since it uses `.c` file
|
|
23
|
+
extension, you need to add a custom language filetype; add the following
|
|
24
|
+
somewhere in your `init.lua`
|
|
25
|
+
|
|
26
|
+
```lua
|
|
27
|
+
vim.filetype.add({
|
|
28
|
+
pattern = {
|
|
29
|
+
[".*/scripts/.*/.*%.c"] = "enforce",
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
*The pattern will match all `.c` files in a `scripts/some_module/` directory.
|
|
35
|
+
You may have to modify the pattern to suit your needs.*
|
|
36
|
+
|
|
37
|
+
To install the parser, you can use
|
|
38
|
+
[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) plugin
|
|
39
|
+
and run `:TSInstall enforce`
|
|
40
|
+
|
|
41
|
+
### VSCode
|
|
42
|
+
|
|
43
|
+
> [!NOTE]
|
|
44
|
+
> This has not been tested. Use at your own discretion
|
|
45
|
+
|
|
46
|
+
You can use `tree-sitter-vscode` plugin.
|
|
47
|
+
You'll likely need `tree-sitter-enforce.wasm`, which you can find in the
|
|
48
|
+
[releases](https://github.com/simonvic/tree-sitter-enforce/releases)
|
|
49
|
+
or you can clone this repository and build it with tree-sitter
|
|
50
|
+
|
|
51
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/simonvic/tree-sitter-enforce/publish.yml?logo=github&label=CI
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Enforce Script"""
|
|
2
|
+
|
|
3
|
+
from importlib.resources import files as _files
|
|
4
|
+
|
|
5
|
+
from ._binding import language
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _get_query(name, file):
|
|
9
|
+
try:
|
|
10
|
+
query = _files(f"{__package__}") / file
|
|
11
|
+
globals()[name] = query.read_text()
|
|
12
|
+
except FileNotFoundError:
|
|
13
|
+
globals()[name] = None
|
|
14
|
+
return globals()[name]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def __getattr__(name):
|
|
18
|
+
if name == "HIGHLIGHTS_QUERY":
|
|
19
|
+
return _get_query("HIGHLIGHTS_QUERY", "queries/highlights.scm")
|
|
20
|
+
if name == "INJECTIONS_QUERY":
|
|
21
|
+
return _get_query("INJECTIONS_QUERY", "queries/injections.scm")
|
|
22
|
+
if name == "LOCALS_QUERY":
|
|
23
|
+
return _get_query("LOCALS_QUERY", "queries/locals.scm")
|
|
24
|
+
if name == "TAGS_QUERY":
|
|
25
|
+
return _get_query("TAGS_QUERY", "queries/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,17 @@
|
|
|
1
|
+
from typing import Final
|
|
2
|
+
from typing_extensions import CapsuleType
|
|
3
|
+
|
|
4
|
+
HIGHLIGHTS_QUERY: Final[str] | None
|
|
5
|
+
"""The syntax highlighting query for this grammar."""
|
|
6
|
+
|
|
7
|
+
INJECTIONS_QUERY: Final[str] | None
|
|
8
|
+
"""The language injection query for this grammar."""
|
|
9
|
+
|
|
10
|
+
LOCALS_QUERY: Final[str] | None
|
|
11
|
+
"""The local variable query for this grammar."""
|
|
12
|
+
|
|
13
|
+
TAGS_QUERY: Final[str] | None
|
|
14
|
+
"""The symbol tagging query for this grammar."""
|
|
15
|
+
|
|
16
|
+
def language() -> CapsuleType:
|
|
17
|
+
"""The tree-sitter language function for this grammar."""
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_enforce(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_enforce(), "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,70 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-enforce
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Enforce Script
|
|
5
|
+
Author-email: simonvic <simonvic.dev@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/simonvic/tree-sitter-enforce
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,enforce
|
|
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-enforce
|
|
21
|
+
|
|
22
|
+
[![CI][ci]](https://github.com/simonvic/tree-sitter-enforce/actions/workflows/publish.yml)
|
|
23
|
+
|
|
24
|
+
Enforce grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
|
|
25
|
+
|
|
26
|
+
This grammar intends to be a close approximation of the
|
|
27
|
+
[Enforce](https://community.bistudio.com/wiki/DayZ:Enforce_Script_Syntax)
|
|
28
|
+
script "specification".
|
|
29
|
+
|
|
30
|
+
> [!NOTE]
|
|
31
|
+
> We don't have official specification; some opinionated choices may have been
|
|
32
|
+
> taken (e.g. mandatory semicolon terminated statements)
|
|
33
|
+
>
|
|
34
|
+
> Read more about it
|
|
35
|
+
> [here](https://github.com/simonvic/tree-sitter-enforce/issues/7)
|
|
36
|
+
|
|
37
|
+
## Getting started
|
|
38
|
+
|
|
39
|
+
### neovim
|
|
40
|
+
|
|
41
|
+
Neovim doesn't recognize the Enforce filetype, and since it uses `.c` file
|
|
42
|
+
extension, you need to add a custom language filetype; add the following
|
|
43
|
+
somewhere in your `init.lua`
|
|
44
|
+
|
|
45
|
+
```lua
|
|
46
|
+
vim.filetype.add({
|
|
47
|
+
pattern = {
|
|
48
|
+
[".*/scripts/.*/.*%.c"] = "enforce",
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
*The pattern will match all `.c` files in a `scripts/some_module/` directory.
|
|
54
|
+
You may have to modify the pattern to suit your needs.*
|
|
55
|
+
|
|
56
|
+
To install the parser, you can use
|
|
57
|
+
[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) plugin
|
|
58
|
+
and run `:TSInstall enforce`
|
|
59
|
+
|
|
60
|
+
### VSCode
|
|
61
|
+
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> This has not been tested. Use at your own discretion
|
|
64
|
+
|
|
65
|
+
You can use `tree-sitter-vscode` plugin.
|
|
66
|
+
You'll likely need `tree-sitter-enforce.wasm`, which you can find in the
|
|
67
|
+
[releases](https://github.com/simonvic/tree-sitter-enforce/releases)
|
|
68
|
+
or you can clone this repository and build it with tree-sitter
|
|
69
|
+
|
|
70
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/simonvic/tree-sitter-enforce/publish.yml?logo=github&label=CI
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
bindings/python/tree_sitter_enforce/__init__.py
|
|
6
|
+
bindings/python/tree_sitter_enforce/__init__.pyi
|
|
7
|
+
bindings/python/tree_sitter_enforce/binding.c
|
|
8
|
+
bindings/python/tree_sitter_enforce/py.typed
|
|
9
|
+
bindings/python/tree_sitter_enforce.egg-info/PKG-INFO
|
|
10
|
+
bindings/python/tree_sitter_enforce.egg-info/SOURCES.txt
|
|
11
|
+
bindings/python/tree_sitter_enforce.egg-info/dependency_links.txt
|
|
12
|
+
bindings/python/tree_sitter_enforce.egg-info/not-zip-safe
|
|
13
|
+
bindings/python/tree_sitter_enforce.egg-info/requires.txt
|
|
14
|
+
bindings/python/tree_sitter_enforce.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-enforce"
|
|
7
|
+
description = "Enforce Script"
|
|
8
|
+
version = "0.4.0"
|
|
9
|
+
keywords = ["incremental", "parsing", "tree-sitter", "enforce"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Topic :: Software Development :: Compilers",
|
|
13
|
+
"Topic :: Text Processing :: Linguistic",
|
|
14
|
+
"Typing :: Typed",
|
|
15
|
+
]
|
|
16
|
+
authors = [{ name = "simonvic", email = "simonvic.dev@gmail.com" }]
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
license.text = "MIT"
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/simonvic/tree-sitter-enforce"
|
|
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,44 @@
|
|
|
1
|
+
; enums
|
|
2
|
+
(decl_enum
|
|
3
|
+
typename: (identifier) @name
|
|
4
|
+
(#set! "kind" "Enum")) @symbol
|
|
5
|
+
|
|
6
|
+
(enum_member
|
|
7
|
+
name: (identifier) @name
|
|
8
|
+
(#set! "kind" "EnumMember")) @symbol
|
|
9
|
+
|
|
10
|
+
; class
|
|
11
|
+
(decl_class
|
|
12
|
+
typename: (identifier) @name
|
|
13
|
+
(#set! "kind" "Class")) @symbol
|
|
14
|
+
|
|
15
|
+
(typedef
|
|
16
|
+
alias: (identifier) @name
|
|
17
|
+
(#set! "kind" "Class")) @symbol
|
|
18
|
+
|
|
19
|
+
; constructor
|
|
20
|
+
(decl_class
|
|
21
|
+
typename: (identifier) @_typename
|
|
22
|
+
body: (class_body
|
|
23
|
+
(decl_method
|
|
24
|
+
name: (identifier) @name
|
|
25
|
+
(#eq? @name @_typename)
|
|
26
|
+
(#set! "kind" "Constructor")) @symbol))
|
|
27
|
+
|
|
28
|
+
; field
|
|
29
|
+
(decl_field
|
|
30
|
+
((field_modifier) @_modifier
|
|
31
|
+
(#eq? @_modifier "const"))
|
|
32
|
+
type: (_)
|
|
33
|
+
name: (identifier) @name
|
|
34
|
+
(#set! "kind" "Constant")) @symbol
|
|
35
|
+
|
|
36
|
+
(decl_field
|
|
37
|
+
type: (_)
|
|
38
|
+
name: (identifier) @name
|
|
39
|
+
(#set! "kind" "Field")) @symbol
|
|
40
|
+
|
|
41
|
+
; methods
|
|
42
|
+
(decl_method
|
|
43
|
+
name: (identifier) @name
|
|
44
|
+
(#set! "kind" "Method")) @symbol
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(if
|
|
2
|
+
(block) @context.end) @context
|
|
3
|
+
|
|
4
|
+
(decl_method
|
|
5
|
+
body: (_) @context.end) @context
|
|
6
|
+
|
|
7
|
+
(for
|
|
8
|
+
body: (_) @context.end) @context
|
|
9
|
+
|
|
10
|
+
(foreach
|
|
11
|
+
body: (_) @context.end) @context
|
|
12
|
+
|
|
13
|
+
(decl_class
|
|
14
|
+
body: (_) @context.end) @context
|
|
15
|
+
|
|
16
|
+
(decl_enum
|
|
17
|
+
body: (_) @context.end) @context
|
|
18
|
+
|
|
19
|
+
(switch
|
|
20
|
+
body: (_) @context.end) @context
|
|
21
|
+
|
|
22
|
+
(switch_case
|
|
23
|
+
label: (_) @context.end) @context
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
[
|
|
2
|
+
(comment_line)
|
|
3
|
+
(comment_block)
|
|
4
|
+
] @comment @spell
|
|
5
|
+
|
|
6
|
+
[
|
|
7
|
+
(doc_line)
|
|
8
|
+
(doc_block)
|
|
9
|
+
] @comment.documentation @spell
|
|
10
|
+
|
|
11
|
+
(literal_bool) @boolean
|
|
12
|
+
|
|
13
|
+
(literal_int) @number
|
|
14
|
+
|
|
15
|
+
(literal_float) @number.float
|
|
16
|
+
|
|
17
|
+
(literal_string) @string
|
|
18
|
+
|
|
19
|
+
(escape_sequence) @string.escape
|
|
20
|
+
|
|
21
|
+
(identifier) @variable
|
|
22
|
+
|
|
23
|
+
(formal_parameter
|
|
24
|
+
name: (identifier) @variable.parameter)
|
|
25
|
+
|
|
26
|
+
((identifier) @constant
|
|
27
|
+
(#lua-match? @constant "^[A-Z_][A-Z%d_]+$"))
|
|
28
|
+
|
|
29
|
+
; Preprocessor directives
|
|
30
|
+
[
|
|
31
|
+
"#include"
|
|
32
|
+
"#define"
|
|
33
|
+
"#ifdef"
|
|
34
|
+
"#ifndef"
|
|
35
|
+
(preproc_else)
|
|
36
|
+
(preproc_endif)
|
|
37
|
+
] @keyword.directive
|
|
38
|
+
|
|
39
|
+
(preproc_const) @constant.macro
|
|
40
|
+
|
|
41
|
+
; Constant fields
|
|
42
|
+
(decl_field
|
|
43
|
+
((field_modifier) @_modifier
|
|
44
|
+
(#eq? @_modifier "const"))
|
|
45
|
+
type: (_)
|
|
46
|
+
name: (identifier) @constant)
|
|
47
|
+
|
|
48
|
+
(enum_member
|
|
49
|
+
name: (identifier) @constant)
|
|
50
|
+
|
|
51
|
+
[
|
|
52
|
+
"+"
|
|
53
|
+
"-"
|
|
54
|
+
"*"
|
|
55
|
+
"/"
|
|
56
|
+
"%"
|
|
57
|
+
"^"
|
|
58
|
+
"++"
|
|
59
|
+
"--"
|
|
60
|
+
"="
|
|
61
|
+
"+="
|
|
62
|
+
"-="
|
|
63
|
+
"*="
|
|
64
|
+
"/="
|
|
65
|
+
"&="
|
|
66
|
+
"^="
|
|
67
|
+
"|="
|
|
68
|
+
"<<="
|
|
69
|
+
">>="
|
|
70
|
+
"<"
|
|
71
|
+
"<="
|
|
72
|
+
">="
|
|
73
|
+
">"
|
|
74
|
+
"=="
|
|
75
|
+
"!="
|
|
76
|
+
"!"
|
|
77
|
+
"&&"
|
|
78
|
+
"||"
|
|
79
|
+
">>"
|
|
80
|
+
"<<"
|
|
81
|
+
"&"
|
|
82
|
+
"|"
|
|
83
|
+
"^"
|
|
84
|
+
"~"
|
|
85
|
+
] @operator
|
|
86
|
+
|
|
87
|
+
[
|
|
88
|
+
"("
|
|
89
|
+
")"
|
|
90
|
+
"["
|
|
91
|
+
"]"
|
|
92
|
+
"{"
|
|
93
|
+
"}"
|
|
94
|
+
] @punctuation.bracket
|
|
95
|
+
|
|
96
|
+
(type_parameters
|
|
97
|
+
[
|
|
98
|
+
"<"
|
|
99
|
+
">"
|
|
100
|
+
] @punctuation.bracket)
|
|
101
|
+
|
|
102
|
+
(types
|
|
103
|
+
[
|
|
104
|
+
"<"
|
|
105
|
+
">"
|
|
106
|
+
] @punctuation.bracket)
|
|
107
|
+
|
|
108
|
+
[
|
|
109
|
+
","
|
|
110
|
+
"."
|
|
111
|
+
":"
|
|
112
|
+
";"
|
|
113
|
+
] @punctuation.delimiter
|
|
114
|
+
|
|
115
|
+
[
|
|
116
|
+
"default"
|
|
117
|
+
"extends"
|
|
118
|
+
] @keyword
|
|
119
|
+
|
|
120
|
+
[
|
|
121
|
+
"new"
|
|
122
|
+
"delete"
|
|
123
|
+
] @keyword.operator
|
|
124
|
+
|
|
125
|
+
"return" @keyword.return
|
|
126
|
+
|
|
127
|
+
[
|
|
128
|
+
"if"
|
|
129
|
+
"else"
|
|
130
|
+
"switch"
|
|
131
|
+
"case"
|
|
132
|
+
] @keyword.conditional
|
|
133
|
+
|
|
134
|
+
[
|
|
135
|
+
"while"
|
|
136
|
+
"for"
|
|
137
|
+
"foreach"
|
|
138
|
+
"continue"
|
|
139
|
+
"break"
|
|
140
|
+
] @keyword.repeat
|
|
141
|
+
|
|
142
|
+
[
|
|
143
|
+
"enum"
|
|
144
|
+
"class"
|
|
145
|
+
"typedef"
|
|
146
|
+
] @keyword.type
|
|
147
|
+
|
|
148
|
+
[
|
|
149
|
+
(variable_modifier)
|
|
150
|
+
(method_modifier)
|
|
151
|
+
(class_modifier)
|
|
152
|
+
(field_modifier)
|
|
153
|
+
(formal_parameter_modifier)
|
|
154
|
+
] @keyword.modifier
|
|
155
|
+
|
|
156
|
+
"ref" @type
|
|
157
|
+
|
|
158
|
+
(decl_class
|
|
159
|
+
typename: (identifier) @type)
|
|
160
|
+
|
|
161
|
+
(decl_class
|
|
162
|
+
superclass: (superclass
|
|
163
|
+
typename: (identifier) @type))
|
|
164
|
+
|
|
165
|
+
(decl_enum
|
|
166
|
+
typename: (identifier) @type)
|
|
167
|
+
|
|
168
|
+
(type_identifier
|
|
169
|
+
(identifier) @type)
|
|
170
|
+
|
|
171
|
+
[
|
|
172
|
+
"auto"
|
|
173
|
+
(type_primitive)
|
|
174
|
+
] @type.builtin
|
|
175
|
+
|
|
176
|
+
[
|
|
177
|
+
(super)
|
|
178
|
+
(this)
|
|
179
|
+
] @variable.builtin
|
|
180
|
+
|
|
181
|
+
(literal_null) @constant.builtin
|
|
182
|
+
|
|
183
|
+
(decl_method
|
|
184
|
+
name: (identifier) @function.method)
|
|
185
|
+
|
|
186
|
+
(invokation
|
|
187
|
+
invoked: (identifier) @function.method.call)
|
|
188
|
+
|
|
189
|
+
; Constructor and deconstructor (function with same name of the class)
|
|
190
|
+
(decl_class
|
|
191
|
+
typename: (identifier) @_classname
|
|
192
|
+
body: (class_body
|
|
193
|
+
(decl_method
|
|
194
|
+
name: (identifier) @constructor
|
|
195
|
+
(#eq? @constructor @_classname))))
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[
|
|
2
|
+
(block)
|
|
3
|
+
(class_body)
|
|
4
|
+
(enum_body)
|
|
5
|
+
(switch_body)
|
|
6
|
+
(array_creation)
|
|
7
|
+
(formal_parameters)
|
|
8
|
+
(actual_parameters)
|
|
9
|
+
] @indent.begin
|
|
10
|
+
|
|
11
|
+
[
|
|
12
|
+
"("
|
|
13
|
+
")"
|
|
14
|
+
"}"
|
|
15
|
+
] @indent.branch
|
|
16
|
+
|
|
17
|
+
[
|
|
18
|
+
")"
|
|
19
|
+
"}"
|
|
20
|
+
] @indent.end
|
|
21
|
+
|
|
22
|
+
(if
|
|
23
|
+
condition: (_) @indent.begin)
|
|
24
|
+
|
|
25
|
+
; Supports if without braces (but not both if-else without braces)
|
|
26
|
+
(if
|
|
27
|
+
consequence: (_) @indent.end @_consequence
|
|
28
|
+
(#not-kind-eq? @_consequence "block")
|
|
29
|
+
("else" @indent.branch
|
|
30
|
+
[
|
|
31
|
+
(if
|
|
32
|
+
(block) @indent.dedent)? @indent.dedent
|
|
33
|
+
(block)? @indent.dedent
|
|
34
|
+
(_)? @indent.dedent
|
|
35
|
+
])?) @indent.begin
|
|
36
|
+
|
|
37
|
+
(comment_line) @indent.ignore
|
|
38
|
+
|
|
39
|
+
[
|
|
40
|
+
(ERROR)
|
|
41
|
+
(comment_block)
|
|
42
|
+
] @indent.auto
|