aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/matlab/highlights.scm
diff options
context:
space:
mode:
authorÁlan Crístoffer2023-06-22 22:19:40 +0000
committerGitHub2023-06-22 22:19:40 +0000
commit2c5288dafb88ae2a12d3589b79a525932f48b6b3 (patch)
treef53c61925d285c0b48d15bd7ef00393a2e346484 /runtime/queries/matlab/highlights.scm
parent842518ccb7e76e2c569db72ff79968ca80882bc0 (diff)
Replace MATLAB grammar (#7388)
Diffstat (limited to 'runtime/queries/matlab/highlights.scm')
-rw-r--r--runtime/queries/matlab/highlights.scm182
1 files changed, 106 insertions, 76 deletions
diff --git a/runtime/queries/matlab/highlights.scm b/runtime/queries/matlab/highlights.scm
index c0e23e91..bc4c5069 100644
--- a/runtime/queries/matlab/highlights.scm
+++ b/runtime/queries/matlab/highlights.scm
@@ -1,97 +1,127 @@
- ; highlights.scm
+; Constants
-function_keyword: (function_keyword) @keyword.function
+(events (identifier) @constant)
+(attribute (identifier) @constant)
-(function_definition
-function_name: (identifier) @function
-(end) @function)
+"~" @constant.builtin
-(parameter_list (identifier) @variable.parameter)
+; Fields/Properties
-[
- "if"
- "elseif"
- "else"
- "switch"
- "case"
- "otherwise"
-] @keyword.control.conditional
+(superclass "." (identifier) @variable.other.member)
+(property_name "." (identifier) @variable.other.member)
+(property name: (identifier) @variable.other.member)
-(if_statement (end) @keyword.control.conditional)
-(switch_statement (end) @keyword.control.conditional)
+; Types
-["for" "while"] @keyword.control.repeat
-(for_statement (end) @keyword.control.repeat)
-(while_statement (end) @keyword.control.repeat)
+(class_definition name: (identifier) @keyword.storage.type)
+(attributes (identifier) @constant)
+(enum . (identifier) @type.enum.variant)
-["try" "catch"] @keyword.control.exception
-(try_statement (end) @keyword.control.exception)
+; Functions
-(function_definition end: (end) @keyword)
+(function_definition
+ "function" @keyword.function
+ name: (identifier) @function
+ [ "end" "endfunction" ]? @keyword.function)
-["return" "break" "continue"] @keyword.return
+(function_signature name: (identifier) @function)
+(function_call name: (identifier) @function)
+(handle_operator (identifier) @function)
+(validation_functions (identifier) @function)
+(command (command_name) @function.macro)
+(command_argument) @string
+(return_statement) @keyword.control.return
-(
-(identifier) @constant.builtin
-(#any-of? @constant.builtin "true" "false")
-)
+; Assignments
-(
- (identifier) @constant.builtin
- (#eq? @constant.builtin "end")
-)
+(assignment left: (_) @variable)
+(multioutput_variable (_) @variable)
-;; Punctuations
+; Parameters
-[";" ","] @punctuation.special
-(argument_list "," @punctuation.delimiter)
-(vector_definition ["," ";"] @punctuation.delimiter)
-(cell_definition ["," ";"] @punctuation.delimiter)
-":" @punctuation.delimiter
-(parameter_list "," @punctuation.delimiter)
-(return_value "," @punctuation.delimiter)
+(function_arguments (identifier) @variable.parameter)
-; ;; Brackets
+; Operators
[
- "("
- ")"
- "["
- "]"
- "{"
- "}"
-] @punctuation.bracket
-
-;; Operators
-"=" @operator
-(operation [ ">"
- "<"
- "=="
- "<="
- ">="
- "=<"
- "=>"
- "~="
- "*"
- ".*"
- "/"
- "\\"
- "./"
- "^"
- ".^"
- "+"] @operator)
-
-;; boolean operator
-[
- "&&"
- "||"
+ "+"
+ ".+"
+ "-"
+ ".*"
+ "*"
+ ".*"
+ "/"
+ "./"
+ "\\"
+ ".\\"
+ "^"
+ ".^"
+ "'"
+ ".'"
+ "|"
+ "&"
+ "?"
+ "@"
+ "<"
+ "<="
+ ">"
+ ">="
+ "=="
+ "~="
+ "="
+ "&&"
+ "||"
+ ":"
] @operator
-;; Number
-(number) @constant.numeric
+; Conditionals
+
+(if_statement [ "if" "end" ] @keyword.control.conditional)
+(elseif_clause "elseif" @keyword.control.conditional)
+(else_clause "else" @keyword.control.conditional)
+(switch_statement [ "switch" "end" ] @keyword.control.conditional)
+(case_clause "case" @keyword.control.conditional)
+(otherwise_clause "otherwise" @keyword.control.conditional)
+(break_statement) @keyword.control.conditional
+
+; Repeats
+
+(for_statement [ "for" "parfor" "end" ] @keyword.control.repeat)
+(while_statement [ "while" "end" ] @keyword.control.repeat)
+(continue_statement) @keyword.control.repeat
+
+; Exceptions
-;; String
+(try_statement [ "try" "end" ] @keyword.control.exception)
+(catch_clause "catch" @keyword.control.exception)
+
+; Punctuation
+
+[ ";" "," "." ] @punctuation.delimiter
+[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
+
+; Literals
+
+(escape_sequence) @constant.character.escape
+(formatting_sequence) @constant.character.escape
(string) @string
+(number) @constant.numeric.float
+(boolean) @constant.builtin.boolean
-;; Comment
-(comment) @comment
+; Comments
+
+[ (comment) (line_continuation) ] @comment.line
+
+; Keywords
+
+"classdef" @keyword.storage.type
+[
+ "arguments"
+ "end"
+ "enumeration"
+ "events"
+ "global"
+ "methods"
+ "persistent"
+ "properties"
+] @keyword