pub fn recognize<F, Input, P>(parser: P) -> Recognize<F, P> where
Input: Stream,
P: Parser<Input>,
F: Default + Extend<<Input as StreamOnce>::Token>,
Expand description
Constructs a parser which returns the tokens parsed by parser
accumulated in
F: Extend<Input::Token>
instead of P::Output
.
use combine::Parser;
use combine::parser::{repeat::skip_many1, token::token, combinator::recognize, char::digit};
let mut parser = recognize((skip_many1(digit()), token('.'), skip_many1(digit())));
assert_eq!(parser.parse("123.45"), Ok(("123.45".to_string(), "")));
assert_eq!(parser.parse("123.45"), Ok(("123.45".to_string(), "")));