[−][src]Macro syn::do_parse
Run a series of parsers, optionally naming each intermediate result, followed by a step to combine the intermediate results.
Produces the result of evaluating the final expression in parentheses with all of the previously named results bound.
- Syntax:
do_parse!(name: THING1 >> THING2 >> (RESULT))
- Output:
RESULT
#[macro_use] extern crate syn; extern crate proc_macro2; use syn::Ident; use syn::token::Paren; use syn::synom::Synom; use proc_macro2::TokenStream; /// Parse a macro invocation that uses `(` `)` parentheses. /// /// Example: `stringify!($args)`. struct Macro { name: Ident, bang_token: Token![!], paren_token: Paren, tts: TokenStream, } impl Synom for Macro { named!(parse -> Self, do_parse!( name: syn!(Ident) >> bang_token: punct!(!) >> body: parens!(syn!(TokenStream)) >> (Macro { name, bang_token, paren_token: body.0, tts: body.1, }) )); }
This macro is available if Syn is built with the "parsing"
feature.