traverse-solidity

Crates.iotraverse-solidity
lib.rstraverse-solidity
version0.1.4
created_at2025-09-19 03:08:17.788473+00
updated_at2025-09-28 06:19:30.253129+00
descriptionSolidity language parser and AST for code analysis
homepagehttps://github.com/calltrace/traverse
repositoryhttps://github.com/calltrace/traverse
max_upload_size
id1845718
size228,261
Gianluca Brigandi (gbrigandi)

documentation

https://docs.rs/traverse-solidity

README

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

Commit count: 232

cargo fmt