aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
authorAndrey Tkachenko <[email protected]>2019-06-06 12:36:16 +0100
committerAndrey Tkachenko <[email protected]>2019-06-06 12:43:26 +0100
commit281c9eeaff8eac4e666089f80f67cf684e1d001b (patch)
treed5d315543cfc7aa47db24aafec3b98df3754ddb3 /crates/ra_parser/src/grammar
parentb79e6294a68fd41f0a3dbd9eb907dfe99646d77e (diff)
[#1083] Try block syntax
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 8b1a1de49..0df47d33d 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -52,6 +52,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
52 CONTINUE_KW, 52 CONTINUE_KW,
53 LIFETIME, 53 LIFETIME,
54 ASYNC_KW, 54 ASYNC_KW,
55 TRY_KW,
55 ]); 56 ]);
56 57
57const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; 58const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW];
@@ -75,6 +76,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
75 T![loop] => loop_expr(p, None), 76 T![loop] => loop_expr(p, None),
76 T![for] => for_expr(p, None), 77 T![for] => for_expr(p, None),
77 T![while] => while_expr(p, None), 78 T![while] => while_expr(p, None),
79 T![try] => try_expr(p, None),
78 LIFETIME if la == T![:] => { 80 LIFETIME if la == T![:] => {
79 let m = p.start(); 81 let m = p.start();
80 label(p); 82 label(p);
@@ -116,7 +118,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
116 } 118 }
117 }; 119 };
118 let blocklike = match done.kind() { 120 let blocklike = match done.kind() {
119 IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR => BlockLike::Block, 121 IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | TRY_BLOCK_EXPR => BlockLike::Block,
120 _ => BlockLike::NotBlock, 122 _ => BlockLike::NotBlock,
121 }; 123 };
122 Some((done, blocklike)) 124 Some((done, blocklike))
@@ -491,3 +493,17 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
491 } 493 }
492 m.complete(p, BREAK_EXPR) 494 m.complete(p, BREAK_EXPR)
493} 495}
496
497// test try_expr
498// fn foo() {
499// try {
500//
501// }
502// }
503fn try_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
504 assert!(p.at(T![try]));
505 let m = m.unwrap_or_else(|| p.start());
506 p.bump();
507 block(p);
508 m.complete(p, TRY_EXPR)
509}