2023-01-22 14:25:10 -08:00
|
|
|
use crate::parser::{ParseResult, Parser, ParserInput, Representation};
|
2022-10-21 22:22:21 -07:00
|
|
|
|
|
|
|
pub struct BoxedParser<'a, I, O, E>
|
|
|
|
where
|
|
|
|
I: ParserInput,
|
|
|
|
{
|
|
|
|
inner: Box<dyn Parser<I, O, E> + 'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, I, O, E> BoxedParser<'a, I, O, E>
|
|
|
|
where
|
|
|
|
I: ParserInput,
|
|
|
|
{
|
|
|
|
pub(crate) fn new<P>(inner: P) -> Self
|
|
|
|
where
|
|
|
|
P: Parser<I, O, E> + 'a,
|
|
|
|
{
|
|
|
|
BoxedParser {
|
|
|
|
inner: Box::new(inner),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, I: ParserInput, O, E> Parser<I, O, E> for BoxedParser<'a, I, O, E> {
|
2023-01-22 14:25:10 -08:00
|
|
|
fn representation(&self) -> Representation {
|
|
|
|
Representation::new("NOT IMPL'D")
|
|
|
|
}
|
2022-10-21 22:22:21 -07:00
|
|
|
fn parse(&self, input: I) -> ParseResult<I, O, E> {
|
|
|
|
self.inner.parse(input)
|
|
|
|
}
|
|
|
|
|
2022-10-22 02:05:31 -07:00
|
|
|
fn boxed<'b>(self) -> BoxedParser<'b, I, O, E>
|
|
|
|
where
|
|
|
|
Self: Sized + 'b,
|
|
|
|
{
|
2022-10-21 22:45:42 -07:00
|
|
|
self
|
|
|
|
}
|
2022-10-21 22:22:21 -07:00
|
|
|
}
|