tree-sitter-verilog

SystemVerilog and Verilog grammar for the tree-sitter incremental parser.

Library
PyPI
v1.0.3
123stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity0
Maintenance20
Community72
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
70/100Good
Architecture74
Code Quality68
Innovation66
Learning Curve72

tree-sitter-verilog is a grammar for the tree-sitter parsing framework that parses Verilog and SystemVerilog source code into a concrete syntax tree. It defines the language’s rules in tree-sitter’s grammar DSL and ships bindings — including a Python package on PyPI — so tools can build fast, error-tolerant parsers for hardware description code.

tree-sitter grammars power features like syntax highlighting, structural navigation, and code analysis in editors and developer tools. This grammar brings that capability to the Verilog/SystemVerilog ecosystem.

What You Get

  • A tree-sitter grammar covering Verilog and SystemVerilog syntax
  • A Python binding exposing the grammar as a tree-sitter Language
  • Concrete syntax trees suitable for highlighting and structural analysis
  • Cross-ecosystem availability (npm, crates, and PyPI) from one grammar

Common Use Cases

  • Adding Verilog/SystemVerilog syntax highlighting to an editor
  • Building static-analysis or linting tools for HDL code
  • Extracting structure (modules, ports, always blocks) from source

Under The Hood

Architecture - The grammar is authored in JavaScript using tree-sitter’s grammar DSL (grammar.js), from which tree-sitter generates a C parser and the parser tables. Language bindings (Python, Node, Rust) wrap that generated parser so host programs can load the grammar and produce a syntax tree that tree-sitter keeps updated incrementally as source changes.

Tech Stack - Almost entirely JavaScript grammar definition (~99%) compiled to C via the tree-sitter CLI. The Python distribution packages the generated C parser as a native extension consumed through the tree-sitter Python runtime; the same grammar is also published to npm and crates.io.

Code Quality - A mature grammar (created in 2018, 328 commits, multiple contributors) with CI configured in the repository. Recent development activity is low and it is currently marked inactive, but its coverage of the large SystemVerilog language and its adoption across editors indicate a well-exercised parser.

API Design - Usage follows the standard tree-sitter pattern: load the language, create a Parser, set the language, and parse source into a tree that can be walked or queried. There is no bespoke API to learn beyond tree-sitter’s, so anyone familiar with other tree-sitter grammars can adopt it immediately.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search