From e6e1d14eee990192e370e7b6f2dd4ffb2b48d610 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 1 Feb 2024 14:06:06 -0800 Subject: [PATCH] Some more work --- src/combinators.rs | 8 ++++++-- src/representation.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) 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} ]"), } } }