pub trait Parser: Sized {
type Output;
fn parse2(self, tokens: TokenStream) -> Result<Self::Output>;
fn parse(self, tokens: TokenStream) -> Result<Self::Output> { ... }
fn parse_str(self, s: &str) -> Result<Self::Output> { ... }
}
Expand description
Parser that can parse Rust tokens into a particular syntax tree node.
Refer to the module documentation for details about parsing in Syn.
This trait is available if Syn is built with the "parsing"
feature.
Required Associated Types
Required Methods
sourcefn parse2(self, tokens: TokenStream) -> Result<Self::Output>
fn parse2(self, tokens: TokenStream) -> Result<Self::Output>
Parse a proc-macro2 token stream into the chosen syntax tree node.
Provided Methods
sourcefn parse(self, tokens: TokenStream) -> Result<Self::Output>
fn parse(self, tokens: TokenStream) -> Result<Self::Output>
Parse tokens of source code into the chosen syntax tree node.
This method is available if Syn is built with both the "parsing"
and
"proc-macro"
features.