[−][src]Function lip::take_chomped
pub fn take_chomped<'a, P, A, S: Clone + 'a>(
parser: P
) -> impl Parser<'a, String, S> where
P: Parser<'a, A, S>,
Take the chomped string from a bunch of chompers.
Sometimes parsers like int
or variable
cannot do exactly what you need.
The "chomping" family of functions is meant for that case!
Maybe you need to parse valid PHP variables like $x
and $txt
:
fn php_variable<'a, S: Clone + 'a>() -> impl Parser<'a, String, S> { take_chomped(succeed!(()) .skip(chomp_if(|c: &char| *c == '$', "a '$'")) .skip(chomp_if(|c: &char| c.is_alphabetic() || *c == '_', "a letter or a '_'")) .skip(chomp_while0(|c: &char| c.is_alphanumeric() || *c == '_', "a letter, digit, or '_'")) ) }