Skip to content

Add CUDA C++ syntax support - #3987

Open
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:cuda-syntax-1054-20260907
Open

Add CUDA C++ syntax support#3987
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:cuda-syntax-1054-20260907

Conversation

@Matei02355

Copy link
Copy Markdown
Contributor

Add CUDA C++ highlighting for .cu and .cuh files, with original kernel, vector/header and launch examples for syntax regression tests.

Adapt the CUDA patterns from harrism/sublimetext-cuda-cpp at 2bf66d15322717284a6d101f99ec8b72c98c1c1d, preserving its NVIDIA BSD license. The original top-level C++ include consumes nested function contexts before the CUDA patterns can match. Derive the native CUDA syntax from the pinned Sublime Packages C++ grammar instead, applying a small patch to its modifiers, types, variables and expression contexts. Preserve the Sublime grammar's permissive license as well.

Handle CUDA qualifiers, vector types, built-in variables, intrinsics, launch bounds and kernel launch delimiters, including templated, namespaced and multiline launches. Keep comments, quoted strings and raw strings in their C++ contexts. Correct the original printf regex. Ordinary C++ mappings are unchanged.

The asset build creates the derived syntax, builds the cache, then removes the generated file through its cleanup trap. The source patch must apply without fuzz, so future C++ updates require review. No generated binary cache is committed.

Validation: three new syntax fixtures match an actual source-built cache; 43 parser-scope assertions cover CUDA tokens and comment/string isolation. All existing context references still link. C++ and .h control output is byte-for-byte unchanged. The generator reproduced the expected syntax, acknowledgement generation accepted both licenses, shell syntax checks passed, and the repository license check passed. The updated-assets CI job will exercise the complete asset-build integration.

Fixes #1054.

@Matei02355
Matei02355 marked this pull request as ready for review September 7, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cuda C++

1 participant