tree-sitter-verilog
raw JSON → 1.0.3 verified Sat May 09 auth: no python
Verilog grammar for tree-sitter. Version 1.0.3, updated 2025. Low cadence; provides a parser for Verilog and SystemVerilog files, used with the tree-sitter parsing library.
pip install tree-sitter-verilog Common errors
error AttributeError: module 'tree_sitter_verilog' has no attribute 'language' ↓
cause Old import pattern using `language` instead of `language_verilog`.
fix
Use
from tree_sitter_verilog import language_verilog and call language_verilog(). error TypeError: Language() argument after * must be an iterable, not function ↓
cause Passing the language function directly instead of calling it.
fix
Call the function:
Language(tsverilog.language_verilog()). Warnings
breaking The language function changed from `language` to `language_verilog` in v1.0.0. Old code using `from tree_sitter_verilog import language` will break. ↓
fix Change import to `from tree_sitter_verilog import language_verilog` and call `language_verilog()`.
deprecated tree-sitter versions below 0.20 are no longer supported. This grammar uses the newer API. ↓
fix Upgrade tree-sitter to >=0.20.
gotcha The grammar is for Verilog and SystemVerilog. However, some SystemVerilog constructs may not be fully supported. Check the grammar's issue tracker for known limitations. ↓
fix Test edge cases against the grammar's test suite.
Imports
- language_verilog
from tree_sitter_verilog import language_verilog - Language wrong
from tree_sitter_verilog import Languagecorrectfrom tree_sitter import Language
Quickstart
import tree_sitter_verilog as tsverilog
from tree_sitter import Language, Parser
# Build Language object from grammar
VERILOG_LANGUAGE = Language(tsverilog.language_verilog())
# Initialize parser
parser = Parser(VERILOG_LANGUAGE)
# Parse a snippet
tree = parser.parse(bytes("module test; wire a; endmodule", "utf8"))
root_node = tree.root_node
print(root_node.sexp())