Skip to content

feat: add @ast-grep/lang-systemverilog package#165

Open
babyworm wants to merge 2 commits intoast-grep:mainfrom
babyworm:feat/add-systemverilog
Open

feat: add @ast-grep/lang-systemverilog package#165
babyworm wants to merge 2 commits intoast-grep:mainfrom
babyworm:feat/add-systemverilog

Conversation

@babyworm
Copy link

@babyworm babyworm commented Feb 23, 2026

As suggested in ast-grep/ast-grep#2477 (comment), adding the NAPI language package to langs.

Summary

  • Add @ast-grep/lang-systemverilog for NAPI SystemVerilog support (.v, .vh, .sv, .svh)
  • Uses tree-sitter-systemverilog v0.3.1 via GitHub URL (not published on npm)
  • expandoChar: '_'$ is reserved for SystemVerilog system tasks (IEEE 1800-2017 §5.6)

Test plan

  • pnpm source / pnpm build / pnpm test all pass
  • Nursery tests: module parsing, pattern matching (module_declaration), $display parsing, always_ff pattern
  • oxlint clean (0 warnings, 0 errors)

Summary by CodeRabbit

  • New Features
    • Introduced SystemVerilog language support for ast-grep, enabling pattern matching and abstract syntax tree analysis for SystemVerilog code.
    • Supports file extensions: .v, .vh, .sv, .svh.
    • Includes comprehensive documentation and setup instructions for integration.

babyworm and others added 2 commits February 24, 2026 00:00
Add SystemVerilog language support to the langs monorepo.
Uses tree-sitter-systemverilog from GitHub (npm unpublished).
Supports .v, .vh, .sv, .svh extensions with '_' expando char.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pin GitHub dependency to v0.3.1 tag for reproducible builds.
Add assert.equal for node kind and always_ff pattern matching test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 23, 2026

📝 Walkthrough

Walkthrough

This PR introduces SystemVerilog language support to ast-grep by adding a new language package with parser configuration, runtime initialization, TypeScript definitions, setup automation, and test coverage for SystemVerilog file extensions (.v, .vh, .sv, .svh).

Changes

Cohort / File(s) Summary
Package Configuration
packages/systemverilog/package.json, packages/systemverilog/postinstall.js
New package manifest defining build, test, and postinstall scripts; runtime dependency on @ast-grep/setup-lang; postinstall hook for automated setup.
Language Integration
packages/systemverilog/index.js, packages/systemverilog/index.d.ts
JavaScript module with lazy-loaded parser path resolution and configuration object exposing libraryPath, extensions (v, vh, sv, svh), languageSymbol, and expandoChar; TypeScript type definitions for LanguageRegistration.
Documentation and Testing
packages/systemverilog/README.md, packages/systemverilog/nursery.js
README with installation and usage instructions; nursery test file covering module parsing, pattern matching for modules and always_ff blocks, and system task parsing.
Changelog
.changeset/add-systemverilog.md
Changeset entry documenting minor version bump for @ast-grep/lang-systemverilog with SystemVerilog file extension support.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: C# language #41: Adds a new language package following the same structural pattern with index.js, index.d.ts with LanguageRegistration, README, nursery tests, package.json, and postinstall setup.

Suggested reviewers

  • HerringtonDarkholme

Poem

🐰 A new language hops into our warren,
SystemVerilog files (.v, .vh, .sv, .svh) now welcomed with care,
Parser paths dance with lazy precision,
Tests verify each pattern match and declaration—
Ast-grep's garden grows more verdant! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding a new SystemVerilog language package to the ast-grep project.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/systemverilog/package.json (1)

41-41: Consider pinning tree-sitter-systemverilog to a commit SHA instead of a tag.

Git tags are mutable and can be force-pushed. For truly reproducible builds, a commit SHA (github:gmlarumbe/tree-sitter-systemverilog#<SHA>) is immutable.

♻️ Example
-    "tree-sitter-systemverilog": "github:gmlarumbe/tree-sitter-systemverilog#v0.3.1"
+    "tree-sitter-systemverilog": "github:gmlarumbe/tree-sitter-systemverilog#<commit-sha-for-v0.3.1>"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/systemverilog/package.json` at line 41, The dependency
"tree-sitter-systemverilog" in packages/systemverilog/package.json is using a
mutable tag; change the value from
"github:gmlarumbe/tree-sitter-systemverilog#v0.3.1" to the corresponding
immutable commit SHA (e.g.
"github:gmlarumbe/tree-sitter-systemverilog#<COMMIT_SHA>") so installs are
reproducible—locate the package.json entry for "tree-sitter-systemverilog",
replace the tag with the exact commit SHA that matches v0.3.1 (or the desired
commit), and save/update lockfile.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/systemverilog/package.json`:
- Line 41: The dependency "tree-sitter-systemverilog" in
packages/systemverilog/package.json is using a mutable tag; change the value
from "github:gmlarumbe/tree-sitter-systemverilog#v0.3.1" to the corresponding
immutable commit SHA (e.g.
"github:gmlarumbe/tree-sitter-systemverilog#<COMMIT_SHA>") so installs are
reproducible—locate the package.json entry for "tree-sitter-systemverilog",
replace the tag with the exact commit SHA that matches v0.3.1 (or the desired
commit), and save/update lockfile.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fdb7f6 and 09d4781.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/add-systemverilog.md
  • packages/systemverilog/README.md
  • packages/systemverilog/index.d.ts
  • packages/systemverilog/index.js
  • packages/systemverilog/nursery.js
  • packages/systemverilog/package.json
  • packages/systemverilog/postinstall.js

"devDependencies": {
"@ast-grep/nursery": "0.0.9",
"tree-sitter-cli": "0.25.8",
"tree-sitter-systemverilog": "github:gmlarumbe/tree-sitter-systemverilog#v0.3.1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you release it on npm instead of github?


node-gyp-build@4.8.4: {}

node-gyp@11.5.0:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node-gyp should not be added as dependencies.

I suspect tree-sitter-verilog is doing great here

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.

2 participants