tree-sitter-matlab 1.2.9__cp310-abi3-musllinux_1_2_i686.whl
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_matlab/__init__.py +42 -0
- tree_sitter_matlab/__init__.pyi +10 -0
- tree_sitter_matlab/_binding.abi3.so +0 -0
- tree_sitter_matlab/binding.c +35 -0
- tree_sitter_matlab/py.typed +0 -0
- tree_sitter_matlab/queries/emacs/highlights.scm +176 -0
- tree_sitter_matlab/queries/emacs/textobjects.scm +93 -0
- tree_sitter_matlab/queries/helix/context.scm +41 -0
- tree_sitter_matlab/queries/helix/folds.scm +11 -0
- tree_sitter_matlab/queries/helix/highlights.scm +127 -0
- tree_sitter_matlab/queries/helix/indents.scm +24 -0
- tree_sitter_matlab/queries/helix/injections.scm +2 -0
- tree_sitter_matlab/queries/helix/locals.scm +19 -0
- tree_sitter_matlab/queries/helix/textobjects.scm +9 -0
- tree_sitter_matlab/queries/neovim/context.scm +41 -0
- tree_sitter_matlab/queries/neovim/folds.scm +11 -0
- tree_sitter_matlab/queries/neovim/highlights.scm +157 -0
- tree_sitter_matlab/queries/neovim/indents.scm +36 -0
- tree_sitter_matlab/queries/neovim/injections.scm +1 -0
- tree_sitter_matlab/queries/neovim/locals.scm +20 -0
- tree_sitter_matlab/queries/neovim/tags.scm +10 -0
- tree_sitter_matlab/queries/neovim/textobjects.scm +110 -0
- tree_sitter_matlab-1.2.9.dist-info/METADATA +94 -0
- tree_sitter_matlab-1.2.9.dist-info/RECORD +27 -0
- tree_sitter_matlab-1.2.9.dist-info/WHEEL +5 -0
- tree_sitter_matlab-1.2.9.dist-info/licenses/LICENSE +19 -0
- tree_sitter_matlab-1.2.9.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""MATLAB tree-sitter parser"""
|
|
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: ...
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_matlab(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_matlab(), "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,176 @@
|
|
|
1
|
+
; attribute
|
|
2
|
+
; comment
|
|
3
|
+
; constant
|
|
4
|
+
; constant.builtin
|
|
5
|
+
; constructor
|
|
6
|
+
; doc
|
|
7
|
+
; embedded
|
|
8
|
+
; escape
|
|
9
|
+
; function
|
|
10
|
+
; function.builtin
|
|
11
|
+
; function.call
|
|
12
|
+
; function.macro
|
|
13
|
+
; function.special
|
|
14
|
+
; keyword
|
|
15
|
+
; label
|
|
16
|
+
; method
|
|
17
|
+
; method.call
|
|
18
|
+
; number
|
|
19
|
+
; operator
|
|
20
|
+
; property
|
|
21
|
+
; property.definition
|
|
22
|
+
; punctuation
|
|
23
|
+
; punctuation.bracket
|
|
24
|
+
; punctuation.delimiter
|
|
25
|
+
; punctuation.special
|
|
26
|
+
; string
|
|
27
|
+
; string.special
|
|
28
|
+
; tag
|
|
29
|
+
; type
|
|
30
|
+
; type.argument
|
|
31
|
+
; type.builtin
|
|
32
|
+
; type.parameter
|
|
33
|
+
; type.super
|
|
34
|
+
; variable
|
|
35
|
+
; variable.builtin
|
|
36
|
+
; variable.parameter
|
|
37
|
+
; variable.special
|
|
38
|
+
|
|
39
|
+
; Errors
|
|
40
|
+
|
|
41
|
+
(ERROR) @error
|
|
42
|
+
|
|
43
|
+
; Constants
|
|
44
|
+
|
|
45
|
+
(events (identifier) @constant)
|
|
46
|
+
(attribute (identifier) @constant)
|
|
47
|
+
|
|
48
|
+
"~" @constant.builtin
|
|
49
|
+
|
|
50
|
+
; Fields/Properties
|
|
51
|
+
|
|
52
|
+
(field_expression field: (identifier) @property)
|
|
53
|
+
(superclass "." (identifier) @property)
|
|
54
|
+
(property_name "." (identifier) @property)
|
|
55
|
+
(property name: (identifier) @property)
|
|
56
|
+
|
|
57
|
+
; Types
|
|
58
|
+
|
|
59
|
+
(class_definition name: (identifier) @type)
|
|
60
|
+
(attributes (identifier) @constant)
|
|
61
|
+
(enum . (identifier) @type)
|
|
62
|
+
|
|
63
|
+
; Functions
|
|
64
|
+
|
|
65
|
+
(function_definition
|
|
66
|
+
"function" @keyword
|
|
67
|
+
name: (identifier) @function
|
|
68
|
+
[ "end" "endfunction" ]? @keyword)
|
|
69
|
+
|
|
70
|
+
(function_signature name: (identifier) @function)
|
|
71
|
+
|
|
72
|
+
(function_call name: (identifier) @function.call)
|
|
73
|
+
|
|
74
|
+
(handle_operator (identifier) @function)
|
|
75
|
+
(validation_functions (identifier) @function)
|
|
76
|
+
|
|
77
|
+
(command (command_name) @function.macro)
|
|
78
|
+
(command_argument) @string
|
|
79
|
+
|
|
80
|
+
(return_statement) @keyword
|
|
81
|
+
|
|
82
|
+
; Parameters
|
|
83
|
+
|
|
84
|
+
(lambda (arguments (identifier) @variable.parameter))
|
|
85
|
+
(function_arguments (identifier) @variable.parameter)
|
|
86
|
+
|
|
87
|
+
; Conditionals
|
|
88
|
+
|
|
89
|
+
(if_statement [ "if" "end" ] @keyword)
|
|
90
|
+
(elseif_clause "elseif" @keyword)
|
|
91
|
+
(else_clause "else" @keyword)
|
|
92
|
+
(switch_statement [ "switch" "end" ] @keyword)
|
|
93
|
+
(case_clause "case" @keyword)
|
|
94
|
+
(otherwise_clause "otherwise" @keyword)
|
|
95
|
+
(break_statement) @keyword
|
|
96
|
+
|
|
97
|
+
; Repeats
|
|
98
|
+
|
|
99
|
+
(for_statement [ "for" "parfor" "end" ] @keyword)
|
|
100
|
+
(while_statement [ "while" "end" ] @keyword)
|
|
101
|
+
(continue_statement) @keyword
|
|
102
|
+
|
|
103
|
+
; Exceptions
|
|
104
|
+
|
|
105
|
+
(try_statement [ "try" "end" ] @keyword)
|
|
106
|
+
(catch_clause "catch" @keyword)
|
|
107
|
+
|
|
108
|
+
; Punctuation
|
|
109
|
+
|
|
110
|
+
[ ";" "," "." ] @punctuation.delimiter
|
|
111
|
+
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
|
|
112
|
+
|
|
113
|
+
; Literals
|
|
114
|
+
|
|
115
|
+
(escape_sequence) @escape
|
|
116
|
+
(formatting_sequence) @escape
|
|
117
|
+
(string) @string
|
|
118
|
+
(number) @number
|
|
119
|
+
|
|
120
|
+
; Comments
|
|
121
|
+
|
|
122
|
+
[ (comment) (line_continuation) ] @comment @spell
|
|
123
|
+
|
|
124
|
+
; Operators
|
|
125
|
+
|
|
126
|
+
(unary_operator ["+" "-"] @number)
|
|
127
|
+
|
|
128
|
+
[
|
|
129
|
+
"+"
|
|
130
|
+
".+"
|
|
131
|
+
"-"
|
|
132
|
+
".*"
|
|
133
|
+
"*"
|
|
134
|
+
".*"
|
|
135
|
+
"/"
|
|
136
|
+
"./"
|
|
137
|
+
"\\"
|
|
138
|
+
".\\"
|
|
139
|
+
"^"
|
|
140
|
+
".^"
|
|
141
|
+
"'"
|
|
142
|
+
".'"
|
|
143
|
+
"|"
|
|
144
|
+
"&"
|
|
145
|
+
"?"
|
|
146
|
+
"@"
|
|
147
|
+
"<"
|
|
148
|
+
"<="
|
|
149
|
+
">"
|
|
150
|
+
">="
|
|
151
|
+
"=="
|
|
152
|
+
"~="
|
|
153
|
+
"="
|
|
154
|
+
"&&"
|
|
155
|
+
"||"
|
|
156
|
+
":"
|
|
157
|
+
] @operator
|
|
158
|
+
|
|
159
|
+
; Assignments
|
|
160
|
+
|
|
161
|
+
(assignment left: (_) @variable)
|
|
162
|
+
(multioutput_variable (_) @variable)
|
|
163
|
+
|
|
164
|
+
; Keywords
|
|
165
|
+
|
|
166
|
+
[
|
|
167
|
+
"arguments"
|
|
168
|
+
"classdef"
|
|
169
|
+
"end"
|
|
170
|
+
"enumeration"
|
|
171
|
+
"events"
|
|
172
|
+
"global"
|
|
173
|
+
"methods"
|
|
174
|
+
"persistent"
|
|
175
|
+
"properties"
|
|
176
|
+
] @keyword
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
(_ (block) @block.inner) @block.outer
|
|
2
|
+
(block (_) @statement.outer)
|
|
3
|
+
(source_file (_) @statement.outer)
|
|
4
|
+
|
|
5
|
+
(function_call
|
|
6
|
+
(arguments)? @call.inner) @call.outer
|
|
7
|
+
((arguments ","? @parameter.outer._start . (_) @parameter.outer._end @parameter.inner . ))
|
|
8
|
+
((arguments (_) @parameter.outer._start @parameter.inner . "," @parameter.outer._end))
|
|
9
|
+
|
|
10
|
+
(command) @call.outer
|
|
11
|
+
(command (command_argument) @parameter.inner @parameter.outer)
|
|
12
|
+
(command
|
|
13
|
+
(command_argument) @call.inner._start (command_argument)* @call.inner._end .)
|
|
14
|
+
|
|
15
|
+
(if_statement
|
|
16
|
+
(block) @conditional.inner) @conditional.outer
|
|
17
|
+
(if_statement
|
|
18
|
+
(elseif_clause
|
|
19
|
+
(block) @conditional.inner))
|
|
20
|
+
(if_statement
|
|
21
|
+
(else_clause
|
|
22
|
+
(block) @conditional.inner))
|
|
23
|
+
|
|
24
|
+
(switch_statement
|
|
25
|
+
(case_clause (block) @conditional.inner)) @conditional.outer
|
|
26
|
+
|
|
27
|
+
(switch_statement
|
|
28
|
+
(otherwise_clause (block) @conditional.inner))
|
|
29
|
+
|
|
30
|
+
(for_statement
|
|
31
|
+
(block) @loop.inner) @loop.outer
|
|
32
|
+
(while_statement
|
|
33
|
+
(block) @loop.inner) @loop.outer
|
|
34
|
+
|
|
35
|
+
(lambda
|
|
36
|
+
expression: (_) @function.inner) @function.outer
|
|
37
|
+
|
|
38
|
+
(global_operator
|
|
39
|
+
(identifier) @parameter.inner)
|
|
40
|
+
|
|
41
|
+
(persistent_operator
|
|
42
|
+
(identifier) @parameter.inner)
|
|
43
|
+
|
|
44
|
+
(function_definition
|
|
45
|
+
(block) @function.inner) @function.outer
|
|
46
|
+
|
|
47
|
+
(function_output (identifier) @parameter.inner @parameter.outer)
|
|
48
|
+
|
|
49
|
+
((multioutput_variable ","? @parameter.outer._start . (_) @parameter.outer._end @parameter.inner . ))
|
|
50
|
+
((multioutput_variable (_) @parameter.inner @parameter.outer._start . "," @parameter.outer._end))
|
|
51
|
+
|
|
52
|
+
((function_arguments ","? @parameter.outer._start . (_) @parameter.inner._end @parameter.inner . ))
|
|
53
|
+
((function_arguments (_) @parameter.outer._start @parameter.inner . "," @parameter.outer._end))
|
|
54
|
+
|
|
55
|
+
(try_statement
|
|
56
|
+
(block) @conditional.inner) @conditional.outer
|
|
57
|
+
(catch_clause
|
|
58
|
+
(identifier) @parameter.inner @parameter.outer)
|
|
59
|
+
(catch_clause
|
|
60
|
+
(block) @conditional.inner)
|
|
61
|
+
|
|
62
|
+
(class_definition) @class.outer
|
|
63
|
+
|
|
64
|
+
(number) @number.inner
|
|
65
|
+
(_ (return_statement) @return.inner @return.outer)
|
|
66
|
+
(comment) @comment.outer
|
|
67
|
+
|
|
68
|
+
(matrix (row) @parameter.outer)
|
|
69
|
+
(cell (row) @parameter.outer)
|
|
70
|
+
(row (_) @parameter.inner)
|
|
71
|
+
|
|
72
|
+
(assignment
|
|
73
|
+
left: (_) @assignment.lhs
|
|
74
|
+
(_) @assignment.rhs) @assignment.outer
|
|
75
|
+
|
|
76
|
+
((superclasses "&"? @parameter.outer._start . (_) @parameter.inner @parameter.outer._end . ))
|
|
77
|
+
((superclasses (_) @parameter.inner @parameter.outer._start . "&" @parameter.outer._end))
|
|
78
|
+
|
|
79
|
+
(enum (identifier) @parameter.inner @parameter.outer)
|
|
80
|
+
|
|
81
|
+
(property name: (_) @parameter.outer @parameter.inner)
|
|
82
|
+
|
|
83
|
+
((enum ","? @parameter.outer._start . (_) @parameter.inner @parameter.outer._end . ))
|
|
84
|
+
((enum (_) @parameter.inner @parameter.outer._start . "," @parameter.outer._end))
|
|
85
|
+
|
|
86
|
+
((validation_functions ","? @paramenter.outer._start . (_) @parameter.inner @parameter.outer._end . ))
|
|
87
|
+
((validation_functions (_) @paramter.outer._start @parameter.inner . "," @parameter.outer._end))
|
|
88
|
+
|
|
89
|
+
((dimensions ","? @parameter.outer._start @_start . (_) @parameter.inner @parameter.outer._end . ))
|
|
90
|
+
((dimensions (_) @parameter.outer._start @parameter.inner . "," @parameter.outer._end))
|
|
91
|
+
|
|
92
|
+
((attributes ","? @parameter.outer._start . (_) @parameter.inner @parameter.outer._end . ))
|
|
93
|
+
((attributes (_) @parameter.outer._start @parameter.inner . "," @parameter.outer._end))
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
(function_definition
|
|
2
|
+
(block (_) @context.end)
|
|
3
|
+
) @context
|
|
4
|
+
|
|
5
|
+
(while_statement
|
|
6
|
+
(block (_) @context.end)
|
|
7
|
+
) @context
|
|
8
|
+
|
|
9
|
+
(for_statement
|
|
10
|
+
(block (_) @context.end)
|
|
11
|
+
) @context
|
|
12
|
+
|
|
13
|
+
(if_statement
|
|
14
|
+
(block (_) @context.end)
|
|
15
|
+
) @context
|
|
16
|
+
|
|
17
|
+
(elseif_clause
|
|
18
|
+
(block (_) @context.end)
|
|
19
|
+
) @context
|
|
20
|
+
|
|
21
|
+
(else_clause
|
|
22
|
+
(block (_) @context.end)
|
|
23
|
+
) @context
|
|
24
|
+
|
|
25
|
+
(switch_statement) @context
|
|
26
|
+
|
|
27
|
+
(case_clause
|
|
28
|
+
(block (_) @context.end)
|
|
29
|
+
) @context
|
|
30
|
+
|
|
31
|
+
(otherwise_clause
|
|
32
|
+
(block (_) @context.end)
|
|
33
|
+
) @context
|
|
34
|
+
|
|
35
|
+
(try_statement
|
|
36
|
+
"try"
|
|
37
|
+
(block (_) @context.end) @context
|
|
38
|
+
"end")
|
|
39
|
+
(catch_clause
|
|
40
|
+
"catch"
|
|
41
|
+
(block (_) @context.end) @context)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
; Constants
|
|
2
|
+
|
|
3
|
+
(events (identifier) @constant)
|
|
4
|
+
(attribute (identifier) @constant)
|
|
5
|
+
|
|
6
|
+
"~" @constant.builtin
|
|
7
|
+
|
|
8
|
+
; Fields/Properties
|
|
9
|
+
|
|
10
|
+
(superclass "." (identifier) @variable.other.member)
|
|
11
|
+
(property_name "." (identifier) @variable.other.member)
|
|
12
|
+
(property name: (identifier) @variable.other.member)
|
|
13
|
+
|
|
14
|
+
; Types
|
|
15
|
+
|
|
16
|
+
(class_definition name: (identifier) @keyword.storage.type)
|
|
17
|
+
(attributes (identifier) @constant)
|
|
18
|
+
(enum . (identifier) @type.enum.variant)
|
|
19
|
+
|
|
20
|
+
; Functions
|
|
21
|
+
|
|
22
|
+
(function_definition
|
|
23
|
+
"function" @keyword.function
|
|
24
|
+
name: (identifier) @function
|
|
25
|
+
[ "end" "endfunction" ]? @keyword.function)
|
|
26
|
+
|
|
27
|
+
(function_signature name: (identifier) @function)
|
|
28
|
+
(function_call name: (identifier) @function)
|
|
29
|
+
(handle_operator (identifier) @function)
|
|
30
|
+
(validation_functions (identifier) @function)
|
|
31
|
+
(command (command_name) @function.macro)
|
|
32
|
+
(command_argument) @string
|
|
33
|
+
(return_statement) @keyword.control.return
|
|
34
|
+
|
|
35
|
+
; Assignments
|
|
36
|
+
|
|
37
|
+
(assignment left: (_) @variable)
|
|
38
|
+
(multioutput_variable (_) @variable)
|
|
39
|
+
|
|
40
|
+
; Parameters
|
|
41
|
+
|
|
42
|
+
(function_arguments (identifier) @variable.parameter)
|
|
43
|
+
|
|
44
|
+
; Conditionals
|
|
45
|
+
|
|
46
|
+
(if_statement [ "if" "end" ] @keyword.control.conditional)
|
|
47
|
+
(elseif_clause "elseif" @keyword.control.conditional)
|
|
48
|
+
(else_clause "else" @keyword.control.conditional)
|
|
49
|
+
(switch_statement [ "switch" "end" ] @keyword.control.conditional)
|
|
50
|
+
(case_clause "case" @keyword.control.conditional)
|
|
51
|
+
(otherwise_clause "otherwise" @keyword.control.conditional)
|
|
52
|
+
(break_statement) @keyword.control.conditional
|
|
53
|
+
|
|
54
|
+
; Repeats
|
|
55
|
+
|
|
56
|
+
(for_statement [ "for" "parfor" "end" ] @keyword.control.repeat)
|
|
57
|
+
(while_statement [ "while" "end" ] @keyword.control.repeat)
|
|
58
|
+
(continue_statement) @keyword.control.repeat
|
|
59
|
+
|
|
60
|
+
; Exceptions
|
|
61
|
+
|
|
62
|
+
(try_statement [ "try" "end" ] @keyword.control.exception)
|
|
63
|
+
(catch_clause "catch" @keyword.control.exception)
|
|
64
|
+
|
|
65
|
+
; Punctuation
|
|
66
|
+
|
|
67
|
+
[ ";" "," "." ] @punctuation.delimiter
|
|
68
|
+
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
|
|
69
|
+
|
|
70
|
+
; Literals
|
|
71
|
+
|
|
72
|
+
(escape_sequence) @constant.character.escape
|
|
73
|
+
(formatting_sequence) @constant.character.escape
|
|
74
|
+
(string) @string
|
|
75
|
+
(number) @constant.numeric.float
|
|
76
|
+
(unary_operator ["+" "-"] @constant.numeric.float)
|
|
77
|
+
|
|
78
|
+
; Comments
|
|
79
|
+
|
|
80
|
+
[ (comment) (line_continuation) ] @comment.line
|
|
81
|
+
|
|
82
|
+
; Operators
|
|
83
|
+
|
|
84
|
+
[
|
|
85
|
+
"+"
|
|
86
|
+
".+"
|
|
87
|
+
"-"
|
|
88
|
+
".*"
|
|
89
|
+
"*"
|
|
90
|
+
".*"
|
|
91
|
+
"/"
|
|
92
|
+
"./"
|
|
93
|
+
"\\"
|
|
94
|
+
".\\"
|
|
95
|
+
"^"
|
|
96
|
+
".^"
|
|
97
|
+
"'"
|
|
98
|
+
".'"
|
|
99
|
+
"|"
|
|
100
|
+
"&"
|
|
101
|
+
"?"
|
|
102
|
+
"@"
|
|
103
|
+
"<"
|
|
104
|
+
"<="
|
|
105
|
+
">"
|
|
106
|
+
">="
|
|
107
|
+
"=="
|
|
108
|
+
"~="
|
|
109
|
+
"="
|
|
110
|
+
"&&"
|
|
111
|
+
"||"
|
|
112
|
+
":"
|
|
113
|
+
] @operator
|
|
114
|
+
|
|
115
|
+
; Keywords
|
|
116
|
+
|
|
117
|
+
"classdef" @keyword.storage.type
|
|
118
|
+
[
|
|
119
|
+
"arguments"
|
|
120
|
+
"end"
|
|
121
|
+
"enumeration"
|
|
122
|
+
"events"
|
|
123
|
+
"global"
|
|
124
|
+
"methods"
|
|
125
|
+
"persistent"
|
|
126
|
+
"properties"
|
|
127
|
+
] @keyword
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[
|
|
2
|
+
(arguments_statement)
|
|
3
|
+
(if_statement)
|
|
4
|
+
(for_statement)
|
|
5
|
+
(while_statement)
|
|
6
|
+
(switch_statement)
|
|
7
|
+
(try_statement)
|
|
8
|
+
(function_definition)
|
|
9
|
+
(class_definition)
|
|
10
|
+
(enumeration)
|
|
11
|
+
(events)
|
|
12
|
+
(methods)
|
|
13
|
+
(properties)
|
|
14
|
+
] @indent
|
|
15
|
+
|
|
16
|
+
[
|
|
17
|
+
(elseif_clause)
|
|
18
|
+
(else_clause)
|
|
19
|
+
(case_clause)
|
|
20
|
+
(otherwise_clause)
|
|
21
|
+
(catch_clause)
|
|
22
|
+
] @indent @extend
|
|
23
|
+
|
|
24
|
+
[ "end" ] @outdent
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
(function_definition name: (identifier) @local.definition ?) @local.scope
|
|
2
|
+
(function_arguments (identifier)* @local.definition)
|
|
3
|
+
|
|
4
|
+
(lambda (arguments (identifier) @local.definition)) @local.scope
|
|
5
|
+
|
|
6
|
+
(assignment left: ((function_call
|
|
7
|
+
name: (identifier) @local.definition)))
|
|
8
|
+
(assignment left: ((field_expression . [(function_call
|
|
9
|
+
name: (identifier) @local.definition)
|
|
10
|
+
(identifier) @local.definition])))
|
|
11
|
+
(assignment left: (_) @local.definition)
|
|
12
|
+
(assignment (multioutput_variable (_) @local.definition))
|
|
13
|
+
|
|
14
|
+
(iterator . (identifier) @local.definition)
|
|
15
|
+
(global_operator (identifier) @local.definition)
|
|
16
|
+
(persistent_operator (identifier) @local.definition)
|
|
17
|
+
(catch_clause (identifier) @local.definition)
|
|
18
|
+
|
|
19
|
+
(identifier) @local.reference
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
(arguments ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
|
|
2
|
+
(function_arguments ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
|
|
3
|
+
|
|
4
|
+
(lambda expression: (_) @function.inside) @function.around
|
|
5
|
+
(function_definition (block) @function.inside) @function.around
|
|
6
|
+
|
|
7
|
+
(class_definition) @class.inside @class.around
|
|
8
|
+
|
|
9
|
+
(comment) @comment.inside @comment.around
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
(function_definition
|
|
2
|
+
(block (_) @context.end)
|
|
3
|
+
) @context
|
|
4
|
+
|
|
5
|
+
(while_statement
|
|
6
|
+
(block (_) @context.end)
|
|
7
|
+
) @context
|
|
8
|
+
|
|
9
|
+
(for_statement
|
|
10
|
+
(block (_) @context.end)
|
|
11
|
+
) @context
|
|
12
|
+
|
|
13
|
+
(if_statement
|
|
14
|
+
(block (_) @context.end)
|
|
15
|
+
) @context
|
|
16
|
+
|
|
17
|
+
(elseif_clause
|
|
18
|
+
(block (_) @context.end)
|
|
19
|
+
) @context
|
|
20
|
+
|
|
21
|
+
(else_clause
|
|
22
|
+
(block (_) @context.end)
|
|
23
|
+
) @context
|
|
24
|
+
|
|
25
|
+
(switch_statement) @context
|
|
26
|
+
|
|
27
|
+
(case_clause
|
|
28
|
+
(block (_) @context.end)
|
|
29
|
+
) @context
|
|
30
|
+
|
|
31
|
+
(otherwise_clause
|
|
32
|
+
(block (_) @context.end)
|
|
33
|
+
) @context
|
|
34
|
+
|
|
35
|
+
(try_statement
|
|
36
|
+
"try"
|
|
37
|
+
(block (_) @context.end) @context
|
|
38
|
+
"end")
|
|
39
|
+
(catch_clause
|
|
40
|
+
"catch"
|
|
41
|
+
(block (_) @context.end) @context)
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
; Includes
|
|
2
|
+
|
|
3
|
+
((command_name) @include
|
|
4
|
+
(#eq? @include "import"))
|
|
5
|
+
|
|
6
|
+
; Keywords
|
|
7
|
+
|
|
8
|
+
[
|
|
9
|
+
"arguments"
|
|
10
|
+
"classdef"
|
|
11
|
+
"end"
|
|
12
|
+
"enumeration"
|
|
13
|
+
"events"
|
|
14
|
+
"global"
|
|
15
|
+
"methods"
|
|
16
|
+
"persistent"
|
|
17
|
+
"properties"
|
|
18
|
+
] @keyword
|
|
19
|
+
|
|
20
|
+
; Conditionals
|
|
21
|
+
|
|
22
|
+
(if_statement [ "if" "end" ] @conditional)
|
|
23
|
+
(elseif_clause "elseif" @conditional)
|
|
24
|
+
(else_clause "else" @conditional)
|
|
25
|
+
(switch_statement [ "switch" "end" ] @conditional)
|
|
26
|
+
(case_clause "case" @conditional)
|
|
27
|
+
(otherwise_clause "otherwise" @conditional)
|
|
28
|
+
(break_statement) @conditional
|
|
29
|
+
|
|
30
|
+
; Repeats
|
|
31
|
+
|
|
32
|
+
(for_statement [ "for" "parfor" "end" ] @repeat)
|
|
33
|
+
(while_statement [ "while" "end" ] @repeat)
|
|
34
|
+
(continue_statement) @repeat
|
|
35
|
+
|
|
36
|
+
; Exceptions
|
|
37
|
+
|
|
38
|
+
(try_statement [ "try" "end" ] @exception)
|
|
39
|
+
(catch_clause "catch" @exception)
|
|
40
|
+
|
|
41
|
+
; Variables
|
|
42
|
+
|
|
43
|
+
(identifier) @variable
|
|
44
|
+
|
|
45
|
+
; Constants
|
|
46
|
+
|
|
47
|
+
(events (identifier) @constant)
|
|
48
|
+
(attribute (identifier) @constant)
|
|
49
|
+
|
|
50
|
+
"~" @constant.builtin
|
|
51
|
+
|
|
52
|
+
; Fields/Properties
|
|
53
|
+
|
|
54
|
+
(field_expression field: (identifier) @field)
|
|
55
|
+
|
|
56
|
+
(superclass "." (identifier) @property)
|
|
57
|
+
|
|
58
|
+
(property_name "." (identifier) @property)
|
|
59
|
+
|
|
60
|
+
(property name: (identifier) @property)
|
|
61
|
+
|
|
62
|
+
; Types
|
|
63
|
+
|
|
64
|
+
(class_definition name: (identifier) @type)
|
|
65
|
+
|
|
66
|
+
(attributes (identifier) @constant)
|
|
67
|
+
|
|
68
|
+
(enum . (identifier) @type)
|
|
69
|
+
|
|
70
|
+
((identifier) @type
|
|
71
|
+
(#lua-match? @type "^_*[A-Z][a-zA-Z0-9_]+$"))
|
|
72
|
+
|
|
73
|
+
; Functions
|
|
74
|
+
|
|
75
|
+
(function_definition
|
|
76
|
+
"function" @keyword.function
|
|
77
|
+
name: (identifier) @function
|
|
78
|
+
[ "end" "endfunction" ]? @keyword.function)
|
|
79
|
+
|
|
80
|
+
(function_signature name: (identifier) @function)
|
|
81
|
+
|
|
82
|
+
(function_call
|
|
83
|
+
name: (identifier) @function.call)
|
|
84
|
+
|
|
85
|
+
(handle_operator (identifier) @function)
|
|
86
|
+
|
|
87
|
+
(validation_functions (identifier) @function)
|
|
88
|
+
|
|
89
|
+
(command (command_name) @function.call)
|
|
90
|
+
(command_argument) @parameter
|
|
91
|
+
|
|
92
|
+
(return_statement) @keyword.return
|
|
93
|
+
|
|
94
|
+
; Parameters
|
|
95
|
+
|
|
96
|
+
(function_arguments (identifier) @parameter)
|
|
97
|
+
|
|
98
|
+
; Punctuation
|
|
99
|
+
|
|
100
|
+
[ ";" "," "." ] @punctuation.delimiter
|
|
101
|
+
|
|
102
|
+
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
|
|
103
|
+
|
|
104
|
+
; Operators
|
|
105
|
+
|
|
106
|
+
[
|
|
107
|
+
"+"
|
|
108
|
+
".+"
|
|
109
|
+
"-"
|
|
110
|
+
".*"
|
|
111
|
+
"*"
|
|
112
|
+
".*"
|
|
113
|
+
"/"
|
|
114
|
+
"./"
|
|
115
|
+
"\\"
|
|
116
|
+
".\\"
|
|
117
|
+
"^"
|
|
118
|
+
".^"
|
|
119
|
+
"'"
|
|
120
|
+
".'"
|
|
121
|
+
"|"
|
|
122
|
+
"&"
|
|
123
|
+
"?"
|
|
124
|
+
"@"
|
|
125
|
+
"<"
|
|
126
|
+
"<="
|
|
127
|
+
">"
|
|
128
|
+
">="
|
|
129
|
+
"=="
|
|
130
|
+
"~="
|
|
131
|
+
"="
|
|
132
|
+
"&&"
|
|
133
|
+
"||"
|
|
134
|
+
":"
|
|
135
|
+
] @operator
|
|
136
|
+
|
|
137
|
+
; Literals
|
|
138
|
+
|
|
139
|
+
(string) @string
|
|
140
|
+
|
|
141
|
+
(escape_sequence) @string.escape
|
|
142
|
+
(formatting_sequence) @string.special
|
|
143
|
+
|
|
144
|
+
(number) @number
|
|
145
|
+
|
|
146
|
+
((identifier) @boolean
|
|
147
|
+
(#eq? @boolean "true"))
|
|
148
|
+
((identifier) @boolean
|
|
149
|
+
(#eq? @boolean "false"))
|
|
150
|
+
|
|
151
|
+
; Comments
|
|
152
|
+
|
|
153
|
+
[ (comment) (line_continuation) ] @comment @spell
|
|
154
|
+
|
|
155
|
+
; Errors
|
|
156
|
+
|
|
157
|
+
(ERROR) @error
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"end" @indent.end @indent.branch
|
|
2
|
+
|
|
3
|
+
[
|
|
4
|
+
(arguments_statement)
|
|
5
|
+
(if_statement)
|
|
6
|
+
(for_statement)
|
|
7
|
+
(while_statement)
|
|
8
|
+
(switch_statement)
|
|
9
|
+
(try_statement)
|
|
10
|
+
(function_definition)
|
|
11
|
+
(class_definition)
|
|
12
|
+
(enumeration)
|
|
13
|
+
(events)
|
|
14
|
+
(methods)
|
|
15
|
+
(properties)
|
|
16
|
+
] @indent.begin
|
|
17
|
+
|
|
18
|
+
[
|
|
19
|
+
"elseif"
|
|
20
|
+
"else"
|
|
21
|
+
"case"
|
|
22
|
+
"otherwise"
|
|
23
|
+
"catch"
|
|
24
|
+
] @indent.branch
|
|
25
|
+
|
|
26
|
+
((matrix (row) @indent.align)
|
|
27
|
+
(#set! indent.open_delimiter "[")
|
|
28
|
+
(#set! indent.close_delimiter "]"))
|
|
29
|
+
((cell (row) @indent.align)
|
|
30
|
+
(#set! indent.open_delimiter "{")
|
|
31
|
+
(#set! indent.close_delimiter "}"))
|
|
32
|
+
((parenthesis) @indent.align
|
|
33
|
+
(#set! indent.open_delimiter "(")
|
|
34
|
+
(#set! indent.close_delimiter ")"))
|
|
35
|
+
|
|
36
|
+
(comment) @indent.auto
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(comment) @comment
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
; References
|
|
2
|
+
|
|
3
|
+
(identifier) @reference
|
|
4
|
+
|
|
5
|
+
; Definitions
|
|
6
|
+
|
|
7
|
+
(function_definition
|
|
8
|
+
name: (identifier) @definition.function
|
|
9
|
+
(function_arguments
|
|
10
|
+
(identifier)* @definition.parameter
|
|
11
|
+
("," (identifier) @definition.parameter)*)?) @scope
|
|
12
|
+
|
|
13
|
+
(assignment left: (identifier) @definition.var)
|
|
14
|
+
(multioutput_variable (identifier) @definition.var)
|
|
15
|
+
|
|
16
|
+
(iterator . (identifier) @definition.var)
|
|
17
|
+
(lambda (arguments (identifier) @definition.parameter))
|
|
18
|
+
(global_operator (identifier) @definition.var)
|
|
19
|
+
(persistent_operator (identifier) @definition.var)
|
|
20
|
+
(catch_clause (identifier) @definition)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
(_ (block) @block.inner) @block.outer
|
|
2
|
+
(block (_) @statement.outer)
|
|
3
|
+
(source_file (_) @statement.outer)
|
|
4
|
+
|
|
5
|
+
(function_call
|
|
6
|
+
(arguments)? @call.inner) @call.outer
|
|
7
|
+
((arguments ","? @_start . (_) @parameter.inner . )
|
|
8
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
9
|
+
((arguments (_) @parameter.inner . "," @_end)
|
|
10
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
11
|
+
|
|
12
|
+
(command) @call.outer
|
|
13
|
+
(command (command_argument) @parameter.inner @parameter.outer)
|
|
14
|
+
(command
|
|
15
|
+
(command_argument) @_start (command_argument)* @_end .
|
|
16
|
+
(#make-range! "call.inner" @_start @_end))
|
|
17
|
+
|
|
18
|
+
(if_statement
|
|
19
|
+
(block) @conditional.inner) @conditional.outer
|
|
20
|
+
(if_statement
|
|
21
|
+
(elseif_clause
|
|
22
|
+
(block) @conditional.inner))
|
|
23
|
+
(if_statement
|
|
24
|
+
(else_clause
|
|
25
|
+
(block) @conditional.inner))
|
|
26
|
+
|
|
27
|
+
(switch_statement
|
|
28
|
+
(case_clause (block) @conditional.inner)) @conditional.outer
|
|
29
|
+
|
|
30
|
+
(switch_statement
|
|
31
|
+
(otherwise_clause (block) @conditional.inner))
|
|
32
|
+
|
|
33
|
+
(for_statement
|
|
34
|
+
(block) @loop.inner) @loop.outer
|
|
35
|
+
(while_statement
|
|
36
|
+
(block) @loop.inner) @loop.outer
|
|
37
|
+
|
|
38
|
+
(lambda
|
|
39
|
+
expression: (_) @function.inner) @function.outer
|
|
40
|
+
|
|
41
|
+
(global_operator
|
|
42
|
+
(identifier) @parameter.inner)
|
|
43
|
+
|
|
44
|
+
(persistent_operator
|
|
45
|
+
(identifier) @parameter.inner)
|
|
46
|
+
|
|
47
|
+
(function_definition
|
|
48
|
+
(block) @function.inner) @function.outer
|
|
49
|
+
|
|
50
|
+
(function_output (identifier) @parameter.inner @parameter.outer)
|
|
51
|
+
|
|
52
|
+
((function_arguments ","? @_start . (_) @parameter.inner . )
|
|
53
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
54
|
+
((function_arguments (_) @parameter.inner . "," @_end)
|
|
55
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
56
|
+
|
|
57
|
+
((multioutput_variable ","? @_start . (_) @parameter.inner . )
|
|
58
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
59
|
+
((multioutput_variable (_) @parameter.inner . "," @_end)
|
|
60
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
61
|
+
|
|
62
|
+
(try_statement
|
|
63
|
+
(block) @conditional.inner) @conditional.outer
|
|
64
|
+
(catch_clause
|
|
65
|
+
(identifier) @parameter.inner @parameter.outer)
|
|
66
|
+
(catch_clause
|
|
67
|
+
(block) @conditional.inner)
|
|
68
|
+
|
|
69
|
+
(class_definition) @class.outer
|
|
70
|
+
|
|
71
|
+
(number) @number.inner
|
|
72
|
+
(_ (return_statement) @return.inner @return.outer)
|
|
73
|
+
(comment) @comment.outer
|
|
74
|
+
|
|
75
|
+
(matrix (row) @parameter.outer)
|
|
76
|
+
(cell (row) @parameter.outer)
|
|
77
|
+
(row (_) @parameter.inner)
|
|
78
|
+
|
|
79
|
+
(assignment
|
|
80
|
+
left: (_) @assignment.lhs
|
|
81
|
+
(_) @assignment.rhs) @assignment.outer
|
|
82
|
+
|
|
83
|
+
((superclasses "&"? @_start . (_) @parameter.inner . )
|
|
84
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
85
|
+
((superclasses (_) @parameter.inner . "&" @_end)
|
|
86
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
87
|
+
|
|
88
|
+
(enum (identifier) @parameter.inner @parameter.outer)
|
|
89
|
+
|
|
90
|
+
(property name: (_) @parameter.outer @parameter.inner)
|
|
91
|
+
|
|
92
|
+
((enum ","? @_start . (_) @parameter.inner . )
|
|
93
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
94
|
+
((enum (_) @parameter.inner . "," @_end)
|
|
95
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
96
|
+
|
|
97
|
+
((validation_functions ","? @_start . (_) @parameter.inner . )
|
|
98
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
99
|
+
((validation_functions (_) @parameter.inner . "," @_end)
|
|
100
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
101
|
+
|
|
102
|
+
((dimensions ","? @_start . (_) @parameter.inner . )
|
|
103
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
104
|
+
((dimensions (_) @parameter.inner . "," @_end)
|
|
105
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
106
|
+
|
|
107
|
+
((attributes ","? @_start . (_) @parameter.inner . )
|
|
108
|
+
(#make-range! "parameter.outer" @_start @parameter.inner))
|
|
109
|
+
((attributes (_) @parameter.inner . "," @_end)
|
|
110
|
+
(#make-range! "parameter.outer" @parameter.inner @_end))
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-matlab
|
|
3
|
+
Version: 1.2.9
|
|
4
|
+
Summary: MATLAB tree-sitter parser
|
|
5
|
+
Author: Álan Crístoffer e Sousa
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/acristoffers/tree-sitter-matlab
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,matlab
|
|
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
|
+
# MATLAB grammar for tree-sitter.
|
|
21
|
+
|
|
22
|
+
There are screenshots at the end of this README :)
|
|
23
|
+
|
|
24
|
+
This parser has the objective of generating a tree that is as correct as
|
|
25
|
+
possible (but sometimes just convenient) with what MATLAB itself executes. It
|
|
26
|
+
is not intended only for syntax highlight, but also to be used by scripts to
|
|
27
|
+
whatever it may be needed. In fact, I wrote it because I'm a Neovim/Doom Emacs
|
|
28
|
+
user and love having text-objects, and was really missing a text object for
|
|
29
|
+
matrices rows/cells.
|
|
30
|
+
|
|
31
|
+
Being as correct as possible means that some things are done correctly, for
|
|
32
|
+
example:
|
|
33
|
+
|
|
34
|
+
- Commands are parsed the same way MATLAB does it, by treating arguments as
|
|
35
|
+
literals, grouping them correctly and only starting comments when allowed. It
|
|
36
|
+
should perfectly match what MATLAB does.
|
|
37
|
+
|
|
38
|
+
- Assignment has its own token, and multiple-variable assignment is NOT an
|
|
39
|
+
assignment to a matrix (and returning an error is the correct thing to do, as
|
|
40
|
+
it allows the user to see that something is off with the highlight, meaning
|
|
41
|
+
something is probably off with the code):
|
|
42
|
+
|
|
43
|
+
```matlab
|
|
44
|
+
% (assignment (multioutput_variable (identifier) (identifier)) (identifier))
|
|
45
|
+
[a,b] = d
|
|
46
|
+
|
|
47
|
+
% this is WRONG:
|
|
48
|
+
[a;b] = d
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- Inside a matrix, `1 + 1` and `1 +1` are different things:
|
|
52
|
+
|
|
53
|
+
```matlab
|
|
54
|
+
a = 1 + 1 % 2
|
|
55
|
+
a = 1 +1 %2
|
|
56
|
+
[1 + 1] == [2]
|
|
57
|
+
[1 +1] == [1 1]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Being convenient means that sometimes the difference between what is acceptable
|
|
61
|
+
and what is not acceptable lives in the semantics, so we can't know. In such
|
|
62
|
+
cases I just accept semantically wrong but syntax correct things and group them
|
|
63
|
+
in the same token (first example). I do the same when the overhead of
|
|
64
|
+
generating a specific token would not really pay off (second example).
|
|
65
|
+
|
|
66
|
+
- Function calls and Matrix Indexing are the same in MATLAB: `A(1)` can be any
|
|
67
|
+
of them and you cannot tell them apart unless you know for sure what `A` is
|
|
68
|
+
referring to. So for convenience I just generate a `function_call` for them and
|
|
69
|
+
also for cell indexing `A{1}`. The "problem" with that is that this is a valid
|
|
70
|
+
indexing but an invalid function call: `A(:)`. However I don't distinguish at
|
|
71
|
+
all and say that all of them are `function_call`.
|
|
72
|
+
|
|
73
|
+
- Function definitions, when inside a class, accepts a special syntax for the
|
|
74
|
+
name of the function, allowing it to be preceded by either `get.` or `set.`,
|
|
75
|
+
like `function get.name()`. I could have a `method_definition` that would allow
|
|
76
|
+
that to only be valid in the class context, but I doubt that would be worth it.
|
|
77
|
+
So any function anywhere can have those and be recognize as correct still.
|
|
78
|
+
Given the existence of external method definition, maybe that is even the
|
|
79
|
+
correct thing to do, since we don't know if the current file is inside a
|
|
80
|
+
special class folder.
|
|
81
|
+
|
|
82
|
+
# Installation
|
|
83
|
+
|
|
84
|
+
This parser is now the default for the following editors:
|
|
85
|
+
|
|
86
|
+
- Emacs: Through the `tree-sitter-langs` package.
|
|
87
|
+
- Helix: Builtin.
|
|
88
|
+
- Neovim: Through the `nvim-treesitter` plugin.
|
|
89
|
+
|
|
90
|
+
# Screenshots
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+

|
|
94
|
+

|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
tree_sitter_matlab/__init__.pyi,sha256=oixFm8lXsZZWYa5cRwj6brbqh37_fzN2rLE-dmX9_rA,247
|
|
2
|
+
tree_sitter_matlab/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
tree_sitter_matlab/binding.c,sha256=h7C-KitZXMRPV6F3j-sxahaR2CR13QC3gEPBgeilgYM,836
|
|
4
|
+
tree_sitter_matlab/__init__.py,sha256=0PhvKgPyLWVNdFtOjTEoI2ptCtyqc0zgyNbglBrOc5g,1150
|
|
5
|
+
tree_sitter_matlab/_binding.abi3.so,sha256=dm4SgJ1UUhtkWT5DwB3zUOXXiQgr2jb0QIRi5VyKGTY,491020
|
|
6
|
+
tree_sitter_matlab/queries/helix/locals.scm,sha256=RQUp2CnxfboPN3aFs6z2ByjbbW7sunm1d5EyrfkvXOk,822
|
|
7
|
+
tree_sitter_matlab/queries/helix/textobjects.scm,sha256=X2Ui1mR2cTCIL_ggmR--dTlZ4YmXlCsqMQ2sFrVW_JA,382
|
|
8
|
+
tree_sitter_matlab/queries/helix/context.scm,sha256=u8d7mwEzpKe5F21VVlU8ixc6Cj5M4UD552yz2nnObBw,596
|
|
9
|
+
tree_sitter_matlab/queries/helix/indents.scm,sha256=0y3gPs3b3d7_94VfVx21OIHmhxEy2KghT_byxvcmgo4,358
|
|
10
|
+
tree_sitter_matlab/queries/helix/injections.scm,sha256=jbjrojqBCasUkBymLivLJ-LDjZbL4DYsAtxvcf2v0o8,69
|
|
11
|
+
tree_sitter_matlab/queries/helix/folds.scm,sha256=wWsPmOq2fAEiNs0A_LEcZ4mnAQE6r7nphrpMYsi5IyU,189
|
|
12
|
+
tree_sitter_matlab/queries/helix/highlights.scm,sha256=Qd95JbujY3nZLQc-IxxToWkK-i_oGfBeLLCBnlT86Ac,2481
|
|
13
|
+
tree_sitter_matlab/queries/emacs/textobjects.scm,sha256=LCwIbkbUaS8g3qBxc7i4iJ5gscFauvHsUwaCCq72-Uw,3163
|
|
14
|
+
tree_sitter_matlab/queries/emacs/highlights.scm,sha256=BeKmlDaygOmMcm_E52_VqorpvxptcC581KuplNmKQCY,2731
|
|
15
|
+
tree_sitter_matlab/queries/neovim/locals.scm,sha256=xO9m6s3z5mvnwLZYPxurjWwLwJ3CHVgqZYtYBucvsN8,573
|
|
16
|
+
tree_sitter_matlab/queries/neovim/textobjects.scm,sha256=FYlyhYV_J_bL8qcw6xKmPmysntiz9s1PaQfv2V6Etqg,3481
|
|
17
|
+
tree_sitter_matlab/queries/neovim/context.scm,sha256=u8d7mwEzpKe5F21VVlU8ixc6Cj5M4UD552yz2nnObBw,596
|
|
18
|
+
tree_sitter_matlab/queries/neovim/indents.scm,sha256=TareEDGJalzhO0lIfclKg1pbm9LXf-wdMdjLWQxFG4A,670
|
|
19
|
+
tree_sitter_matlab/queries/neovim/injections.scm,sha256=P0dRDJFJ6ojtdDFh18Xv6zETOmBes7MAbZCtttY_NBE,19
|
|
20
|
+
tree_sitter_matlab/queries/neovim/folds.scm,sha256=wWsPmOq2fAEiNs0A_LEcZ4mnAQE6r7nphrpMYsi5IyU,189
|
|
21
|
+
tree_sitter_matlab/queries/neovim/highlights.scm,sha256=lSboTeNvTuG7l97cw8SQjuz61xK8dz1PlrdwhzRjjlo,2376
|
|
22
|
+
tree_sitter_matlab/queries/neovim/tags.scm,sha256=EY0XStKMjGPxXbKCM3jKVH0Qvgus0CENhHQDTT3FkWk,245
|
|
23
|
+
tree_sitter_matlab-1.2.9.dist-info/WHEEL,sha256=R2Q6x55j9mRwUMDKGxYbnhu7hJAJEGVdNpFAt1xB6Js,109
|
|
24
|
+
tree_sitter_matlab-1.2.9.dist-info/top_level.txt,sha256=Dg13NJZGhzKz2Riy0HL6h4_yxGrw2Mq20p2lv1Q_bIE,28
|
|
25
|
+
tree_sitter_matlab-1.2.9.dist-info/METADATA,sha256=_HEZZYLSkc2ZNLPxE80R7WDvE18ofLBQ7w75OhLxH5A,3843
|
|
26
|
+
tree_sitter_matlab-1.2.9.dist-info/RECORD,,
|
|
27
|
+
tree_sitter_matlab-1.2.9.dist-info/licenses/LICENSE,sha256=hnP1rNWb-zvRKXYKV_cgktXjwB4Fg3Uy6slJfPgAakY,1061
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2023 Álan Crístoffer
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|