macro_rules! punct {
($i:expr, $punct:expr) => { ... };
}Expand description
Parse a piece of punctuation like “+” or “+=”.
See also keyword! for parsing keywords, which are subtly different from
punctuation.
- Syntax:
punct!("...") - Output:
&str
extern crate syn;
#[macro_use] extern crate synom;
// Parse zero or more bangs.
named!(many_bangs -> Vec<&str>,
many0!(punct!("!"))
);
fn main() {
let input = "!! !";
let parsed = many_bangs(input).expect("bangs");
assert_eq!(parsed, ["!", "!", "!"]);
}