tree-sitter-mlua 0.1.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_mlua-0.1.0/LICENSE.md +21 -0
- tree_sitter_mlua-0.1.0/PKG-INFO +52 -0
- tree_sitter_mlua-0.1.0/README.md +32 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua/__init__.py +43 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua/__init__.pyi +9 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua/binding.c +35 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua/py.typed +0 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua.egg-info/PKG-INFO +52 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua.egg-info/SOURCES.txt +15 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua.egg-info/dependency_links.txt +1 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua.egg-info/not-zip-safe +1 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua.egg-info/requires.txt +3 -0
- tree_sitter_mlua-0.1.0/bindings/python/tree_sitter_mlua.egg-info/top_level.txt +2 -0
- tree_sitter_mlua-0.1.0/pyproject.toml +32 -0
- tree_sitter_mlua-0.1.0/queries/highlights.scm +86 -0
- tree_sitter_mlua-0.1.0/queries/injections.scm +4 -0
- tree_sitter_mlua-0.1.0/queries/locals.scm +46 -0
- tree_sitter_mlua-0.1.0/queries/tags.scm +32 -0
- tree_sitter_mlua-0.1.0/setup.cfg +4 -0
- tree_sitter_mlua-0.1.0/setup.py +77 -0
- tree_sitter_mlua-0.1.0/src/parser.c +18736 -0
- tree_sitter_mlua-0.1.0/src/tree_sitter/alloc.h +54 -0
- tree_sitter_mlua-0.1.0/src/tree_sitter/array.h +336 -0
- tree_sitter_mlua-0.1.0/src/tree_sitter/parser.h +286 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Munif Tanjim
|
|
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,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-mlua
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MapleStory Worlds .mlua grammar for tree-sitter
|
|
5
|
+
Author: taerim0
|
|
6
|
+
Author-email: Munif Tanjim <hello@muniftanjim.dev>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/taerim0/tree-sitter-mlua
|
|
9
|
+
Keywords: incremental,parsing,tree-sitter,mlua
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
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.md
|
|
17
|
+
Provides-Extra: core
|
|
18
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# tree-sitter-mlua
|
|
22
|
+
|
|
23
|
+
[![CI][ci]](https://github.com/taerim0/tree-sitter-mlua/actions/workflows/ci.yml)
|
|
24
|
+
|
|
25
|
+
Tree-sitter grammar for **MapleStory Worlds' `.mlua` script/interface format**.
|
|
26
|
+
|
|
27
|
+
`.mlua` is a class-based DSL layered on top of a Lua-like expression/statement
|
|
28
|
+
language: the top level is one `script Name [extends Base] ... end`
|
|
29
|
+
declaration containing `property`/`method`/`member`/`emitter`/`handler`/
|
|
30
|
+
`constructor`/`operator` members (each optionally preceded by `@Decorator`
|
|
31
|
+
annotations), and method **bodies** are ordinary Lua statements/expressions.
|
|
32
|
+
`.d.mlua` files (native-API declarations, no method bodies) parse with the
|
|
33
|
+
same grammar.
|
|
34
|
+
|
|
35
|
+
There was no public tree-sitter grammar for this format anywhere at the time
|
|
36
|
+
this was written — confirmed by inspecting real MapleStory Worlds project
|
|
37
|
+
`.mlua` files directly, not assumed from documentation alone.
|
|
38
|
+
|
|
39
|
+
## Acknowledgement
|
|
40
|
+
|
|
41
|
+
This grammar is forked from [tree-sitter-grammars/tree-sitter-lua][ts-lua]
|
|
42
|
+
(MIT licensed, by Munif Tanjim) — `.mlua` method bodies are real Lua, so the
|
|
43
|
+
statement/expression/string/comment/number rules and the external scanner are
|
|
44
|
+
reused near-verbatim from that project rather than re-derived from scratch.
|
|
45
|
+
Only the top-level rules (`chunk`, `script`/`property`/`method`/`member`/
|
|
46
|
+
`emitter`/`handler`/`constructor`/`operator` declarations, decorators, and the
|
|
47
|
+
`type` rule for property/parameter/return types, including generics like
|
|
48
|
+
`List<Vector2>`) are new.
|
|
49
|
+
|
|
50
|
+
[ts-lua]: https://github.com/tree-sitter-grammars/tree-sitter-lua
|
|
51
|
+
|
|
52
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/taerim0/tree-sitter-mlua/ci.yml?logo=github&label=CI
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# tree-sitter-mlua
|
|
2
|
+
|
|
3
|
+
[![CI][ci]](https://github.com/taerim0/tree-sitter-mlua/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
Tree-sitter grammar for **MapleStory Worlds' `.mlua` script/interface format**.
|
|
6
|
+
|
|
7
|
+
`.mlua` is a class-based DSL layered on top of a Lua-like expression/statement
|
|
8
|
+
language: the top level is one `script Name [extends Base] ... end`
|
|
9
|
+
declaration containing `property`/`method`/`member`/`emitter`/`handler`/
|
|
10
|
+
`constructor`/`operator` members (each optionally preceded by `@Decorator`
|
|
11
|
+
annotations), and method **bodies** are ordinary Lua statements/expressions.
|
|
12
|
+
`.d.mlua` files (native-API declarations, no method bodies) parse with the
|
|
13
|
+
same grammar.
|
|
14
|
+
|
|
15
|
+
There was no public tree-sitter grammar for this format anywhere at the time
|
|
16
|
+
this was written — confirmed by inspecting real MapleStory Worlds project
|
|
17
|
+
`.mlua` files directly, not assumed from documentation alone.
|
|
18
|
+
|
|
19
|
+
## Acknowledgement
|
|
20
|
+
|
|
21
|
+
This grammar is forked from [tree-sitter-grammars/tree-sitter-lua][ts-lua]
|
|
22
|
+
(MIT licensed, by Munif Tanjim) — `.mlua` method bodies are real Lua, so the
|
|
23
|
+
statement/expression/string/comment/number rules and the external scanner are
|
|
24
|
+
reused near-verbatim from that project rather than re-derived from scratch.
|
|
25
|
+
Only the top-level rules (`chunk`, `script`/`property`/`method`/`member`/
|
|
26
|
+
`emitter`/`handler`/`constructor`/`operator` declarations, decorators, and the
|
|
27
|
+
`type` rule for property/parameter/return types, including generics like
|
|
28
|
+
`List<Vector2>`) are new.
|
|
29
|
+
|
|
30
|
+
[ts-lua]: https://github.com/tree-sitter-grammars/tree-sitter-lua
|
|
31
|
+
|
|
32
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/taerim0/tree-sitter-mlua/ci.yml?logo=github&label=CI
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""MapleStory Worlds .mlua 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
|
+
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,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_mlua(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_mlua(), "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,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-mlua
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MapleStory Worlds .mlua grammar for tree-sitter
|
|
5
|
+
Author: taerim0
|
|
6
|
+
Author-email: Munif Tanjim <hello@muniftanjim.dev>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/taerim0/tree-sitter-mlua
|
|
9
|
+
Keywords: incremental,parsing,tree-sitter,mlua
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
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.md
|
|
17
|
+
Provides-Extra: core
|
|
18
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# tree-sitter-mlua
|
|
22
|
+
|
|
23
|
+
[![CI][ci]](https://github.com/taerim0/tree-sitter-mlua/actions/workflows/ci.yml)
|
|
24
|
+
|
|
25
|
+
Tree-sitter grammar for **MapleStory Worlds' `.mlua` script/interface format**.
|
|
26
|
+
|
|
27
|
+
`.mlua` is a class-based DSL layered on top of a Lua-like expression/statement
|
|
28
|
+
language: the top level is one `script Name [extends Base] ... end`
|
|
29
|
+
declaration containing `property`/`method`/`member`/`emitter`/`handler`/
|
|
30
|
+
`constructor`/`operator` members (each optionally preceded by `@Decorator`
|
|
31
|
+
annotations), and method **bodies** are ordinary Lua statements/expressions.
|
|
32
|
+
`.d.mlua` files (native-API declarations, no method bodies) parse with the
|
|
33
|
+
same grammar.
|
|
34
|
+
|
|
35
|
+
There was no public tree-sitter grammar for this format anywhere at the time
|
|
36
|
+
this was written — confirmed by inspecting real MapleStory Worlds project
|
|
37
|
+
`.mlua` files directly, not assumed from documentation alone.
|
|
38
|
+
|
|
39
|
+
## Acknowledgement
|
|
40
|
+
|
|
41
|
+
This grammar is forked from [tree-sitter-grammars/tree-sitter-lua][ts-lua]
|
|
42
|
+
(MIT licensed, by Munif Tanjim) — `.mlua` method bodies are real Lua, so the
|
|
43
|
+
statement/expression/string/comment/number rules and the external scanner are
|
|
44
|
+
reused near-verbatim from that project rather than re-derived from scratch.
|
|
45
|
+
Only the top-level rules (`chunk`, `script`/`property`/`method`/`member`/
|
|
46
|
+
`emitter`/`handler`/`constructor`/`operator` declarations, decorators, and the
|
|
47
|
+
`type` rule for property/parameter/return types, including generics like
|
|
48
|
+
`List<Vector2>`) are new.
|
|
49
|
+
|
|
50
|
+
[ts-lua]: https://github.com/tree-sitter-grammars/tree-sitter-lua
|
|
51
|
+
|
|
52
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/taerim0/tree-sitter-mlua/ci.yml?logo=github&label=CI
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE.md
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
bindings/python/tree_sitter_mlua/__init__.py
|
|
6
|
+
bindings/python/tree_sitter_mlua/__init__.pyi
|
|
7
|
+
bindings/python/tree_sitter_mlua/binding.c
|
|
8
|
+
bindings/python/tree_sitter_mlua/py.typed
|
|
9
|
+
bindings/python/tree_sitter_mlua.egg-info/PKG-INFO
|
|
10
|
+
bindings/python/tree_sitter_mlua.egg-info/SOURCES.txt
|
|
11
|
+
bindings/python/tree_sitter_mlua.egg-info/dependency_links.txt
|
|
12
|
+
bindings/python/tree_sitter_mlua.egg-info/not-zip-safe
|
|
13
|
+
bindings/python/tree_sitter_mlua.egg-info/requires.txt
|
|
14
|
+
bindings/python/tree_sitter_mlua.egg-info/top_level.txt
|
|
15
|
+
src/parser.c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tree-sitter-mlua"
|
|
7
|
+
description = "MapleStory Worlds .mlua grammar for tree-sitter"
|
|
8
|
+
version = "0.1.0"
|
|
9
|
+
keywords = ["incremental", "parsing", "tree-sitter", "mlua"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Topic :: Software Development :: Compilers",
|
|
13
|
+
"Topic :: Text Processing :: Linguistic",
|
|
14
|
+
"Typing :: Typed",
|
|
15
|
+
]
|
|
16
|
+
authors = [
|
|
17
|
+
{ name = "taerim0" },
|
|
18
|
+
{ name = "Munif Tanjim", email = "hello@muniftanjim.dev" },
|
|
19
|
+
]
|
|
20
|
+
requires-python = ">=3.10"
|
|
21
|
+
license.text = "MIT"
|
|
22
|
+
readme = "README.md"
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/taerim0/tree-sitter-mlua"
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
core = ["tree-sitter~=0.24"]
|
|
29
|
+
|
|
30
|
+
[tool.cibuildwheel]
|
|
31
|
+
build = "cp310-*"
|
|
32
|
+
build-frontend = "build"
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
; Keywords
|
|
2
|
+
|
|
3
|
+
[
|
|
4
|
+
"script"
|
|
5
|
+
"extends"
|
|
6
|
+
"end"
|
|
7
|
+
"property"
|
|
8
|
+
"member"
|
|
9
|
+
"constructor"
|
|
10
|
+
"operator"
|
|
11
|
+
"static"
|
|
12
|
+
"readonly"
|
|
13
|
+
] @keyword
|
|
14
|
+
|
|
15
|
+
["method" "emitter" "handler" "function" "local"] @keyword.function
|
|
16
|
+
|
|
17
|
+
"return" @keyword.return
|
|
18
|
+
|
|
19
|
+
[(break_statement) (continue_statement)] @keyword
|
|
20
|
+
"goto" @keyword
|
|
21
|
+
|
|
22
|
+
(label_statement) @label
|
|
23
|
+
|
|
24
|
+
["if" "then" "elseif" "else"] @keyword.conditional
|
|
25
|
+
|
|
26
|
+
["while" "repeat" "until" "for" "in" "do"] @keyword.repeat
|
|
27
|
+
|
|
28
|
+
"@" @punctuation.special
|
|
29
|
+
|
|
30
|
+
; Types
|
|
31
|
+
|
|
32
|
+
(type name: (identifier) @type)
|
|
33
|
+
(script_declaration name: (identifier) @type)
|
|
34
|
+
|
|
35
|
+
; Declarations
|
|
36
|
+
|
|
37
|
+
(decorator name: (identifier) @attribute)
|
|
38
|
+
(property_declaration name: (identifier) @property)
|
|
39
|
+
(member_declaration name: (identifier) @constant)
|
|
40
|
+
(method_declaration name: (identifier) @function.method)
|
|
41
|
+
(constructor_declaration name: (identifier) @constructor)
|
|
42
|
+
(operator_declaration name: (identifier) @function.method)
|
|
43
|
+
(emitter_declaration name: (identifier) @function.method)
|
|
44
|
+
(handler_declaration name: (identifier) @function.method)
|
|
45
|
+
(parameter name: (identifier) @variable.parameter)
|
|
46
|
+
|
|
47
|
+
(call
|
|
48
|
+
function: (variable name: (identifier) @function.call))
|
|
49
|
+
(call
|
|
50
|
+
function: (variable field: (identifier) @function.method.call))
|
|
51
|
+
|
|
52
|
+
; Variables
|
|
53
|
+
|
|
54
|
+
((identifier) @variable.builtin
|
|
55
|
+
(#eq? @variable.builtin "self"))
|
|
56
|
+
|
|
57
|
+
((identifier) @constant
|
|
58
|
+
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
|
59
|
+
|
|
60
|
+
(identifier) @variable
|
|
61
|
+
|
|
62
|
+
(variable
|
|
63
|
+
field: (identifier) @field)
|
|
64
|
+
|
|
65
|
+
; Operators and punctuation
|
|
66
|
+
|
|
67
|
+
(binary_expression operator: _ @operator)
|
|
68
|
+
(unary_expression operator: _ @operator)
|
|
69
|
+
(compound_assignment_statement operator: _ @operator)
|
|
70
|
+
|
|
71
|
+
"=" @operator
|
|
72
|
+
|
|
73
|
+
["and" "or" "not"] @keyword.operator
|
|
74
|
+
|
|
75
|
+
[";" ":" "," "." "::"] @punctuation.delimiter
|
|
76
|
+
|
|
77
|
+
["(" ")" "[" "]" "{" "}" "<" ">"] @punctuation.bracket
|
|
78
|
+
|
|
79
|
+
; Literals
|
|
80
|
+
|
|
81
|
+
(number) @number
|
|
82
|
+
(string) @string
|
|
83
|
+
(comment) @comment
|
|
84
|
+
[(true) (false)] @boolean
|
|
85
|
+
(nil) @constant.builtin
|
|
86
|
+
(vararg_expression) @constant
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
; Scopes
|
|
2
|
+
[
|
|
3
|
+
(chunk)
|
|
4
|
+
(script_declaration)
|
|
5
|
+
(do_statement)
|
|
6
|
+
(while_statement)
|
|
7
|
+
(repeat_statement)
|
|
8
|
+
(if_statement)
|
|
9
|
+
(for_numeric_statement)
|
|
10
|
+
(for_generic_statement)
|
|
11
|
+
(method_declaration)
|
|
12
|
+
(constructor_declaration)
|
|
13
|
+
(operator_declaration)
|
|
14
|
+
(emitter_declaration)
|
|
15
|
+
(handler_declaration)
|
|
16
|
+
(function_definition)
|
|
17
|
+
(function_definition_statement)
|
|
18
|
+
(local_function_definition_statement)
|
|
19
|
+
] @local.scope
|
|
20
|
+
|
|
21
|
+
; Definitions
|
|
22
|
+
(local_variable_declaration
|
|
23
|
+
(variable_list
|
|
24
|
+
(variable name: (identifier) @local.definition)))
|
|
25
|
+
|
|
26
|
+
(for_generic_statement
|
|
27
|
+
left: (variable_list
|
|
28
|
+
(identifier) @local.definition))
|
|
29
|
+
|
|
30
|
+
(for_numeric_statement
|
|
31
|
+
name: (identifier) @local.definition)
|
|
32
|
+
|
|
33
|
+
(parameter
|
|
34
|
+
name: (identifier) @local.definition)
|
|
35
|
+
|
|
36
|
+
(property_declaration
|
|
37
|
+
name: (identifier) @local.definition)
|
|
38
|
+
|
|
39
|
+
(method_declaration
|
|
40
|
+
name: (identifier) @local.definition)
|
|
41
|
+
|
|
42
|
+
(constructor_declaration
|
|
43
|
+
name: (identifier) @local.definition)
|
|
44
|
+
|
|
45
|
+
; References
|
|
46
|
+
(identifier) @local.reference
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(script_declaration
|
|
2
|
+
name: (identifier) @name) @definition.class
|
|
3
|
+
|
|
4
|
+
(method_declaration
|
|
5
|
+
name: (identifier) @name) @definition.method
|
|
6
|
+
|
|
7
|
+
(constructor_declaration
|
|
8
|
+
name: (identifier) @name) @definition.method
|
|
9
|
+
|
|
10
|
+
(operator_declaration
|
|
11
|
+
name: (identifier) @name) @definition.method
|
|
12
|
+
|
|
13
|
+
(emitter_declaration
|
|
14
|
+
name: (identifier) @name) @definition.method
|
|
15
|
+
|
|
16
|
+
(handler_declaration
|
|
17
|
+
name: (identifier) @name) @definition.method
|
|
18
|
+
|
|
19
|
+
(function_definition_statement
|
|
20
|
+
name: (identifier) @name) @definition.function
|
|
21
|
+
|
|
22
|
+
(local_function_definition_statement
|
|
23
|
+
name: (identifier) @name) @definition.function
|
|
24
|
+
|
|
25
|
+
(property_declaration
|
|
26
|
+
name: (identifier) @name) @definition.property
|
|
27
|
+
|
|
28
|
+
(member_declaration
|
|
29
|
+
name: (identifier) @name) @definition.constant
|
|
30
|
+
|
|
31
|
+
(call
|
|
32
|
+
function: (variable name: (identifier) @name)) @reference.call
|
|
@@ -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_mlua", "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") and not get_config_var("Py_GIL_DISABLED"):
|
|
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_mlua": ["*.pyi", "py.typed"],
|
|
52
|
+
"tree_sitter_mlua.queries": ["*.scm"],
|
|
53
|
+
},
|
|
54
|
+
ext_package="tree_sitter_mlua",
|
|
55
|
+
ext_modules=[
|
|
56
|
+
Extension(
|
|
57
|
+
name="_binding",
|
|
58
|
+
sources=[
|
|
59
|
+
"bindings/python/tree_sitter_mlua/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
|
+
)
|