Start working on bnf()

This commit is contained in:
Greg Shuflin 2022-10-21 21:56:08 -07:00
parent a049236300
commit 73845224d5
2 changed files with 25 additions and 1 deletions

View File

@ -1 +1,4 @@
pub struct Bnf {}
#[derive(Debug, Clone)]
pub enum Bnf {
Production,
}

View File

@ -147,6 +147,10 @@ impl<'a, I: ParserInput, O, E> Parser<I, O, E> for BoxedParser<'a, I, O, E> {
fn parse(&self, input: I) -> ParseResult<I, O, E> {
self.inner.parse(input)
}
fn bnf(&self) -> Option<Bnf> {
self.inner.bnf()
}
}
impl<I: ParserInput, O, E, F> Parser<I, O, E> for F
@ -158,6 +162,19 @@ where
}
}
impl<I: ParserInput, O, E, F> Parser<I, O, E> for (F, Bnf)
where
F: Fn(I) -> ParseResult<I, O, E>,
{
fn parse(&self, input: I) -> ParseResult<I, O, E> {
self.0(input)
}
fn bnf(&self) -> Option<Bnf> {
Some(self.1.clone())
}
}
impl<I, O, E, T> Parser<I, O, E> for Rc<T>
where
I: ParserInput,
@ -166,4 +183,8 @@ where
fn parse(&self, input: I) -> ParseResult<I, O, E> {
self.as_ref().parse(input)
}
fn bnf(&self) -> Option<Bnf> {
self.as_ref().bnf()
}
}