Expand description
Typed Solidity AST deserialized from solc’s JSON output.
This module provides Rust structs that mirror the AST node types emitted
by the Solidity compiler (solc --standard-json), plus a lightweight
declaration extraction function (extract_decl_nodes) that avoids
deserializing the full AST.
§Design
- All structs derive
serde::Deserializeto parse directly from solc JSON. - Fields use
Option<T>liberally for cross-version compatibility. - An
AstVisitortrait (gated behind#[cfg(test)]) follows the official C++ASTConstVisitorpattern for test traversal.
Re-exports§
pub use contracts::*;pub use enums::*;pub use events::*;pub use expressions::*;pub use functions::*;pub use source_units::*;pub use statements::*;pub use types::*;pub use variables::*;pub use yul::*;
Modules§
- contracts
- Contract definition and related AST node types.
- enums
- Enum types used across the Solidity AST.
- events
- Event and error definition AST node types.
- expressions
- Expression AST node types.
- functions
- Function, modifier, and parameter list AST node types.
- source_
units - Source unit (file-level) AST node types.
- statements
- Statement AST node types.
- types
- Type name AST nodes.
- variables
- Variable declaration AST node types.
- yul
- Yul (inline assembly) AST node types.
Structs§
- External
Reference - External reference inside an
InlineAssemblynode. - Extracted
Decls - Result of extracting declaration nodes from the raw sources Value.
- Identifier
Path - An
IdentifierPathAST node — a dotted name likeIERC20orMyLib.add. - Structured
Documentation - A
StructuredDocumentationAST node. - Type
Descriptions - Type description attached to expressions and some declarations.
- Using
ForFunction - An entry in a
UsingForDirective’sfunctionList.
Enums§
- Decl
Node - A reference to any declaration-level AST node.
- Documentation
- Structured documentation (NatSpec) attached to declarations.
Functions§
- extract_
decl_ nodes - Extract declaration nodes directly from the raw
sourcessection of solc output. - format_
params_ typed - Format a typed
ParameterListinto a comma-separated parameter string. - type_
name_ to_ str - Extract a human-readable type string from a
TypeNamenode.
Type Aliases§
- NodeID
- AST node ID, matching solc’s signed 64-bit integer.