Macro synom::tag
[−]
[src]
macro_rules! tag { ($i:expr, $tag:expr) => { ... }; }
Parse the given string from exactly the current position in the input. You
almost always want punct!
or keyword!
instead of this.
The tag!
parser is equivalent to punct!
but does not ignore leading
whitespace. Both punct!
and keyword!
skip over leading whitespace. See
an explanation of synom's whitespace handling strategy in the top-level
crate documentation.
- Syntax:
tag!("...")
- Output:
"..."
extern crate syn; #[macro_use] extern crate synom; use syn::StrLit; use syn::parse::string; use synom::IResult; // Parse a proposed syntax for an owned string literal: "abc"s named!(owned_string -> String, map!( terminated!(string, tag!("s")), |lit: StrLit| lit.value ) ); fn main() { let input = r#" "abc"s "#; let parsed = owned_string(input).expect("owned string literal"); println!("{:?}", parsed); let input = r#" "abc" s "#; let err = owned_string(input); assert_eq!(err, IResult::Error); }