diff --git a/src/ast.rs b/src/ast.rs index fd4f39a..de220e6 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -41,12 +41,30 @@ impl ToString for BaseType { } } -#[derive(Builder)] -pub struct Block { - statements: Vec, +#[derive(Default)] +pub struct GlobalBlock { + statements: Vec>, } -impl ToString for Block { +impl ToString for GlobalBlock { + fn to_string(&self) -> String { + let mut s = String::new(); + + for stat in &self.statements { + s.push_str(&stat.to_string()); + s.push(' '); + } + + s.push('\n'); + s + } +} + +pub struct Block { + statements: Vec>, +} + +impl ToString for Block { fn to_string(&self) -> String { let mut s = String::from("{ "); @@ -60,9 +78,9 @@ impl ToString for Block { } } -impl AstNode for Block {} +impl AstNode for Block {} -impl Statement for Block {} +impl Statement for Block {} pub enum Literal { Int(i32),