Fmt config

This commit is contained in:
2026-06-28 15:52:02 +02:00
parent 31eebb4baa
commit 2174b99a3f
6 changed files with 72 additions and 30 deletions
+16 -6
View File
@@ -2,21 +2,23 @@ pub mod expr;
pub mod statement;
pub mod top_level;
use mist_parser::ast::*;
use mist_parser::{MistFmtConfig, ast::*};
pub struct Context {
pub expr_ensure_semicolon: bool,
}
pub struct MistCodegen {
config: MistFmtConfig,
indent_amount: u8,
output: String,
indent: usize,
}
impl MistCodegen {
pub fn new() -> Self {
pub fn new(config: MistFmtConfig) -> Self {
Self {
config,
output: String::new(),
indent: 0,
indent_amount: 4,
@@ -47,13 +49,21 @@ impl MistCodegen {
}
pub fn start_indent(&mut self) {
self.addln("");
self.add_indented("");
if self.config.allman_bracket_style {
self.addln("");
self.add_indented("");
} else {
self.add(" ");
}
}
pub fn start_bracket(&mut self) {
self.addln("");
self.add_indentedln("{");
if self.config.allman_bracket_style {
self.addln("");
self.add_indentedln("{");
} else {
self.add(" {");
}
self.indent += 1;
}