Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for language t32 #7140

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
| svelte | ✓ | | | `svelteserver` |
| sway | ✓ | ✓ | ✓ | `forc` |
| swift | ✓ | | | `sourcekit-lsp` |
| t32 | ✓ | | | |
| tablegen | ✓ | ✓ | ✓ | |
| task | ✓ | | | |
| tfvars | ✓ | | ✓ | `terraform-ls` |
Expand Down
13 changes: 13 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2605,3 +2605,16 @@ indent = { tab-width = 3, unit = " " }
[[grammar]]
name = "forth"
source = { git = "https://github.com/alexanderbrevig/tree-sitter-forth", rev = "c6fae50a17763af827604627c0fa9e4604aaac0b" }

[[language]]
name = "t32"
scope = "source.t32"
injection-regex = "t32"
file-types = ["cmm", "t32"]
roots = []
comment-token = ";"
indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "t32"
source = { git = "https://codeberg.org/xasc/tree-sitter-t32", rev = "1dd98248b01e4a3933c1b85b58bab0875e2ba437" }
145 changes: 145 additions & 0 deletions runtime/queries/t32/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
[
"="
"^^"
"||"
"&&"
"+"
"-"
"*"
"/"
"%"
"|"
"^"
"=="
"!="
">"
">="
"<="
"<"
"<<"
">>"
".."
"--"
"++"
"+"
"-"
"~"
"!"
"&"
"->"
"*"
] @operator

[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket

[
","
"."
";"
] @punctuation.delimiter

; Constants
[
(access_class)
(address)
(bitmask)
(file_handle)
(frequency)
(time)
] @constant.builtin

[
(float)
(percentage)
] @constant.numeric.float

(integer) @constant.numeric.integer

(character) @constant.character

; Strings
(string) @string

(path) @string.special.path

(symbol) @string.special.symbol

; Returns
(
(command_expression
command: (identifier) @keyword.return)
(#match? @keyword.return "^[eE][nN][dD]([dD][oO])?$")
)
(
(command_expression
command: (identifier) @keyword.return)
(#match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$")
)

; Subroutine calls
(subroutine_call_expression
command: (identifier) @keyword
subroutine: (identifier) @function)

; Subroutine blocks
(subroutine_block
command: (identifier) @keyword
subroutine: (identifier) @function)

(labeled_expression
label: (identifier) @function
(block))

; Parameter declarations
(parameter_declaration
command: (identifier) @keyword
(identifier)? @constant.builtin
macro: (macro) @variable.parameter)

; Variables, constants and labels
(macro) @variable
(internal_c_variable) @variable

(
(command_expression
command: (identifier) @keyword
arguments: (argument_list . (identifier) @label))
(#match? @keyword "^[gG][oO][tT][oO]$")
)
(labeled_expression
label: (identifier) @label)

(
(argument_list (identifier) @constant.builtin)
(#match? @constant.builtin "^[%/][a-zA-Z][a-zA-Z0-9.]*$")
)
(argument_list
(identifier) @constant)

; Commands
(command_expression command: (identifier) @keyword)
(macro_definition command: (identifier) @keyword)

; Control flow
(if_block
command: (identifier) @keyword.control.conditional.if)
(else_block
command: (identifier) @keyword.control.control.else)

(while_block
command: (identifier) @keyword.control.repeat.while)
(repeat_block
command: (identifier) @keyword.control.loop)

(call_expression
function: (identifier) @function)

(type_identifier) @type
(comment) @comment
2 changes: 2 additions & 0 deletions runtime/queries/t32/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))