Some more work

This commit is contained in:
Greg Shuflin 2024-02-01 14:06:06 -08:00
parent a189f34c37
commit e6e1d14eee
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,9 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use crate::{ParseResult, Parser, representation::Representation}; use crate::{
representation::{Representation, EBNF},
ParseResult, Parser,
};
pub fn repeated<P, I, O, E>(parser: P) -> Repeated<P, I, O, E> pub fn repeated<P, I, O, E>(parser: P) -> Repeated<P, I, O, E>
where where
@ -102,7 +105,8 @@ where
fn representation(&self) -> Representation { fn representation(&self) -> Representation {
let at_least = self.at_least.unwrap_or(0); let at_least = self.at_least.unwrap_or(0);
let at_most = self.at_most.unwrap_or(u32::MAX); 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)
} }
} }

View File

@ -58,7 +58,7 @@ impl fmt::Display for EBNF {
EBNF::Nonterminal(name) => write!(f, "{name}"), EBNF::Nonterminal(name) => write!(f, "{name}"),
EBNF::StringTerminal(term) => write!(f, r#""{term}""#), EBNF::StringTerminal(term) => write!(f, r#""{term}""#),
EBNF::LabeledTerminal(s) => write!(f, "<{s}>"), EBNF::LabeledTerminal(s) => write!(f, "<{s}>"),
EBNF::Repeated(inner) => write!(f, "[ {inner} ]") EBNF::Repeated(inner) => write!(f, "[ {inner} ]"),
} }
} }
} }