oni_comb_parser/text/
lexeme.rs1use crate::combinator::zip_left::ZipLeft;
2use crate::input::Input;
3use crate::parser::Parser;
4use crate::parser_ext::ParserExt;
5use crate::primitive::take_while0::TakeWhile0;
6use crate::str_input::StrInput;
7use crate::text::take_while::take_while0;
8
9fn is_ws(c: char) -> bool {
10 c.is_ascii_whitespace()
11}
12
13pub type Lexeme<'a, P> = ZipLeft<P, TakeWhile0<fn(char) -> bool, StrInput<'a>>>;
15
16pub fn lexeme<'a, P>(parser: P) -> Lexeme<'a, P>
23where
24 P: Parser<StrInput<'a>, Error = <StrInput<'a> as Input>::Error>, {
25 parser.zip_left(take_while0(is_ws as fn(char) -> bool))
26}