diff options
Diffstat (limited to 'src/parser/grammar/items')
-rw-r--r-- | src/parser/grammar/items/mod.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index d059833a0..c88e39596 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs | |||
@@ -223,6 +223,11 @@ fn fn_item(p: &mut Parser) { | |||
223 | fn_ret_type(p); | 223 | fn_ret_type(p); |
224 | block(p); | 224 | block(p); |
225 | 225 | ||
226 | // test block | ||
227 | // fn a() {} | ||
228 | // fn b() { let _ = 1; } | ||
229 | // fn c() { 1; 2; } | ||
230 | // fn d() { 1; 2 } | ||
226 | fn block(p: &mut Parser) { | 231 | fn block(p: &mut Parser) { |
227 | if !p.at(L_CURLY) { | 232 | if !p.at(L_CURLY) { |
228 | p.error("expected block"); | 233 | p.error("expected block"); |
@@ -232,7 +237,18 @@ fn fn_item(p: &mut Parser) { | |||
232 | while !p.at(EOF) && !p.at(R_CURLY) { | 237 | while !p.at(EOF) && !p.at(R_CURLY) { |
233 | match p.current() { | 238 | match p.current() { |
234 | LET_KW => let_stmt(p), | 239 | LET_KW => let_stmt(p), |
235 | _ => p.err_and_bump("expected statement"), | 240 | _ => { |
241 | let expr_stmt = p.start(); | ||
242 | expressions::expr(p); | ||
243 | if p.eat(SEMI) { | ||
244 | expr_stmt.complete(p, EXPR_STMT); | ||
245 | if p.at(R_CURLY) { | ||
246 | break; | ||
247 | } | ||
248 | } else { | ||
249 | expr_stmt.abandon(p); | ||
250 | } | ||
251 | } | ||
236 | } | 252 | } |
237 | } | 253 | } |
238 | p.expect(R_CURLY); | 254 | p.expect(R_CURLY); |