prepare for modules

This commit is contained in:
2025-04-25 04:16:54 -04:00
parent 0ceb82445e
commit 4e7c201690
30 changed files with 369 additions and 333 deletions

View File

@@ -147,7 +147,7 @@ impl<T: ParsableWith> Node<T> {
NodeParseResult {
node: Self {
inner,
span: start.to(end),
origin: start.to(end),
},
recover,
}
@@ -173,7 +173,7 @@ impl<T: MaybeParsable> Node<T> {
let end = ctx.prev_end();
Some(Self {
inner,
span: start.to(end),
origin: start.to(end),
})
}
}
@@ -191,3 +191,19 @@ impl<T: Parsable> NodeParsable for T {
Node::<Self>::parse(ctx)
}
}
pub trait NodeParsableWith {
type Data;
fn parse_node(ctx: &mut ParserCtx, data: Self::Data) -> NodeParseResult<Self>
where
Self: Sized;
}
impl<T: ParsableWith<Data = D>, D> NodeParsableWith for T {
type Data = D;
fn parse_node(ctx: &mut ParserCtx, data: Self::Data) -> NodeParseResult<Self>
where
Self: Sized,
{
Node::<Self>::parse_with(ctx, data)
}
}