macro_rules! not {
($i:expr, $submac:ident!( $($args:tt)* )) => { ... };
}Expand description
Parses successfully if the given parser fails to parse. Does not consume any of the input.
- Syntax:
not!(THING) - Output:
()
extern crate syn;
#[macro_use] extern crate synom;
use synom::IResult;
// Parses a shebang line like `#!/bin/bash` and returns the part after `#!`.
// Note that a line starting with `#![` is an inner attribute, not a
// shebang.
named!(shebang -> &str, preceded!(
tuple!(tag!("#!"), not!(tag!("["))),
take_until!("\n")
));
fn main() {
let bin_bash = "#!/bin/bash\n";
let parsed = shebang(bin_bash).expect("shebang");
assert_eq!(parsed, "/bin/bash");
let inner_attr = "#![feature(specialization)]\n";
let err = shebang(inner_attr);
assert_eq!(err, IResult::Error);
}