Representation always exists
This commit is contained in:
parent
0829b16fc9
commit
4818b23c3b
@ -8,7 +8,7 @@ where
|
|||||||
{
|
{
|
||||||
inner: P,
|
inner: P,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
repr: Option<Representation>,
|
repr: Representation,
|
||||||
phantom: PhantomData<(I, O, E)>,
|
phantom: PhantomData<(I, O, E)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ where
|
|||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn representation(&self) -> Option<Representation> {
|
fn representation(&self) -> Representation {
|
||||||
self.repr.clone()
|
self.repr.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ where
|
|||||||
Self {
|
Self {
|
||||||
inner,
|
inner,
|
||||||
name: None,
|
name: None,
|
||||||
repr: None,
|
repr: Representation::new(),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,9 +50,6 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_repr(self, repr: Representation) -> Self {
|
pub fn with_repr(self, repr: Representation) -> Self {
|
||||||
Self {
|
Self { repr, ..self }
|
||||||
repr: Some(repr),
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ pub trait Parser<I, O, E> {
|
|||||||
fn name(&self) -> Option<String> {
|
fn name(&self) -> Option<String> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn representation(&self) -> Option<Representation> {
|
fn representation(&self) -> Representation {
|
||||||
None
|
Representation::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ mod tests {
|
|||||||
let parser = literal_char('f');
|
let parser = literal_char('f');
|
||||||
assert_eq!(Ok(('f', "unky")), parser.parse("funky"));
|
assert_eq!(Ok(('f', "unky")), parser.parse("funky"));
|
||||||
|
|
||||||
let repr = parser.representation().unwrap();
|
let repr = parser.representation();
|
||||||
assert!(matches!(repr.production(), EBNF::CharTerminal('f')));
|
assert!(matches!(repr.production(), EBNF::CharTerminal('f')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user