[][src]Macro syn::do_parse

macro_rules! do_parse {
    ($i:expr, ( $($rest:expr),* )) => { ... };
    ($i:expr, $e:ident >> $($rest:tt)*) => { ... };
    ($i:expr, $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { ... };
    ($i:expr, $field:ident : $e:ident >> $($rest:tt)*) => { ... };
    ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { ... };
    ($i:expr, mut $field:ident : $e:ident >> $($rest:tt)*) => { ... };
    ($i:expr, mut $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { ... };
}

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.

#[macro_use]
extern crate syn;
extern crate proc_macro2;

use proc_macro2::Ident;
use proc_macro2::TokenStream;
use syn::token::Paren;
use syn::synom::Synom;

/// 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.