feat(t32)!: update queries for new HLL node types

- Lock grammar to version 2.1.1
- Update query for syntax hightlighting
- fix missing locals query
- reduce number of "(identifier) @variable" highlight queries
- revert to capture @function.builtin for PRACTICE call expressions
This commit is contained in:
Christoph Sax 2023-07-25 06:12:57 +02:00 committed by Christian Clason
parent e8648569d8
commit 2fb7359828
3 changed files with 119 additions and 26 deletions

View file

@ -1512,7 +1512,7 @@ list.t32 = {
install_info = { install_info = {
url = "https://codeberg.org/xasc/tree-sitter-t32", url = "https://codeberg.org/xasc/tree-sitter-t32",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
revision = "1dd98248b01e4a3933c1b85b58bab0875e2ba437", revision = "767f3c52fe649e4a6ab3551ac287e5b6038c9148",
}, },
maintainers = { "@xasc" }, maintainers = { "@xasc" },
} }

View file

@ -1,3 +1,4 @@
; Keywords, punctuation and operators
[ [
"=" "="
"^^" "^^"
@ -28,50 +29,129 @@
"&" "&"
"->" "->"
"*" "*"
"-="
"+="
"*="
"/="
"%="
"|="
"&="
"^="
">>="
"<<="
"--"
"++"
] @operator ] @operator
[ [
"(" "("
")" ")"
"{" "{"
"}" "}"
"[" "["
"]" "]"
] @punctuation.bracket ] @punctuation.bracket
[ [
"," ","
"." "."
";"
] @punctuation.delimiter ] @punctuation.delimiter
[ [
(access_class) "enum"
"struct"
"union"
] @keyword
"sizeof" @keyword.operator
[
"const"
"volatile"
] @type.qualifier
; Operators in comma and conditional HLL expressions
(hll_comma_expression
"," @operator)
(hll_conditional_expression
[
"?"
":"
] @conditional.ternary)
; Strings and others literal types
(access_class) @constant.builtin
[
(address) (address)
(bitmask) (bitmask)
(file_handle) (file_handle)
(frequency)
(integer) (integer)
(percentage) (hll_number_literal)
(time)
] @number ] @number
(float) @float [
(float)
(frequency)
(percentage)
(time)
] @float
(string) @string [
(string)
(hll_string_literal)
] @string
(hll_escape_sequence) @string.escape
(path) @string.special (path) @string.special
(symbol) @symbol (symbol) @symbol
(character) @character [
(character)
(hll_char_literal)
] @character
; Types in HLL expressions
[
(hll_type_identifier)
(hll_type_descriptor)
] @type
(hll_type_qualifier) @type.qualifier
(hll_primitive_type) @type.builtin
; HLL expressions
(hll_call_expression
function: (identifier) @function.call)
(hll_call_expression
function: (hll_field_expression
field: (hll_field_identifier) @function.call))
; HLL variables
(identifier) @variable
(hll_field_identifier) @field
; Commands ; Commands
(command_expression (command_expression
command: (identifier) @keyword) command: (identifier) @keyword)
(macro_definition (macro_definition
command: (identifier) @keyword) command: (identifier) @keyword)
(call_expression
function: (identifier) @function.builtin)
; Returns ; Returns
( (
(command_expression (command_expression
@ -84,20 +164,23 @@
(#lua-match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$") (#lua-match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$")
) )
; Subroutine calls ; Subroutine calls
(subroutine_call_expression (subroutine_call_expression
command: (identifier) @keyword command: (identifier) @keyword
subroutine: (identifier) @function.call) subroutine: (identifier) @function.call)
; Variables, constants and labels ; Variables, constants and labels
(macro) @variable.builtin (macro) @variable.builtin
(internal_c_variable) @variable.builtin (trace32_hll_variable) @variable.builtin
(argument_list (argument_list
(identifier) @constant) (identifier) @constant.builtin)
( (
(argument_list (identifier) @constant.builtin) (argument_list (identifier) @constant.builtin)
(#lua-match? @constant.builtin "^[%%/][%l%u][%l%u%d.]*$") (#lua-match? @constant.builtin "^[%%/][%l%u][%l%u%d.]*$")
) )
( (
@ -106,24 +189,34 @@
arguments: (argument_list . (identifier) @label)) arguments: (argument_list . (identifier) @label))
(#lua-match? @keyword "^[gG][oO][tT][oO]$") (#lua-match? @keyword "^[gG][oO][tT][oO]$")
) )
(labeled_expression (labeled_expression
label: (identifier) @label) label: (identifier) @label)
(option_expression
(identifier) @constant.builtin)
(format_expression
(identifier) @constant.builtin)
; Subroutine blocks ; Subroutine blocks
(subroutine_block (subroutine_block
command: (identifier) @keyword command: (identifier) @keyword.function
subroutine: (identifier) @function) subroutine: (identifier) @function)
(labeled_expression (labeled_expression
label: (identifier) @function label: (identifier) @function
(block)) (block))
; Parameter declarations ; Parameter declarations
(parameter_declaration (parameter_declaration
command: (identifier) @keyword command: (identifier) @keyword
(identifier)? @constant.builtin (identifier)? @constant.builtin
macro: (macro) @parameter) macro: (macro) @parameter)
; Control flow ; Control flow
(if_block (if_block
command: (identifier) @conditional) command: (identifier) @conditional)
@ -135,8 +228,5 @@
(repeat_block (repeat_block
command: (identifier) @repeat) command: (identifier) @repeat)
(call_expression
function: (identifier) @function.builtin)
(type_identifier) @type
(comment) @comment @spell (comment) @comment @spell

View file

@ -13,7 +13,7 @@
(command_expression (command_expression
command: (identifier) command: (identifier)
arguments: (argument_list arguments: (argument_list
variable: (identifier) @definition.var)) declarator: (trace32_hll_variable) @definition.var))
; Function definitions ; Function definitions
(subroutine_block (subroutine_block
@ -32,4 +32,7 @@
(#set! reference.kind "function") (#set! reference.kind "function")
) )
(macro) @reference [
(macro)
(trace32_hll_variable)
] @reference