AST - Added function to extract all block statements
This commit is contained in:
parent
cd731d387a
commit
9c7445d904
1 changed files with 11 additions and 0 deletions
11
src/ast.rs
11
src/ast.rs
|
@ -45,6 +45,17 @@ pub enum StmtNode {
|
|||
},
|
||||
}
|
||||
|
||||
impl StmtNode {
|
||||
/// Extract the list of statements from a block. Panic if the statement
|
||||
/// is not a block.
|
||||
pub fn extract_block_statements(self) -> Vec<StmtNode> {
|
||||
match self {
|
||||
Self::Block(stmts) => stmts,
|
||||
_ => panic!("Statement is not a block"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An AST node that represents an expression.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ExprNode {
|
||||
|
|
Loading…
Reference in a new issue