ebnf repeated
This commit is contained in:
parent
9c2228dbff
commit
a189f34c37
@ -1,6 +1,6 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use crate::{ParseResult, Parser};
|
use crate::{ParseResult, Parser, representation::Representation};
|
||||||
|
|
||||||
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
|
||||||
@ -94,6 +94,16 @@ where
|
|||||||
}
|
}
|
||||||
Ok((results, input))
|
Ok((results, input))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn name(&self) -> Option<String> {
|
||||||
|
self.inner_parser.name()
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SeparatedBy<D, P, I, O, E>
|
pub struct SeparatedBy<D, P, I, O, E>
|
||||||
|
@ -38,6 +38,7 @@ pub enum EBNF {
|
|||||||
StringTerminal(String),
|
StringTerminal(String),
|
||||||
LabeledTerminal(String),
|
LabeledTerminal(String),
|
||||||
Alternation(Vec<EBNF>),
|
Alternation(Vec<EBNF>),
|
||||||
|
Repeated(Box<EBNF>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for EBNF {
|
impl fmt::Display for EBNF {
|
||||||
@ -57,6 +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} ]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user