Macro synom::punct [] [src]

macro_rules! punct {
    ($i:expr, $punct:expr) => { ... };
}

Parse a piece of punctuation like "+" or "+=".

See also keyword! for parsing keywords, which are subtly different from punctuation.

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, ["!", "!", "!"]);
}