diff --git a/src/combinators.rs b/src/combinators.rs index 7ef4abd..9f8e0fe 100644 --- a/src/combinators.rs +++ b/src/combinators.rs @@ -1,6 +1,9 @@ use std::marker::PhantomData; -use crate::{ParseResult, Parser, representation::Representation}; +use crate::{ + representation::{Representation, EBNF}, + ParseResult, Parser, +}; pub fn repeated(parser: P) -> Repeated where @@ -102,7 +105,8 @@ where fn representation(&self) -> Representation { let at_least = self.at_least.unwrap_or(0); let at_most = self.at_most.unwrap_or(u32::MAX); - Representation::new() + let production = EBNF::Repeated(Box::new(self.inner_parser.representation().production())); + Representation::new().with_production(production) } } diff --git a/src/representation.rs b/src/representation.rs index 3c88523..b8f4fba 100644 --- a/src/representation.rs +++ b/src/representation.rs @@ -58,7 +58,7 @@ impl fmt::Display for EBNF { EBNF::Nonterminal(name) => write!(f, "{name}"), EBNF::StringTerminal(term) => write!(f, r#""{term}""#), EBNF::LabeledTerminal(s) => write!(f, "<{s}>"), - EBNF::Repeated(inner) => write!(f, "[ {inner} ]") + EBNF::Repeated(inner) => write!(f, "[ {inner} ]"), } } }