Skip to content

feat: add CUDA (.cu/.cuh) and IEC 61131-3 SCL (.scl/.st) language support#875

Open
zouyuanqing wants to merge 2 commits into
colbymchenry:mainfrom
zouyuanqing:feat/cuda-scl-support
Open

feat: add CUDA (.cu/.cuh) and IEC 61131-3 SCL (.scl/.st) language support#875
zouyuanqing wants to merge 2 commits into
colbymchenry:mainfrom
zouyuanqing:feat/cuda-scl-support

Conversation

@zouyuanqing

@zouyuanqing zouyuanqing commented Jun 14, 2026

Copy link
Copy Markdown

Summary

Adds language support for CUDA (.cu\ / .cuh) and IEC 61131-3 SCL (.scl\ / .st).

CUDA — Closes #387

Type & extraction

  • New \cuda\ language type, mapped to \ ree-sitter-cpp.wasm\ + \cppExtractor\
  • .cu\ / .cuh\ extensions
  • CUDA is a C++ dialect. The C++ parser handles function definitions, structs, templates, and #include\ directives. Only <<<...>>>\ kernel launch syntax and _global_\ / _device_\ storage specifiers may parse as errors — the test comment explicitly documents this limitation.

Resolution pipeline (the part that makes this actually useful)

CUDA files now share the full C/C++ resolution path:

Module Change
\import-resolver.ts\ .cuh\ / .cu\ in extension resolution; -I\ include-dir search; standard library detection; import mappings (all gated with |
\
ame-matcher.ts\ CUDA added to C family (\c: 'c', cpp: 'c', cuda: 'c') for cross-language resolution
\index.ts\ Namespace filtering shared with C/C++

This means #include\ references from .cu\ files resolve to their headers, cross-file function calls produce edges, and .cu\ ↔ .cpp\ ↔ .h\ cross-references work correctly.

SCL (IEC 61131-3 ST) — Advances #441

  • New \scl\ language type, .scl\ / .st\ extensions
  • File-level tracking only (matching yaml/twig/properties conventions)
  • \GrammarLanguage\ type explicitly excludes \scl\ to prevent type errors
  • Fix: SCL files were silently dropped during single-file indexing — \isLanguageSupported\ now returns \ rue\

Tests (149 new lines)

SCL

  • Language detection by extension
  • Support / grammar-loaded / file-level-only flags
  • End-to-end file-record tracking: 2 ST files indexed, verified both appear in \getFiles()\ with correct \language: scl, zero symbol nodes

CUDA

  • Fixture extraction from realistic selective-scan kernel (\selective_scan.cu)
  • _global_\ and _host_\ functions extracted with \language: cuda\
  • #include <cuda_runtime.h>\ as import node
  • Function call edges within CUDA code
  • .cuh\ header struct definition extraction

Files changed

File + - Notes
\src/types.ts\ 2 0 LANGUAGES
\src/extraction/grammars.ts\ 7 2 EXTENSION_MAP, WASM, display, type fix
\src/extraction/languages/index.ts\ 1 0 cuda → cppExtractor
\src/resolution/import-resolver.ts\ 7 4 Full C++ resolution sharing
\src/resolution/index.ts\ 1 1 Namespace filtering
\src/resolution/name-matcher.ts\ 1 1 C family membership
_tests_/extraction.test.ts\ 149 1 SCL + CUDA test suites
_tests_/fixtures/cuda/selective_scan.cu\ 32 0 Real kernel fixture
\CHANGELOG.md\ 7 0 Unreleased entries

Total: +216 −10

Not in this PR

  • \ ree-sitter-cuda.wasm\ (separate grammar — can replace C++ wasm in follow-up)
  • SCL extractor (foundation only — \ ree-sitter-structured-text\ grammar exists and can be vendored in a follow-up)
  • PTX (.ptx) — no tree-sitter grammar; requires new grammar from scratch

…port

CUDA:
- New 'cuda' language type, reuses tree-sitter-cpp.wasm + cppExtractor
- Full C/C++ resolution pipeline integration: #include resolution,
  compile_commands.json -I directory search, standard library detection,
  import mappings all share CUDA path alongside C/C++
- Cross-language reference resolution: CUDA added to C family
  (c/cpp/cuda) in name-matcher, so .cu ↔ .c ↔ .cpp ↔ .h references
  resolve as same-family
- Extension resolution for .cuh/.cu in import-resolver

SCL (IEC 61131-3 Structured Text):
- New 'scl' language type, .scl/.st extensions
- File-level tracking only (matching yaml/twig/properties conventions)
- GrammarLanguage type fixed to exclude 'scl'
- Fix: SCL files no longer silently dropped during single-file
  indexing (isLanguageSupported now returns true)

Tests:
- SCL: language detection, grammar loaded, file-level-only flag,
  file-record tracking with zero-symbol validation
- CUDA: fixture extraction (selective_scan.cu kernel), #include
  import nodes, function call edges, .cuh struct extraction,
  language attribution on all node kinds

Closes colbymchenry#387, advances colbymchenry#441
@zouyuanqing zouyuanqing force-pushed the feat/cuda-scl-support branch from aa9e3e0 to a20629e Compare June 14, 2026 09:06
- tree-sitter.ts: chained call parsing (obj.method() via -> / .)
- callback-synthesizer.ts: C++ override edge synthesis (2 places)
- name-matcher.ts: bareFnOnly, dotMatch member resolution,
  C++ call chain resolution (Foo::instance().bar())

These 5 branches only gate on cpp/c — CUDA files would silently
miss callback synthesis, bare kernel-call resolution, and
method-call resolution on these paths.
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.

Title: Feature request: index .cu / .cuh CUDA source files

1 participant