4 releases
| 0.1.4 | Sep 28, 2025 |
|---|---|
| 0.1.3 | Sep 21, 2025 |
| 0.1.2 | Sep 19, 2025 |
| 0.1.1 | Sep 19, 2025 |
#62 in #solidity
182 downloads per month
Used in 2 crates
(via traverse-codegen)
225KB
5.5K
SLoC
traverse-solidity
Core Solidity parsing and analysis functionality for the Traverse suite.
Overview
This crate provides the foundational Solidity parsing capabilities using tree-sitter, enabling syntactic analysis of smart contracts. It serves as the backbone for all Traverse tools that need to understand Solidity code structure.
Features
- Fast, incremental parsing using tree-sitter
- Complete Solidity syntax support
- AST traversal utilities
- Source location tracking
- Comment preservation
Usage
use traverse_solidity::parse_solidity;
fn main() {
let source_code = r#"
contract Example {
function hello() public pure returns (string memory) {
return "Hello, World!";
}
}
"#;
let tree = parse_solidity(source_code);
// Process the syntax tree
}
Tree-sitter Grammar
This crate uses a customized tree-sitter grammar for Solidity that provides comprehensive coverage of Solidity syntax including:
- All contract types (contracts, interfaces, libraries, abstract contracts)
- Solidity 0.8+ features
- Inline assembly (Yul)
- NatSpec comments
Part of Traverse
This crate is part of the Traverse suite of tools for Solidity code analysis, visualization, and test generation.
License
MIT OR Apache-2.0
Dependencies
~7–9.5MB
~101K SLoC