From b352f180ab191daacac38d7a77cf38bbd6a9670c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 21 Nov 2023 21:16:16 +0100 Subject: [PATCH] Import ISPC queries from https://github.com/nvim-treesitter/nvim-treesitter/tree/7da3cb6323d1e1fbfc4d7dc05cac74946458b8a0/queries/ispc instead These seem to have been removed from the main repo in: https://github.com/fab4100/tree-sitter-ispc/commit/0197076648b8f31aab85c447015f29dadb53a8b3 --- book/src/generated/lang-support.md | 2 +- runtime/queries/ispc/folds.scm | 8 + runtime/queries/ispc/highlights.scm | 226 ++++++++-------------------- runtime/queries/ispc/indents.scm | 7 + runtime/queries/ispc/injections.scm | 4 +- runtime/queries/ispc/locals.scm | 17 +++ 6 files changed, 96 insertions(+), 168 deletions(-) create mode 100644 runtime/queries/ispc/folds.scm create mode 100644 runtime/queries/ispc/indents.scm create mode 100644 runtime/queries/ispc/locals.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d65e2d67a..15ab23604 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -93,7 +93,7 @@ | iex | ✓ | | | | | ini | ✓ | | | | | inko | ✓ | ✓ | ✓ | | -| ispc | ✓ | | | | +| ispc | ✓ | | ✓ | | | janet | ✓ | | | | | java | ✓ | ✓ | ✓ | `jdtls` | | javascript | ✓ | ✓ | ✓ | `typescript-language-server` | diff --git a/runtime/queries/ispc/folds.scm b/runtime/queries/ispc/folds.scm new file mode 100644 index 000000000..45d0ba131 --- /dev/null +++ b/runtime/queries/ispc/folds.scm @@ -0,0 +1,8 @@ +; inherits: c + +[ + (foreach_statement) + (foreach_instance_statement) + (unmasked_statement) + (template_declaration) +] @fold diff --git a/runtime/queries/ispc/highlights.scm b/runtime/queries/ispc/highlights.scm index 553967288..6770d6bb9 100644 --- a/runtime/queries/ispc/highlights.scm +++ b/runtime/queries/ispc/highlights.scm @@ -1,144 +1,42 @@ -[ - "break" - "case" - "continue" - "default" - "else" - "enum" - "return" - "sizeof" - "struct" - "switch" - "typedef" - "union" - "soa" - "task" - "launch" - "unmasked" - "template" - "typename" - (sync_expression) - ] @keyword - -[ - "in" - "new" - "delete" - ] @keyword.operator +; inherits: c [ - "do" - "for" - "while" - "cdo" - "cfor" - "cwhile" - "foreach" - "foreach_tiled" - "foreach_active" - "foreach_unique" - ] @repeat + "soa" + "task" + "launch" + "unmasked" + "template" + "typename" + (sync_expression) +] @keyword [ - "if" - "cif" - ] @conditional + "in" + "new" + "delete" +] @keyword.operator [ - "int8" - "int16" - "int32" - "int64" - "uint8" - "uint16" - "uint32" - "uint64" - "float16" - "ptrdiff_t" - ] @type.builtin + "cdo" + "cfor" + "cwhile" + "foreach" + "foreach_tiled" + "foreach_active" + "foreach_unique" +] @repeat [ - "const" - "volatile" - "varying" - "uniform" - ] @type.qualifier + "cif" +] @conditional [ - "export" - "extern" - "inline" - "noinline" - "static" - ] @type.qualifier + "varying" + "uniform" +] @type.qualifier -"__vectorcall" @attribute "__regcall" @attribute -[ - "#define" - "#elif" - "#else" - "#endif" - "#if" - "#ifdef" - "#ifndef" - "#include" - (preproc_directive) - ] @preproc - -[ - "--" - "-" - "-=" - "->" - "=" - "!=" - "*" - "&" - "&&" - "+" - "++" - "+=" - "<" - "==" - ">" - "||" - ] @operator - -"." @delimiter -";" @delimiter - -(string_literal) @string -(system_lib_string) @string - -(null) @constant -(number_literal) @number -(char_literal) @number - -(call_expression - function: (identifier) @function) -(call_expression - function: (field_expression - field: (field_identifier) @function)) -(function_declarator - declarator: (identifier) @function) -(preproc_function_def - name: (identifier) @function.special) - -(field_identifier) @property -(statement_identifier) @label -(type_identifier) @type -(primitive_type) @type -(sized_type_specifier) @type - -((identifier) @constant - (#match? @constant "^[A-Z][A-Z\\d_]*$")) - -(identifier) @variable - -(comment) @comment - (overload_declarator name: _ @function) (foreach_statement range_operator: _ @operator) @@ -151,48 +49,48 @@ ; built-in variables ((identifier) @variable.builtin - (#any-of? @variable.builtin - "programCount" - "programIndex" - "taskCount" - "taskCount0" - "taskCount1" - "taskCount2" - "taskIndex" - "taskIndex0" - "taskIndex1" - "taskIndex2" - "threadCount" - "threadIndex" - )) + (#any-of? @variable.builtin + "programCount" + "programIndex" + "taskCount" + "taskCount0" + "taskCount1" + "taskCount2" + "taskIndex" + "taskIndex0" + "taskIndex1" + "taskIndex2" + "threadCount" + "threadIndex" + )) ; preprocessor constants ((identifier) @constant.builtin - (#any-of? @constant.builtin - "ISPC" - "ISPC_FP16_SUPPORTED" - "ISPC_FP64_SUPPORTED" - "ISPC_LLVM_INTRINSICS_ENABLED" - "ISPC_MAJOR_VERSION" - "ISPC_MINOR_VERSION" - "ISPC_POINTER_SIZE" - "ISPC_TARGET_AVX" - "ISPC_TARGET_AVX2" - "ISPC_TARGET_AVX512KNL" - "ISPC_TARGET_AVX512SKX" - "ISPC_TARGET_AVX512SPR" - "ISPC_TARGET_NEON" - "ISPC_TARGET_SSE2" - "ISPC_TARGET_SSE4" - "ISPC_UINT_IS_DEFINED" - "PI" - "TARGET_ELEMENT_WIDTH" - "TARGET_WIDTH" - )) + (#any-of? @constant.builtin + "ISPC" + "ISPC_FP16_SUPPORTED" + "ISPC_FP64_SUPPORTED" + "ISPC_LLVM_INTRINSICS_ENABLED" + "ISPC_MAJOR_VERSION" + "ISPC_MINOR_VERSION" + "ISPC_POINTER_SIZE" + "ISPC_TARGET_AVX" + "ISPC_TARGET_AVX2" + "ISPC_TARGET_AVX512KNL" + "ISPC_TARGET_AVX512SKX" + "ISPC_TARGET_AVX512SPR" + "ISPC_TARGET_NEON" + "ISPC_TARGET_SSE2" + "ISPC_TARGET_SSE4" + "ISPC_UINT_IS_DEFINED" + "PI" + "TARGET_ELEMENT_WIDTH" + "TARGET_WIDTH" + )) ; standard library built-in ((type_identifier) @type.builtin - (#lua-match? @type.builtin "^RNGState")) + (#lua-match? @type.builtin "^RNGState")) (call_expression function: (identifier) @function.builtin diff --git a/runtime/queries/ispc/indents.scm b/runtime/queries/ispc/indents.scm new file mode 100644 index 000000000..cc0829d5c --- /dev/null +++ b/runtime/queries/ispc/indents.scm @@ -0,0 +1,7 @@ +; inherits: c + +((foreach_statement body: (_) @_body) @indent.begin + (#not-has-type? @_body compound_statement)) + +((foreach_instance_statement body: (_) @_body) @indent.begin + (#not-has-type? @_body compound_statement)) diff --git a/runtime/queries/ispc/injections.scm b/runtime/queries/ispc/injections.scm index afeb068a2..a5a5208ca 100644 --- a/runtime/queries/ispc/injections.scm +++ b/runtime/queries/ispc/injections.scm @@ -1,3 +1 @@ -(preproc_arg) @c - -(comment) @comment +; inherits: c diff --git a/runtime/queries/ispc/locals.scm b/runtime/queries/ispc/locals.scm new file mode 100644 index 000000000..8eca18c67 --- /dev/null +++ b/runtime/queries/ispc/locals.scm @@ -0,0 +1,17 @@ +; inherits: c + +(reference_declarator + (identifier) @definition.var) + +(type_parameter_declaration + (type_identifier) @definition.type) +(template_declaration) @scope + +(template_function + name: (identifier) @definition.function) @scope + +[ + (foreach_statement) + (foreach_instance_statement) + (unmasked_statement) +] @scope