File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
packages/engine/src/parser Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ impl<'a> Parser<'a> {
105
105
Match => self . stmt_match ( ) ?,
106
106
For => self . stmt_for ( ) ?,
107
107
While => self . stmt_while ( ) ?,
108
+ Return => self . stmt_return ( ) ?,
109
+ Break => Some ( Statement :: Break ) ,
110
+ Continue => Some ( Statement :: Continue ) ,
108
111
EOF | EOL => return Ok ( None ) ,
109
112
110
113
_ => {
@@ -242,6 +245,15 @@ impl<'a> Parser<'a> {
242
245
Ok ( Some ( Statement :: While ( Box :: from ( ( condition, block) ) ) ) )
243
246
}
244
247
248
+ // MARK: Return
249
+ fn stmt_return ( & mut self ) -> ParserResult < Option < Statement > > {
250
+ self . expect_token ( & LexerTokenKind :: Return ) ?;
251
+
252
+ let value = self . expression ( ) ?;
253
+
254
+ Ok ( Some ( Statement :: Return ( Box :: from ( value) ) ) )
255
+ }
256
+
245
257
fn expression ( & mut self ) -> ParserResult < Option < WithCursor < Expression > > > {
246
258
self . expr_assignment ( )
247
259
}
Original file line number Diff line number Diff line change 1
1
for i in 0..5 {
2
2
while true {
3
- aaa
3
+ return true
4
4
}
5
5
}
You can’t perform that action at this time.
0 commit comments