aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
authorCaio <[email protected]>2019-03-09 23:40:22 +0000
committerCaio <[email protected]>2019-03-09 23:40:22 +0000
commitad72699553c39f159f25a6dc7ecd5df953817407 (patch)
treed0e0d665f23e8b55feb624fac45bc7de644d622c /crates/ra_parser/src/grammar
parenta9d09b7ec0721e9ad305866a57989d1aa9c67ec1 (diff)
Add async keyword
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs5
-rw-r--r--crates/ra_parser/src/grammar/items.rs10
2 files changed, 14 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 9f282c74d..53bb26c5f 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -93,6 +93,11 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
93 } 93 }
94 } 94 }
95 95
96 ASYNC_KW if la == L_CURLY => {
97 let m = p.start();
98 p.bump();
99 block_expr(p, Some(m))
100 }
96 MATCH_KW => match_expr(p), 101 MATCH_KW => match_expr(p),
97 UNSAFE_KW if la == L_CURLY => { 102 UNSAFE_KW if la == L_CURLY => {
98 let m = p.start(); 103 let m = p.start();
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index ab9d2de90..91f9bfe8a 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -86,9 +86,14 @@ pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem {
86 } 86 }
87 87
88 let mut has_mods = false; 88 let mut has_mods = false;
89
89 // modifiers 90 // modifiers
90 has_mods |= p.eat(CONST_KW);
91 91
92 has_mods |= p.eat(CONST_KW);
93 if p.at(ASYNC_KW) && p.nth(1) != L_CURLY {
94 p.eat(ASYNC_KW);
95 has_mods = true;
96 }
92 // test_err unsafe_block_in_mod 97 // test_err unsafe_block_in_mod
93 // fn foo(){} unsafe { } fn bar(){} 98 // fn foo(){} unsafe { } fn bar(){}
94 if p.at(UNSAFE_KW) && p.nth(1) != L_CURLY { 99 if p.at(UNSAFE_KW) && p.nth(1) != L_CURLY {
@@ -110,6 +115,9 @@ pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem {
110 115
111 // items 116 // items
112 let kind = match p.current() { 117 let kind = match p.current() {
118 // test async_fn
119 // async fn foo() {}
120
113 // test extern_fn 121 // test extern_fn
114 // extern fn foo() {} 122 // extern fn foo() {}
115 123