feat: add matlab

This commit is contained in:
Amaan Qureshi 2023-02-28 00:16:21 -05:00
parent f0617c31f4
commit 316200f77d
6 changed files with 136 additions and 0 deletions

View file

@ -264,6 +264,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991)
- [x] [markdown](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml)
- [x] [markdown_inline](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml)
- [x] [matlab](https://github.com/mstanciu552/tree-sitter-matlab) (maintained by @amaanq)
- [x] [menhir](https://github.com/Kerl13/tree-sitter-menhir) (maintained by @Kerl13)
- [ ] [mermaid](https://github.com/monaqa/tree-sitter-mermaid) (experimental)
- [x] [meson](https://github.com/Decodetalkers/tree-sitter-meson) (maintained by @Decodetalkers)

View file

@ -272,6 +272,9 @@
"markdown_inline": {
"revision": "7e7aa9a25ca9729db9fe22912f8f47bdb403a979"
},
"matlab": {
"revision": "2d5d3d5193718a86477d4335aba5b34e79147326"
},
"menhir": {
"revision": "db7953acb0d5551f207373c81fa07a57d7b085cb"
},

View file

@ -888,6 +888,14 @@ list.markdown_inline = {
experimental = true,
}
list.matlab = {
install_info = {
url = "https://github.com/mstanciu552/tree-sitter-matlab",
files = { "src/parser.c" },
},
maintainers = { "@amaanq" },
}
list.menhir = {
install_info = {
url = "https://github.com/Kerl13/tree-sitter-menhir",

16
queries/matlab/folds.scm Normal file
View file

@ -0,0 +1,16 @@
[
(function_definition)
(if_statement)
(for_statement)
(while_statement)
(switch_statement)
(case_statement)
(otherwise_statement)
(try_statement)
(catch_statement)
] @fold

View file

@ -0,0 +1,107 @@
; Functions
(function_definition
function_name: (identifier) @function
(end) @keyword.function)
(parameter_list (identifier) @parameter)
; Keywords
((identifier) @keyword
(#eq? @keyword "end"))
(function_keyword) @keyword.function
[
"return"
] @keyword.return
; Conditionals
[
"if"
"elseif"
"else"
"switch"
"case"
"otherwise"
] @conditional
(if_statement (end) @conditional)
(switch_statement (end) @conditional)
; Repeats
[
"for"
"while"
"break"
"continue"
] @repeat
(for_statement (end) @repeat)
(while_statement (end) @repeat)
; Exceptions
[
"try"
"catch"
] @exception
(try_statement (end) @exception)
; Punctuation
[
","
";"
":"
] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
; Operators
[
">"
"<"
"=="
"<="
">="
"=<"
"=>"
"~="
"*"
".*"
"/"
"\\"
"./"
"^"
".^"
"+"
"="
"&&"
"||"
] @operator
; Literals
(number) @number
(string) @string
[ "true" "false" ] @boolean
; Comments
(comment) @comment @spell
; Errors
(ERROR) @error

View file

@ -0,0 +1 @@
(comment) @comment