From 3a7f07c62d3dd253d63c483ee291d9471f539479 Mon Sep 17 00:00:00 2001 From: Unreal Hoang Date: Sat, 20 Jul 2019 17:41:31 +0900 Subject: add await to syntax, parser for await_expr --- crates/ra_parser/src/grammar/expressions.rs | 12 ++++++++++++ crates/ra_parser/src/syntax_kind/generated.rs | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'crates/ra_parser/src') diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 298030cb9..3e49e70c7 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -393,6 +393,18 @@ fn postfix_expr( T![.] if p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::]) => { method_call_expr(p, lhs) } + T![.] if p.nth(1) == AWAIT_KW => { + // test await_expr + // fn foo() { + // x.await; + // x.0.await; + // x.0().await?.hello(); + // } + let m = lhs.precede(p); + p.bump(); + p.bump(); + m.complete(p, AWAIT_EXPR) + } T![.] => field_expr(p, lhs), // test postfix_range // fn foo() { let x = 1..; } diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 374fd5aec..4b5abb516 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs @@ -105,6 +105,7 @@ pub enum SyntaxKind { RETURN_KW, TRY_KW, BOX_KW, + AWAIT_KW, AUTO_KW, DEFAULT_KW, EXISTENTIAL_KW, @@ -193,6 +194,7 @@ pub enum SyntaxKind { INDEX_EXPR, METHOD_CALL_EXPR, FIELD_EXPR, + AWAIT_EXPR, TRY_EXPR, CAST_EXPR, REF_EXPR, @@ -338,6 +340,7 @@ macro_rules! T { (return) => { $crate::SyntaxKind::RETURN_KW }; (try) => { $crate::SyntaxKind::TRY_KW }; (box) => { $crate::SyntaxKind::BOX_KW }; + (await) => { $crate::SyntaxKind::AWAIT_KW }; (auto) => { $crate::SyntaxKind::AUTO_KW }; (default) => { $crate::SyntaxKind::DEFAULT_KW }; (existential) => { $crate::SyntaxKind::EXISTENTIAL_KW }; @@ -398,6 +401,7 @@ impl SyntaxKind { | RETURN_KW | TRY_KW | BOX_KW + | AWAIT_KW | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW @@ -572,6 +576,7 @@ impl SyntaxKind { RETURN_KW => &SyntaxInfo { name: "RETURN_KW" }, TRY_KW => &SyntaxInfo { name: "TRY_KW" }, BOX_KW => &SyntaxInfo { name: "BOX_KW" }, + AWAIT_KW => &SyntaxInfo { name: "AWAIT_KW" }, AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, EXISTENTIAL_KW => &SyntaxInfo { name: "EXISTENTIAL_KW" }, @@ -660,6 +665,7 @@ impl SyntaxKind { INDEX_EXPR => &SyntaxInfo { name: "INDEX_EXPR" }, METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, + AWAIT_EXPR => &SyntaxInfo { name: "AWAIT_EXPR" }, TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" }, REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, @@ -752,6 +758,7 @@ impl SyntaxKind { "return" => RETURN_KW, "try" => TRY_KW, "box" => BOX_KW, + "await" => AWAIT_KW, _ => return None, }; Some(kw) -- cgit v1.2.3