AST - Added return statement
This commit is contained in:
parent
e4a86eb1de
commit
9b9103c170
1 changed files with 10 additions and 0 deletions
10
src/ast.rs
10
src/ast.rs
|
@ -43,6 +43,11 @@ pub enum StmtNode {
|
||||||
is_break: bool,
|
is_break: bool,
|
||||||
loop_name: Option<Token>,
|
loop_name: Option<Token>,
|
||||||
},
|
},
|
||||||
|
/// Return statement.
|
||||||
|
Return {
|
||||||
|
token: Token,
|
||||||
|
value: Option<ExprNode>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StmtNode {
|
impl StmtNode {
|
||||||
|
@ -204,6 +209,11 @@ impl AstDumper for StmtNode {
|
||||||
None => format!("( {} )", stmt),
|
None => format!("( {} )", stmt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Self::Return { token: _, value } => match value {
|
||||||
|
Some(expr) => format!("( return {} )", expr.dump()),
|
||||||
|
None => "( return )".to_owned(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue