Skip to main content

Module solc_ast

Module solc_ast 

Source
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::Deserialize to parse directly from solc JSON.
  • Fields use Option<T> liberally for cross-version compatibility.
  • An AstVisitor trait (gated behind #[cfg(test)]) follows the official C++ ASTConstVisitor pattern 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§

ExternalReference
External reference inside an InlineAssembly node.
ExtractedDecls
Result of extracting declaration nodes from the raw sources Value.
IdentifierPath
An IdentifierPath AST node — a dotted name like IERC20 or MyLib.add.
StructuredDocumentation
A StructuredDocumentation AST node.
TypeDescriptions
Type description attached to expressions and some declarations.
UsingForFunction
An entry in a UsingForDirective’s functionList.

Enums§

DeclNode
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 sources section of solc output.
format_params_typed
Format a typed ParameterList into a comma-separated parameter string.
type_name_to_str
Extract a human-readable type string from a TypeName node.

Type Aliases§

NodeID
AST node ID, matching solc’s signed 64-bit integer.