diff --git a/trunk_parser/src/ast.rs b/trunk_parser/src/ast.rs index cdb8b13..82ce978 100644 --- a/trunk_parser/src/ast.rs +++ b/trunk_parser/src/ast.rs @@ -271,6 +271,9 @@ pub enum Statement { name: Identifier, value: Option, }, + Block { + body: Block, + }, Noop, } diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index 9712862..aac2b80 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -893,6 +893,12 @@ impl Parser { finally, } } + TokenKind::LeftBrace => { + self.next(); + let body = self.block(&TokenKind::RightBrace)?; + self.rbrace()?; + Statement::Block { body } + } _ => { let expr = self.expression(0)?; @@ -2957,6 +2963,19 @@ mod tests { ); } + #[test] + fn block() { + assert_ast("