Macro synom::keyword
[−]
[src]
macro_rules! keyword { ($i:expr, $keyword:expr) => { ... }; }
Parse a keyword like "fn" or "struct".
See also punct!
for parsing punctuation, which are subtly different from
keywords.
- Syntax:
keyword!("...")
- Output:
&str
extern crate syn; #[macro_use] extern crate synom; use synom::IResult; // Parse zero or more "bang" keywords. named!(many_bangs -> Vec<&str>, terminated!( many0!(keyword!("bang")), punct!(";") ) ); fn main() { let input = "bang bang bang;"; let parsed = many_bangs(input).expect("bangs"); assert_eq!(parsed, ["bang", "bang", "bang"]); let input = "bangbang;"; let err = many_bangs(input); assert_eq!(err, IResult::Error); }