StackNodeFactory
via FactoryModeParse
This commit is contained in:
parent
6935b072dd
commit
25fe0655dc
@ -103,49 +103,40 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Sta
|
|||||||
type ParseError = StackParseError<ParseError<'a, Ctx, F>>;
|
type ParseError = StackParseError<ParseError<'a, Ctx, F>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: ParseMode> ImplMode for StackNodeFactory<F> {
|
impl<F: ParseMode> ParseMode for StackNodeFactory<F> {
|
||||||
type Mode = F::Mode;
|
type Mode = F::Mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + RegularFactory<'a, Ctx>> CRegularFactory<'a, Ctx>
|
impl<'a, Ctx: Context<'a>, F: FactoryModeParse<'a, Ctx>> FactoryModeParse<'a, Ctx>
|
||||||
for StackNodeFactory<F>
|
for StackNodeFactory<F>
|
||||||
where
|
where
|
||||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||||
{
|
{
|
||||||
fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ModeResultM<'a, Ctx, Self, I> {
|
||||||
let (rest, inctx) = self.parse_point(inctx)?;
|
let (rest, inctx) = self.parse_point(inctx)?;
|
||||||
let element = self
|
let selement = self
|
||||||
.element_factory
|
.element_factory
|
||||||
.rdeserialize(inctx)
|
.mdeserialize(inctx)
|
||||||
.map_err(StackParseError::Element)?;
|
.map_err(StackParseError::Element)?;
|
||||||
Ok(StackNode { rest, element })
|
Ok(Self::map(selement, |element| StackNode { rest, element }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crextend(&self, mut mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
fn mextend(
|
||||||
mentionable.element = self
|
&self,
|
||||||
.element_factory
|
mentionable: ExtensionSourceM<'a, Ctx, Self>,
|
||||||
.rextend(mentionable.element, tail)
|
tail: &[u8],
|
||||||
.map_err(StackParseError::Element)?;
|
) -> ExtensionResultM<'a, Ctx, Self> {
|
||||||
Ok(mentionable)
|
Self::xsbind(
|
||||||
}
|
mentionable,
|
||||||
}
|
|StackNode { rest, element }| (rest, element),
|
||||||
|
|element| {
|
||||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + InliningFactory<'a, Ctx>> CInliningFactory<'a, Ctx>
|
Self::xmap_err(
|
||||||
for StackNodeFactory<F>
|
self.element_factory.mextend(element, tail),
|
||||||
where
|
StackParseError::Element,
|
||||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
)
|
||||||
{
|
},
|
||||||
fn cextension_error(&self, tail: &[u8]) -> Self::ParseError {
|
|rest, element| Ok(StackNode { rest, element }),
|
||||||
StackParseError::Element(self.element_factory.extension_error(tail))
|
)
|
||||||
}
|
|
||||||
|
|
||||||
fn cideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I> {
|
|
||||||
let (rest, inctx) = self.parse_point(inctx)?;
|
|
||||||
let (element, inctx) = self
|
|
||||||
.element_factory
|
|
||||||
.ideserialize(inctx)
|
|
||||||
.map_err(StackParseError::Element)?;
|
|
||||||
Ok((StackNode { rest, element }, inctx))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user