syn_solidity/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#![doc = include_str!("../README.md")]
#![doc(
    html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg",
    html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico"
)]
#![allow(missing_docs, missing_copy_implementations, clippy::missing_const_for_fn)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

extern crate proc_macro;

use syn::Result;

#[macro_use]
mod macros;

mod attribute;
pub use attribute::{
    FunctionAttribute, FunctionAttributes, Modifier, Mutability, Override, Storage,
    VariableAttribute, VariableAttributes, Visibility,
};

mod expr;
pub use expr::{
    ArgList, ArgListImpl, BinOp, Expr, ExprArray, ExprBinary, ExprCall, ExprCallOptions,
    ExprDelete, ExprIndex, ExprMember, ExprNew, ExprPayable, ExprPostfix, ExprTernary, ExprTuple,
    ExprTypeCall, ExprUnary, NamedArg, NamedArgList, PostUnOp, UnOp,
};

mod file;
pub use file::File;

mod ident;
pub use ident::{SolIdent, SolPath};

mod item;
pub use item::{
    ContractKind, EventParameter, FunctionBody, FunctionKind, ImportAlias, ImportAliases,
    ImportDirective, ImportGlob, ImportPath, ImportPlain, Inheritance, Item, ItemContract,
    ItemEnum, ItemError, ItemEvent, ItemFunction, ItemStruct, ItemUdt, PragmaDirective,
    PragmaTokens, Returns, UserDefinableOperator, UsingDirective, UsingList, UsingListItem,
    UsingType, Variant,
};

mod lit;
pub use lit::{
    HexStr, Lit, LitDenominated, LitHexStr, LitNumber, LitStr, LitUnicodeStr, SubDenomination,
    UnicodeStr,
};

pub mod kw;

pub mod spanned;
pub use spanned::Spanned;

mod stmt;
pub use stmt::{
    AssemblyFlags, Block, CatchClause, ForInitStmt, Stmt, StmtAssembly, StmtBreak, StmtContinue,
    StmtDoWhile, StmtEmit, StmtExpr, StmtFor, StmtIf, StmtReturn, StmtRevert, StmtTry, StmtVarDecl,
    StmtWhile, UncheckedBlock, VarDeclDecl, VarDeclTuple,
};

mod r#type;
pub use r#type::{Type, TypeArray, TypeFunction, TypeMapping, TypeTuple};

pub(crate) mod utils;

mod variable;
pub use variable::{FieldList, ParameterList, Parameters, VariableDeclaration, VariableDefinition};

#[cfg(feature = "visit")]
pub mod visit;
#[cfg(feature = "visit")]
pub use visit::Visit;

#[cfg(feature = "visit-mut")]
pub mod visit_mut;
#[cfg(feature = "visit-mut")]
pub use visit_mut::VisitMut;

mod yul;
pub use yul::{
    WalrusToken, YulBlock, YulCaseBranch, YulEVMBuiltIn, YulExpr, YulFnCall, YulFnType, YulFor,
    YulFunctionDef, YulIdent, YulIf, YulPath, YulReturns, YulStmt, YulSwitch, YulSwitchDefault,
    YulVarAssign, YulVarDecl,
};

/// Parse a Solidity [`proc_macro::TokenStream`] into a [`File`].
pub fn parse(input: proc_macro::TokenStream) -> Result<File> {
    syn::parse(input)
}

/// Parse a Solidity [`proc_macro2::TokenStream`] into a [`File`].
pub fn parse2(input: proc_macro2::TokenStream) -> Result<File> {
    syn::parse2(input)
}

const DEBUG: bool = option_env!("SYN_SOLIDITY_DEBUG").is_some();