chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

wanted function

Open sineptic opened this issue 7 months ago • 5 comments

Is there any function that read only if in input pattern occurs EXACTLY N times. existed function exactly() read even if there more than N occurs.

// This don't work:
let pattern = || {...};
let a = || read_until(pattern().repeated().exactly(N).then_ignore(pattern().not().rewind()));
// Example
let N = 2;
let pattern = || just::<_, Simple<_>>('a');
let a = ...;
assert!(a().parse("aaa ").is_ok());

//  ++-        +++
// "a̲aa " -> "aa̲a "

And I can't read already processed input.

sineptic avatar Jul 23 '24 13:07 sineptic