better state system

This commit is contained in:
2024-07-03 12:07:05 +02:00
parent 3cb1ab90fd
commit 9b755b1821
4 changed files with 61 additions and 45 deletions
+11 -1
View File
@@ -34,7 +34,7 @@ impl Default for Transpiler {
impl Transpiler {
pub fn transpile(&mut self, code: String, indent: usize, vars: &mut Variables) -> String {
let ast = parser::parse(code, vars, self);
let ast = parser::parse(code, vars, &mut self.state.clone(), self);
let mut res = String::new();
if indent > 0 {
res += " ".repeat(indent * 2).as_str();
@@ -56,6 +56,16 @@ impl Transpiler {
)
.as_str();
}
Ast::Struct(name, curly) => {
res += format!(
"struct {} {}\n{}{}\n",
name,
"{",
self.transpile(curly, indent + 1, &mut vars.clone()),
"}"
)
.as_str()
}
}
}
if indent > 0 {