cl-parser: Rearrange to match cl-ast

Also reorder `Let` in the AST
This commit is contained in:
2024-07-31 02:35:41 -05:00
parent 97808fd855
commit 1eb0516baf
3 changed files with 478 additions and 457 deletions

View File

@@ -404,23 +404,6 @@ mod display {
}
}
impl Display for Let {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self { mutable, name, ty, init, tail } = self;
write!(f, "let {mutable}{name}")?;
if let Some(value) = ty {
write!(f, ": {value}")?;
}
if let Some(value) = init {
write!(f, " = {value}")?;
}
if let Some(value) = tail {
write!(f, ";\n{value}")?;
}
Ok(())
}
}
impl Display for Expr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.kind.fmt(f)
@@ -458,6 +441,23 @@ mod display {
}
}
impl Display for Let {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self { mutable, name, ty, init, tail } = self;
write!(f, "let {mutable}{name}")?;
if let Some(value) = ty {
write!(f, ": {value}")?;
}
if let Some(value) = init {
write!(f, " = {value}")?;
}
if let Some(value) = tail {
write!(f, ";\n{value}")?;
}
Ok(())
}
}
impl Display for Assign {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self { parts } = self;