pub fn take_until<A>(until: A) -> TakeUntil<A>
Expand description

A parser that accepts any number of inputs until a terminating pattern is reached.

The output type of this parser is (Vec<I>, O), a combination of the preceding inputs and the output of the final patterns.

Examples

let single_line = just::<_, _, Simple<char>>("//")
    .then(take_until(text::newline()))
    .ignored();

let multi_line = just::<_, _, Simple<char>>("/*")
    .then(take_until(just("*/")))
    .ignored();

let comment = single_line.or(multi_line);

let tokens = text::ident()
    .padded()
    .padded_by(comment
        .padded()
        .repeated())
    .repeated();

assert_eq!(tokens.parse(r#"
    // These tokens...
    these are
    /*
        ...have some
        multi-line...
    */
    // ...and single-line...
    tokens
    // ...comments between them
"#), Ok(vec!["these".to_string(), "are".to_string(), "tokens".to_string()]));