parser: get formatting to match gawk 5.4.0

I was previously running into bugs cuz I was on the LTS lol.
This commit is contained in:
Guillem L. Jara
2026-05-07 13:18:08 +02:00
parent 09b1947d13
commit aa9e1ad203
+7 -6
View File
@@ -48,13 +48,14 @@ impl Display for Ast<'_> {
write_body_ln(f, body, 0)?;
writeln!(f)?;
}
for (fun, Function { args, body }) in &self.functions {
// GNU appears to place two newlines before functions.
// I think it's a bug but we'll keep it.
write!(f, "\nfunction {fun}(")?;
for (i, (fun, Function { args, body })) in self.functions.iter().enumerate() {
write!(f, "function {fun}(")?;
write_args(f, args, 0)?;
writeln!(f, ") ")?;
write_body_ln(f, body, 0)?;
writeln!(f, ")")?;
write_body(f, body, 0)?;
if i + 1 != self.functions.len() {
writeln!(f, "\n")?;
}
}
Ok(())
}