Implement the rematch target parser.

This commit is contained in:
Tom Alexander 2023-07-14 16:32:52 -04:00
parent 0014dfc21f
commit 66ae70e790
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -53,7 +53,25 @@ pub fn rematch_target<'r, 's>(
target: &'r Vec<Object<'s>>,
input: &'s str,
) -> Res<&'s str, Vec<Object<'s>>> {
todo!()
let mut remaining = input;
let mut new_matches = Vec::with_capacity(target.len());
for original_object in target {
match original_object {
// TODO: The rest of the minimal set of objects.
Object::PlainText(plaintext) => {
let (new_remaining, new_match) = plaintext.rematch_object(context, remaining)?;
remaining = new_remaining;
new_matches.push(new_match);
}
_ => {
return Err(nom::Err::Error(CustomError::MyError(MyError(
"OnlyMinimalSetObjectsAllowed",
))));
}
};
}
Ok((remaining, new_matches))
}
#[tracing::instrument(ret, level = "debug")]