Switch to using plain text with no additional exit matcher added.

This commit is contained in:
Tom Alexander
2023-04-22 22:06:34 -04:00
parent 208e2cfe87
commit f964481544
2 changed files with 16 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
use nom::branch::alt;
use nom::character::complete::anychar;
use nom::character::complete::line_ending;
use nom::character::complete::multispace0;
use nom::character::complete::none_of;
@@ -8,7 +9,9 @@ use nom::combinator::not;
use nom::combinator::opt;
use nom::combinator::peek;
use nom::combinator::recognize;
use nom::combinator::verify;
use nom::multi::many0;
use nom::multi::many_till;
use nom::sequence::tuple;
use super::parser_context::ContextElement;
@@ -203,6 +206,14 @@ pub fn whitespace_eof(input: &str) -> Res<&str, &str> {
recognize(tuple((multispace0, eof)))(input)
}
#[tracing::instrument(ret, level = "debug")]
pub fn text_until_exit<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
recognize(verify(
many_till(anychar, parser_with_context!(exit_matcher_parser)(context)),
|(children, _exit_contents)| !children.is_empty(),
))(input)
}
#[cfg(test)]
mod tests {
use super::*;