This commit is contained in:
Tom Alexander 2023-04-03 15:15:16 -04:00
parent b65ed28462
commit 2d1df18544
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
8 changed files with 7 additions and 48 deletions

View File

@ -1,38 +0,0 @@
use nom::error::ParseError;
use nom::IResult;
use nom::InputLength;
use super::Context;
pub fn context_many1<'r: 's, 's, I, O, E, M>(
context: Context<'r, 's>,
mut many_matcher: M,
) -> impl FnMut(I) -> IResult<I, Vec<O>, E> + 'r
where
I: Clone + InputLength,
E: ParseError<I>,
M: for<'x> Fn(Context<'x, 's>, I) -> IResult<I, O, E> + 'r,
{
move |mut i: I| {
let mut err = None;
let mut elements: Vec<O> = Vec::new();
loop {
match many_matcher(&context, i.clone()) {
Ok((remaining, many_elem)) => {
i = remaining;
elements.push(many_elem);
}
the_error @ Err(_) => {
err = Some(the_error);
break;
}
}
}
if elements.is_empty() {
if let Some(err) = err {
err?;
}
}
Ok((i, elements))
}
}

View File

@ -25,7 +25,6 @@ use crate::parser::util::element_trailing_whitespace;
use super::element::Element; use super::element::Element;
use super::error::Res; use super::error::Res;
use super::object::Object; use super::object::Object;
use super::parser_context;
use super::parser_with_context::parser_with_context; use super::parser_with_context::parser_with_context;
use super::source::Source; use super::source::Source;
use super::util::exit_matcher_parser; use super::util::exit_matcher_parser;

View File

@ -18,7 +18,7 @@ impl<I> ParseError<I> for CustomError<I> {
CustomError::Nom(input, kind) CustomError::Nom(input, kind)
} }
fn append(input: I, kind: ErrorKind, mut other: Self) -> Self { fn append(_input: I, _kind: ErrorKind, mut other: Self) -> Self {
// Doesn't do append like VerboseError // Doesn't do append like VerboseError
other other
} }

View File

@ -1,4 +1,3 @@
mod combinator;
mod document; mod document;
mod element; mod element;
mod error; mod error;

View File

@ -9,8 +9,12 @@ use super::Context;
#[derive(Debug)] #[derive(Debug)]
pub enum Object<'s> { pub enum Object<'s> {
#[allow(dead_code)]
TextMarkup(TextMarkup<'s>), TextMarkup(TextMarkup<'s>),
PlainText(PlainText<'s>), PlainText(PlainText<'s>),
#[allow(dead_code)]
RegularLink(RegularLink<'s>), RegularLink(RegularLink<'s>),
} }

View File

@ -20,7 +20,6 @@ use super::error::Res;
use super::lesser_element::Paragraph; use super::lesser_element::Paragraph;
use super::util::blank_line; use super::util::blank_line;
use super::util::get_consumed; use super::util::get_consumed;
use super::util::trailing_whitespace;
use super::Context; use super::Context;
#[tracing::instrument(ret, level = "debug")] #[tracing::instrument(ret, level = "debug")]

View File

@ -8,7 +8,6 @@ use super::error::MyError;
use super::error::Res; use super::error::Res;
use super::list::List; use super::list::List;
use super::list::Node; use super::list::Node;
use super::util::always_fail;
use super::Context; use super::Context;
type Matcher = dyn for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str>; type Matcher = dyn for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str>;
@ -139,7 +138,8 @@ pub struct ExitMatcherNode<'r> {
#[derive(Clone)] #[derive(Clone)]
pub enum ChainBehavior<'r> { pub enum ChainBehavior<'r> {
AndParent(Option<&'r Matcher>), AndParent(Option<&'r Matcher>),
#[allow(dead_code)]
#[allow(dead_code)] // Will be used when inside code/quote blocks
IgnoreParent(Option<&'r Matcher>), IgnoreParent(Option<&'r Matcher>),
} }

View File

@ -12,19 +12,15 @@ use crate::parser::parser_context::ContextElement;
use crate::parser::parser_context::ExitMatcherNode; use crate::parser::parser_context::ExitMatcherNode;
use crate::parser::util::exit_matcher_parser; use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::parser::util::regurgitate;
use crate::parser::util::start_of_line; use crate::parser::util::start_of_line;
use crate::parser::util::trailing_whitespace;
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::character::complete::digit1; use nom::character::complete::digit1;
use nom::character::complete::line_ending;
use nom::character::complete::one_of; use nom::character::complete::one_of;
use nom::character::complete::space0; use nom::character::complete::space0;
use nom::combinator::eof; use nom::combinator::eof;
use nom::combinator::recognize; use nom::combinator::recognize;
use nom::combinator::verify; use nom::combinator::verify;
use nom::multi::many0;
use nom::multi::many_till; use nom::multi::many_till;
use nom::sequence::tuple; use nom::sequence::tuple;