Skip to content

Commit 90e9cf9

Browse files
acristoffersmeain
authored andcommitted
Add matlab grammar
1 parent 2e1d165 commit 90e9cf9

File tree

5 files changed

+192
-4
lines changed

5 files changed

+192
-4
lines changed

.gitmodules

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
url = https://github.com/LumaKernel/tree-sitter-prisma
187187
branch = master
188188
update = none
189-
ignore = dirty
189+
ignore = dirty
190190
[submodule "repos/haskell"]
191191
path = repos/haskell
192192
url = https://github.com/tree-sitter/tree-sitter-haskell
@@ -253,9 +253,9 @@
253253
[submodule "repos/fennel"]
254254
path = repos/fennel
255255
url = https://github.com/TravonteD/tree-sitter-fennel
256-
branch = master
257-
update = none
258-
ignore = dirty
256+
branch = master
257+
update = none
258+
ignore = dirty
259259
[submodule "repos/clojure"]
260260
path = repos/clojure
261261
url = https://github.com/sogaiu/tree-sitter-clojure
@@ -268,3 +268,9 @@
268268
branch = master
269269
update = none
270270
ignore = dirty
271+
[submodule "repos/matlab"]
272+
path = repos/matlab
273+
url = https://github.com/acristoffers/tree-sitter-matlab
274+
branch = main
275+
update = none
276+
ignore = dirty

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Add `MATLAB` grammar
6+
57
## 0.12.20 - 2023-06-22
68
- Bump `go` grammar
79

queries/matlab/highlights.scm

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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+
(boolean) @constant.builtin
120+
121+
; Comments
122+
123+
[ (comment) (line_continuation) ] @comment @spell
124+
125+
; Operators
126+
127+
(unary_operator ["+" "-"] @number)
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+
":"
158+
] @operator
159+
160+
; Assignments
161+
162+
(assignment left: (_) @variable)
163+
(multioutput_variable (_) @variable)
164+
165+
; Keywords
166+
167+
[
168+
"arguments"
169+
"classdef"
170+
"end"
171+
"enumeration"
172+
"events"
173+
"global"
174+
"methods"
175+
"persistent"
176+
"properties"
177+
] @keyword
178+

repos/matlab

Submodule matlab added at 166b81d

tree-sitter-langs.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ See `tree-sitter-langs-repos'."
129129
(jsonc-mode . json)
130130
(julia-mode . julia)
131131
(lua-mode . lua)
132+
(matlab-mode . matlab)
132133
(meson-mode . meson)
133134
(ocaml-mode . ocaml)
134135
(perl-mode . perl)

0 commit comments

Comments
 (0)