Simplify creating BoundedSeparated

Along with this comes the decision to no longer track whitespace and
comments across desugarings in most cases. The main reason for this
decision is that not having to track whitespace simplifies the code and
reasoning necessary.

While implementing desugarings, I also realized that the current comment
model doesn't let me accurately track whitespace across desugarings. I'm
fairly sure I haven't yet found a good model for whitespace and
comments. Once I find one, adding pretty printing support for those
should hopefully be easy though.
This commit is contained in:
Joscha 2022-11-22 14:44:15 +01:00
parent d6a0bbf2af
commit c769d9e16f
7 changed files with 110 additions and 205 deletions

View file

@ -7,14 +7,12 @@ impl Call {
match self {
Self::Arg {
expr,
s0,
s1,
s0: _,
s1: _,
arg,
s2,
s2: _,
span,
} => {
// `expr s0 ( s1 arg s2 )`
// -> `'{ s0 call: expr, arg: s1 arg s2 }`
let call = TableLitElem::Named {
name: Ident::new("call", span),
s0: Space::empty(span),
@ -25,25 +23,17 @@ impl Call {
let arg = TableLitElem::Named {
name: Ident::new("arg", span),
s0: Space::empty(span),
s1,
s1: Space::empty(span),
value: arg,
span,
};
let elems = vec![
(s0, call, Space::empty(span)),
(Space::empty(span), arg, s2),
];
let new = Expr::Lit(Lit::Table(TableLit(BoundedSeparated {
elems,
trailing: None,
span,
})));
let new = Expr::Lit(Lit::Table(TableLit(
BoundedSeparated::new(span).then(call).then(arg),
)));
(new, true)
}
Self::NoArg { expr, s0, s1, span } => {
// `expr s0 ( s1 )`
// -> `expr s0 ( s1 nil )`
let new = Expr::Call(Self::Arg {
expr,
s0,
@ -61,8 +51,6 @@ impl Call {
constr,
span,
} => {
// `expr s0 {..}`
// -> `expr s0 ( {..} )`
let new = Expr::Call(Self::Arg {
expr,
s0,