AST - Added return statement

This commit is contained in:
Emmanuel BENOîT 2023-01-02 20:16:14 +01:00
parent e4a86eb1de
commit 9b9103c170

View file

@ -43,6 +43,11 @@ pub enum StmtNode {
is_break: bool,
loop_name: Option<Token>,
},
/// Return statement.
Return {
token: Token,
value: Option<ExprNode>,
},
}
impl StmtNode {
@ -204,6 +209,11 @@ impl AstDumper for StmtNode {
None => format!("( {} )", stmt),
}
}
Self::Return { token: _, value } => match value {
Some(expr) => format!("( return {} )", expr.dump()),
None => "( return )".to_owned(),
},
}
}
}