Add BoundedSeparated with parser and printer

This type should be able to replace Separated (with a bit of effort).

The hope is that this type is a better representation for table-like
syntax with optional trailing delimiter that will let me remove_map
elements without too much difficulty. This is necessary for desugaring
table constructors.
This commit is contained in:
Joscha 2022-11-21 22:49:40 +01:00
parent 9591b23082
commit a1867fdc4e
3 changed files with 86 additions and 2 deletions

View file

@ -96,3 +96,16 @@ impl<E, S1, S2> HasSpan for Separated<E, S1, S2> {
}
}
}
#[derive(Debug, Clone)]
pub struct BoundedSeparated<E> {
pub elems: Vec<(Space, E, Space)>,
pub trailing: Option<Space>,
pub span: Span,
}
impl<E> HasSpan for BoundedSeparated<E> {
fn span(&self) -> Span {
self.span
}
}