parsers: add D parser

This commit is contained in:
Cezary Drożak 2021-10-01 11:33:33 +02:00 committed by Stephan Seitz
parent e87ed0fdaa
commit c2c454c29a
5 changed files with 300 additions and 0 deletions

View file

@ -85,6 +85,17 @@ list.cuda = {
maintainers = { "@theHamsta" },
}
list.d = {
install_info = {
url = "https://github.com/CyberShadow/tree-sitter-d",
files = { "src/parser.c", "src/scanner.cc" },
requires_generate_from_grammar = true,
},
maintainers = { "@nawordar" },
-- Generating grammar takes ~60s
experimental = true,
}
list.glsl = {
install_info = {
url = "https://github.com/theHamsta/tree-sitter-glsl",

1
queries/d/folds.scm Normal file
View file

@ -0,0 +1 @@
(block_statement) @fold

264
queries/d/highlights.scm Normal file
View file

@ -0,0 +1,264 @@
;; Misc
[
(line_comment)
(block_comment)
(nesting_block_comment)
] @comment
[
"(" ")"
"[" "]"
"{" "}"
] @punctuation.bracket
[
","
";"
"."
] @punctuation.delimiter
[
".."
"$"
] @punctuation.special
;; Constants
[
"__FILE_FULL_PATH__"
"__FILE__"
"__FUNCTION__"
"__LINE__"
"__MODULE__"
"__PRETTY_FUNCTION__"
] @constant.macro
(string_literals) @string
; Don't highlight token strings as strings
(token_string_tokens) @none
(character_literal) @character
(integer_literal) @number
(float_literal) @float
[
"true"
"false"
] @boolean
;; Functions
(func_declarator
(identifier) @function
)
[
"__traits"
"__vector"
"assert"
"is"
"mixin"
"pragma"
"typeid"
] @function.builtin
(import_expression
"import" @function.builtin
)
(parameter
(var_declarator
(identifier) @parameter
)
)
(function_literal
(identifier) @parameter
)
(constructor
"this" @constructor
)
(destructor
"this" @constructor
)
;; Keywords
[
"case"
"default"
"else"
"if"
"switch"
] @conditional
[
"break"
"continue"
"do"
"for"
"foreach"
"foreach_reverse"
"while"
] @repeat
[
"__gshared"
"__parameters"
"abstract"
"alias"
"align"
"asm"
"auto"
"body"
"class"
"const"
"debug"
"deprecated"
"enum"
"export"
"extern"
"final"
"goto"
"immutable"
"inout"
"interface"
"invariant"
"lazy"
"macro"
"nothrow"
"null"
"out"
"override"
"package"
"private"
"protected"
"public"
"pure"
"ref"
"scope"
"shared"
"static"
"struct"
"synchronized"
"template"
"union"
"unittest"
"version"
"with"
] @keyword
[
"delegate"
"function"
] @keyword.function
"return" @keyword.return
[
"cast"
"new"
] @keyword.operator
[
"+"
"++"
"+="
"-"
"--"
"-="
"*"
"*="
"%"
"%="
"^"
"^="
"^^"
"^^="
"/"
"/="
"|"
"|="
"||"
"~"
"~="
"="
"=="
"=>"
"<"
"<="
"<<"
"<<="
">"
">="
">>"
">>="
">>>"
">>>="
"!"
"!="
"&"
"&&"
] @operator
[
"catch"
"finally"
"throw"
"try"
] @exception
(module_declaration
"module" @include
)
(import_declaration
"import" @include
)
(type) @type
(catch_parameter
(qualified_identifier) @type
)
(var_declarations
(qualified_identifier) @type
)
(func_declaration
(qualified_identifier) @type
)
(parameter
(qualified_identifier) @type
)
(class_declaration
(identifier) @type
)
(fundamental_type) @type.builtin
[
(module_name)
(module_fully_qualified_name)
] @namespace
(at_attribute) @attribute
(user_defined_attribute
"@" @attribute
)
;; Variables
(primary_expression
"this" @variable.builtin
)

17
queries/d/indents.scm Normal file
View file

@ -0,0 +1,17 @@
[
(block_statement)
(case_statement)
(token_string)
] @indent
[
"(" ")"
"{" "}"
"[" "]"
] @branch
[
(line_comment)
(block_comment)
(nesting_block_comment)
] @ignore

7
queries/d/injections.scm Normal file
View file

@ -0,0 +1,7 @@
[
(line_comment)
(block_comment)
(nesting_block_comment)
] @comment
(token_string_tokens) @d