Clone issue.
This commit is contained in:
parent
96aca6b537
commit
b20568c09e
@ -3,5 +3,6 @@ mod nom_context;
|
|||||||
mod parser_with_context;
|
mod parser_with_context;
|
||||||
mod text;
|
mod text;
|
||||||
mod text_element_parser;
|
mod text_element_parser;
|
||||||
|
mod token;
|
||||||
pub use text_element_parser::document;
|
pub use text_element_parser::document;
|
||||||
type Context<'r> = &'r nom_context::ContextTree<'r>;
|
type Context<'r> = &'r nom_context::ContextTree<'r>;
|
||||||
|
@ -4,6 +4,7 @@ use nom::error::VerboseError;
|
|||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
use super::list::List;
|
use super::list::List;
|
||||||
|
use super::token::Token;
|
||||||
|
|
||||||
type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
|
type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ pub struct FailMatcherNode<'r> {
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PreviousElementNode<'r> {
|
pub struct PreviousElementNode<'r> {
|
||||||
pub dummy: &'r str,
|
pub element: Token<'r>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -33,7 +33,7 @@ use super::text_element_parser::paragraph;
|
|||||||
|
|
||||||
pub type Res<T, U> = IResult<T, U, VerboseError<T>>;
|
pub type Res<T, U> = IResult<T, U, VerboseError<T>>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum TextElement<'a> {
|
pub enum TextElement<'a> {
|
||||||
Span(Span<'a>),
|
Span(Span<'a>),
|
||||||
Space(Space<'a>),
|
Space(Space<'a>),
|
||||||
|
@ -21,6 +21,7 @@ use super::text::Bold;
|
|||||||
use super::text::Link;
|
use super::text::Link;
|
||||||
use super::text::Res;
|
use super::text::Res;
|
||||||
use super::text::TextElement;
|
use super::text::TextElement;
|
||||||
|
use super::token::Token;
|
||||||
use super::Context;
|
use super::Context;
|
||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
@ -41,12 +42,13 @@ use tracing::trace;
|
|||||||
|
|
||||||
type UnboundMatcher<'r, I, O, E> = dyn Fn(Context<'r>, I) -> IResult<I, O, E>;
|
type UnboundMatcher<'r, I, O, E> = dyn Fn(Context<'r>, I) -> IResult<I, O, E>;
|
||||||
|
|
||||||
fn context_many_till<'r, I, O, E, F, M, T>(
|
fn context_many_till<'r, 'x, I, O, E, F, M, T>(
|
||||||
context: Context<'r>,
|
context: Context<'r>,
|
||||||
mut many_matcher: M,
|
mut many_matcher: M,
|
||||||
mut till_matcher: T,
|
mut till_matcher: T,
|
||||||
) -> impl FnMut(I) -> IResult<I, (Vec<O>, F), E> + 'r
|
) -> impl FnMut(I) -> IResult<I, (Vec<O>, F), E> + 'r
|
||||||
where
|
where
|
||||||
|
O: Into<Token<'x>>,
|
||||||
I: Clone + InputLength,
|
I: Clone + InputLength,
|
||||||
E: ParseError<I>,
|
E: ParseError<I>,
|
||||||
M: Fn(Context<'r>, I) -> IResult<I, O, E> + 'r,
|
M: Fn(Context<'r>, I) -> IResult<I, O, E> + 'r,
|
||||||
|
12
src/parser/token.rs
Normal file
12
src/parser/token.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
use super::text::TextElement;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Token<'a> {
|
||||||
|
TextElement(TextElement<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Into<Token<'a>> for TextElement<'a> {
|
||||||
|
fn into(self) -> Token<'a> {
|
||||||
|
Token::TextElement(self)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user