Skip to content

Commit

Permalink
Fix check_with_partial of RepMinMax.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheVeryDarkness authored and tomtau committed Mar 12, 2024
1 parent 8bb6982 commit ae7ddb6
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions pest/src/typed/template/repetition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,12 @@ impl<
stack: &mut Stack<Span<'i>>,
tracker: &mut Tracker<'i, R>,
) -> Option<Position<'i>> {
let mut vec = Vec::new();

for i in 0..MAX {
match restore_on_none(stack, |stack| {
try_parse_unit::<R, T, TRIVIA>(input, stack, tracker, i)
check_unit::<R, T, TRIVIA>(input, stack, tracker, i)
}) {
Some((next, matched)) => {
Some(next) => {
input = next;
vec.push(matched);
}
None => {
if i < MIN {
Expand Down Expand Up @@ -191,3 +188,18 @@ fn try_parse_unit<'i, R: RuleType, T: TypedNode<'i, R>, const TRIVIA: u8>(
input = next;
Some((input, matched))
}

#[inline]
fn check_unit<'i, R: RuleType, T: TypedNode<'i, R>, const TRIVIA: u8>(
mut input: Position<'i>,
stack: &mut Stack<Span<'i>>,
tracker: &mut Tracker<'i, R>,
i: usize,
) -> Option<Position<'i>> {
if i > 0 {
input = try_handle_trivia::<R, TRIVIA>(input, stack, tracker)?;
}
let next = T::check_with_partial(input, stack, tracker)?;
input = next;
Some(input)
}

0 comments on commit ae7ddb6

Please sign in to comment.