diff options
author | Aleksey Kladov <[email protected]> | 2018-07-31 15:43:44 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-31 15:43:44 +0100 |
commit | edf2b17a572b56371cfc29bbc3a686edcb12782c (patch) | |
tree | 44f07e4a5bbbc9f3de23e87a35b56b0b61a4dfda /src/parser/grammar/items | |
parent | 9f87c9a3f927d3b7a3cbb92818c45c979ece693b (diff) |
allow items inside blocks
Diffstat (limited to 'src/parser/grammar/items')
-rw-r--r-- | src/parser/grammar/items/mod.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index 9147df87d..12bcf7924 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs | |||
@@ -248,16 +248,19 @@ fn fn_item(p: &mut Parser) { | |||
248 | while !p.at(EOF) && !p.at(R_CURLY) { | 248 | while !p.at(EOF) && !p.at(R_CURLY) { |
249 | match p.current() { | 249 | match p.current() { |
250 | LET_KW => let_stmt(p), | 250 | LET_KW => let_stmt(p), |
251 | _ => { | 251 | c => { |
252 | let expr_stmt = p.start(); | 252 | // test block_items |
253 | expressions::expr(p); | 253 | // fn a() { fn b() {} } |
254 | if p.eat(SEMI) { | 254 | if ITEM_FIRST.contains(c) { |
255 | expr_stmt.complete(p, EXPR_STMT); | 255 | item(p) |
256 | if p.at(R_CURLY) { | ||
257 | break; | ||
258 | } | ||
259 | } else { | 256 | } else { |
260 | expr_stmt.abandon(p); | 257 | let expr_stmt = p.start(); |
258 | expressions::expr(p); | ||
259 | if p.eat(SEMI) { | ||
260 | expr_stmt.complete(p, EXPR_STMT); | ||
261 | } else { | ||
262 | expr_stmt.abandon(p); | ||
263 | } | ||
261 | } | 264 | } |
262 | } | 265 | } |
263 | } | 266 | } |