macro_rules! keyword {
($input:expr, $keyword:expr) => { ... };
}Expand description
keyword!(&[T]: nom::AsBytes) => &[T] -> Result<&[T], &[T]>
is an alias to the itag macro.
The goal of this alias is twofold:
- It avoids confusion and errors (a PHP keyword is always case-insensitive),
- It ensures a better readability of parsers.
ยงExamples
use tagua_parser::{
Result,
tokens
};
named!(
test<&[u8]>,
keyword!(tokens::CLASS)
);
let output = Result::Done(&b""[..], tokens::CLASS);
assert_eq!(test(&b"class"[..]), output);
assert_eq!(test(&b"ClAsS"[..]), output);