QRegularFactory
-> CRegularFactory
This commit is contained in:
parent
0456de685f
commit
cf7ff1b5b8
@ -33,9 +33,9 @@ pub use self::hashing::{Hash, HASH_SIZE, HASH_ZEROS};
|
||||
pub use self::inctx::InCtx;
|
||||
pub use self::inlining::{Inlining, InliningExt, InliningResultExt};
|
||||
pub use self::modes::{
|
||||
ExtensionResult, ExtensionResultM, ExtensionResultP, ExtensionSource, ExtensionSourceM,
|
||||
ExtensionSourceP, FactoryModeParse, FactoryModeProxy, ImplMode, Mode, ModeResult, ModeResultM,
|
||||
ModeResultP, ParseMode, ParseModeExt, ParseSuccess, ParseSuccessP, QRegularFactory,
|
||||
CRegularFactory, ExtensionResult, ExtensionResultM, ExtensionResultP, ExtensionSource,
|
||||
ExtensionSourceM, ExtensionSourceP, FactoryModeParse, FactoryModeProxy, ImplMode, Mode,
|
||||
ModeResult, ModeResultM, ModeResultP, ParseMode, ParseModeExt, ParseSuccess, ParseSuccessP,
|
||||
RegularFactory, RegularMode, WithMode, WithParseMode,
|
||||
};
|
||||
pub use self::origin::{OFctr, Origin};
|
||||
|
@ -365,11 +365,11 @@ impl Mode for RegularMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait QRegularFactory<'a, Ctx: Context<'a>>:
|
||||
pub trait CRegularFactory<'a, Ctx: Context<'a>>:
|
||||
FactoryBase<'a, Ctx> + ImplMode<Mode = RegularMode>
|
||||
{
|
||||
fn qrdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
||||
fn qrextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>;
|
||||
fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
||||
fn crextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>;
|
||||
}
|
||||
|
||||
pub trait RegularFactory<'a, Ctx: Context<'a>>:
|
||||
@ -391,16 +391,16 @@ impl<'a, Ctx: Context<'a>, F: FactoryModeParse<'a, Ctx> + ParseMode<Mode = Regul
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: QRegularFactory<'a, Ctx>> FactoryModeProxy<'a, Ctx>
|
||||
impl<'a, Ctx: Context<'a>, F: CRegularFactory<'a, Ctx>> FactoryModeProxy<'a, Ctx>
|
||||
for WithMode<F, RegularMode>
|
||||
{
|
||||
type F = F;
|
||||
|
||||
fn pmdeserialize<I: InCtx<'a, Ctx>>(f: &Self::F, inctx: I) -> ModeResultM<'a, Ctx, F, I> {
|
||||
f.qrdeserialize(inctx)
|
||||
f.crdeserialize(inctx)
|
||||
}
|
||||
|
||||
fn pmextend(f: &F, mentionable: Mtbl<'a, Ctx, F>, tail: &[u8]) -> ExtensionResultM<'a, Ctx, F> {
|
||||
f.qrextend(mentionable, tail)
|
||||
f.crextend(mentionable, tail)
|
||||
}
|
||||
}
|
||||
|
@ -106,12 +106,12 @@ impl<F: ParseMode> ImplMode for StackNodeFactory<F> {
|
||||
type Mode = F::Mode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + RegularFactory<'a, Ctx>> QRegularFactory<'a, Ctx>
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + RegularFactory<'a, Ctx>> CRegularFactory<'a, Ctx>
|
||||
for StackNodeFactory<F>
|
||||
where
|
||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||
{
|
||||
fn qrdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
let (rest, inctx) = self.parse_point(inctx)?;
|
||||
let element = self
|
||||
.element_factory
|
||||
@ -120,7 +120,7 @@ where
|
||||
Ok(StackNode { rest, element })
|
||||
}
|
||||
|
||||
fn qrextend(&self, mut mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
fn crextend(&self, mut mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
mentionable.element = self
|
||||
.element_factory
|
||||
.extend(mentionable.element, tail)
|
||||
|
@ -144,8 +144,8 @@ impl<F> ImplMode for NodeFactory<F> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryParse<'a, Ctx>> QRegularFactory<'a, Ctx> for NodeFactory<F> {
|
||||
fn qrdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryParse<'a, Ctx>> CRegularFactory<'a, Ctx> for NodeFactory<F> {
|
||||
fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
let tree_factory = TreeFactory(NullableFactory::new(self.clone()));
|
||||
let (l, inctx) = tree_factory.ideserialize(inctx)?;
|
||||
let (r, inctx) = tree_factory.ideserialize(inctx)?;
|
||||
@ -153,7 +153,7 @@ impl<'a, Ctx: Context<'a>, F: FactoryParse<'a, Ctx>> QRegularFactory<'a, Ctx> fo
|
||||
Ok(Node { l, r, key })
|
||||
}
|
||||
|
||||
fn qrextend(&self, mut mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
fn crextend(&self, mut mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
mentionable.key = self
|
||||
.0
|
||||
.extend(mentionable.key, tail)
|
||||
|
@ -101,12 +101,12 @@ impl<'a, Ctx: Context<'a>> ImplMode for TypelessFactory<'a, Ctx> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>> QRegularFactory<'a, Ctx> for TypelessFactory<'a, Ctx> {
|
||||
fn qrdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
impl<'a, Ctx: Context<'a>> CRegularFactory<'a, Ctx> for TypelessFactory<'a, Ctx> {
|
||||
fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
self.t_deserialize.de(inctx.demote()).map_err(TypelessError)
|
||||
}
|
||||
|
||||
fn qrextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
fn crextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
self.t_extend.xt(mentionable, tail)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user