Macro unrest_tmp_synom::do_parse
[−]
[src]
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, one after another, optionally assigning the results a name. Fail if any of the parsers fails.
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
extern crate syn; #[macro_use] extern crate synom; extern crate proc_macro2; use syn::{Ident, TokenTree}; use synom::tokens::{Bang, Paren}; use proc_macro2::TokenStream; // Parse a macro invocation like `stringify!($args)`. named!(simple_mac -> (Ident, (TokenStream, Paren)), do_parse!( name: syn!(Ident) >> syn!(Bang) >> body: parens!(syn!(TokenStream)) >> (name, body) ));