Expand description
§solar-ast
Solidity and Yul AST (Abstract Syntax Tree) type and visitor trait definitions.
Modules§
- either
- The enum
Eitherwith variantsLeftandRightis a general purpose sum type with two cases. - interface
- solar-interface
- token
- Solidity source code token.
- visit
- Constant and mutable AST visitor trait definitions.
- yul
- Yul AST.
Structs§
- Arena
- AST arena allocator.
- AstPath
- A boxed
PathSlice. - BinOp
- A binary operation:
a + b,a += b. - Block
- A block of statements.
- Call
Args - A list of function call arguments.
- DocComment
- A single doc-comment:
/// foo,/** bar */. - DocComments
- A list of doc-comments.
- Expr
- An expression.
- Function
Header - A function header:
function helloWorld() external pure returns(string memory). - Ident
- An identifier.
- Import
Directive - An import directive:
import "foo.sol";. - Item
- A top-level item in a Solidity source file.
- Item
Contract - A contract, abstract contract, interface, or library definition:
contract Foo layout at 10 is Bar("foo"), Baz { ... }. - Item
Enum - An enum definition:
enum Foo { A, B, C }. - Item
Error - An error definition:
error Foo(uint256 a, uint256 b);. - Item
Event - An event definition:
event Transfer(address indexed from, address indexed to, uint256 value);. - Item
Function - A function, constructor, fallback, receive, or modifier definition:
function helloWorld() external pure returns(string memory);. - ItemId
- A source unit item ID. Only used in
SourceUnit. - Item
Struct - A struct definition:
struct Foo { uint256 bar; }. - Item
Udvt - A user-defined value type definition:
type Foo is uint256;. - Lit
- A literal:
hex"1234",5.6 ether. - Modifier
- A modifier invocation, or an inheritance specifier.
- Named
Arg - A named argument:
name: value. - Override
- An override specifier:
override,override(a, b.c). - Parameter
List - A list of variable declarations and its span, which includes the brackets.
- Path
- A qualified identifier:
foo.bar.baz. - Path
Slice - A qualified identifier:
foo.bar.baz. - Pragma
Directive - A pragma directive:
pragma solidity ^0.8.0;. - Semver
Req - A SemVer version requirement. This is a list of components, and is never empty.
- Semver
ReqComponent - A single SemVer version requirement component.
- Semver
ReqCon - A list of conjoint SemVer version requirement components.
- Semver
Version - A SemVer version.
- Semver
Version ReqCompat - A list of or-ed
semver::VersionReq. - Source
Unit - A Solidity source file.
- Span
- A source code location.
- Spanned
- A value paired with a source code location.
- Stmt
- A statement, usually ending in a semicolon.
- Stmt
Assembly - An assembly block, with optional flags:
assembly "evmasm" (...) { ... }. - StmtTry
- A try statement:
try fooBar(42) returns (...) { ... } catch (...) { ... }. - Storage
Layout Specifier - The storage layout specifier of a contract.
- StrLit
- A single UTF-8 string literal. Only used in import paths and statements, not expressions.
- Symbol
- An interned string.
- TryCatch
Clause - Clause of a try/catch block:
returns/catch (...) { ... }. - Type
- A type name.
- Type
Array - An array type.
- Type
Fixed Size - Size of a fixed-point number (N) type. Valid values: 0..=80.
- Type
Function - A function type name.
- Type
Mapping - A mapping type.
- Type
Size - Byte size of a fixed-bytes, integer, or fixed-point number (M) type. Valid values: 0..=32.
- UnOp
- A unary operation:
!x,-x,x++. - Using
Directive - A
usingdirective:using { A, B.add as + } for uint256 global;. - Variable
Definition - A state variable or constant definition:
uint256 constant FOO = 42;.
Enums§
- Base
- Base of numeric literal encoding according to its prefix.
- BinOp
Kind - A kind of binary operation.
- Call
Args Kind - A list of function call argument expressions.
- Comment
Kind - The type of a comment.
- Contract
Kind - The kind of contract.
- Data
Location - A storage location.
- Either
- The enum
Eitherwith variantsLeftandRightis a general purpose sum type with two cases. - Elementary
Type - Elementary/primitive type.
- Ether
SubDenomination - An ether
SubDenomination. - Expr
Kind - A kind of expression.
- Function
Kind - A kind of function.
- Ident
OrStr Lit - An identifier or a string literal.
- Import
Items - The path of an import directive.
- Index
Kind - A kind of square bracketed indexing expression:
vector[index],slice[l:r]. - Item
Kind - An AST item. A more expanded version of a Solidity source unit.
- LitKind
- A kind of literal.
- Pragma
Tokens - The parsed or unparsed tokens of a pragma directive.
- Semver
Op - SemVer comparison operator:
=,>,>=,<,<=,~,^,*. - Semver
ReqComponent Kind - A SemVer version requirement component.
- Semver
Version Number - A SemVer version number.
- State
Mutability - Stmt
Kind - A kind of statement.
- StrKind
- A string literal kind.
- SubDenomination
- A number sub-denomination.
- Time
SubDenomination - A time
SubDenomination. - Type
Kind - The kind of a type.
- UnOp
Kind - A kind of unary operation.
- User
Definable Operator - A user-definable operator:
+,*,|, etc. - Using
List - The path list of a
usingdirective. - VarMut
- The mutability of a variable.
- Visibility
- Visibility ordered from restricted to unrestricted.
Traits§
Type Aliases§
- Box
- AST box. Allocated on the AST arena.
- BoxSlice
- AST box slice. Allocated on the AST arena.
- Named
ArgList - A list of named arguments:
{a: "1", b: 2}.