Veryl grammar for tree-sitter.
This is a tree-sitter parser for Veryl, a modern hardware description language based on SystemVerilog. This parser enables syntax highlighting and code analysis for Veryl in editors like Zed, Neovim, and others that support tree-sitter.
- Complete Veryl syntax support including:
- Module, interface, and package declarations
- Import statements
- Function declarations with parameters and return types
- Embed declarations for SystemVerilog integration
- Struct and enum types with attributes
- Type declarations and aliases
- Always blocks (always_comb, always_ff, initial)
- Control flow statements (if, else, for, case, switch, break, return)
- Veryl-specific features:
- if_reset statement for reset logic
- clock and reset types
- Concatenation with repeat syntax
- Case and if expressions
- Bit slicing and indexing
- System functions (e.g., $display, $sv::*)
- Scoped identifiers and namespaces
- Attributes (#[...])
- Built-in types (logic, bit, u32, u64, i32, clock, reset, string)
- Operators and expressions
- Comprehensive syntax highlighting queries
- Tested on real-world Veryl projects (zenbu, bluecore)
npm install
tree-sitter generateAdd the following to your Neovim configuration:
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.veryl = {
install_info = {
url = "https://github.com/hota1024/tree-sitter-veryl",
files = {"src/parser.c"},
branch = "main",
},
filetype = "veryl",
}
vim.filetype.add({
extension = {
veryl = "veryl",
},
})This parser can be integrated with Zed editor for Veryl syntax highlighting.
module Counter #(
param WIDTH: u32 = 8,
) (
clk: input clock,
rst: input reset,
count: output logic<WIDTH>,
) {
var counter: logic<WIDTH>;
always_ff (clk) {
if_reset {
counter = '0;
} else {
counter += 1;
}
}
assign count = counter;
}
Create a test file with .veryl extension and run:
tree-sitter parse your-file.veryltree-sitter highlight your-file.veryl- Veryl - The Veryl language compiler and tools
- Veryl Documentation - Official Veryl documentation