From b454eb5a600779a9ab6f7bea251772bdd98b81b9 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 30 Apr 2019 23:22:48 +0800 Subject: Add macro pat parsing --- crates/ra_parser/src/grammar/patterns.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/ra_parser/src/grammar') diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index 03fa9b71e..12dd22bde 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs @@ -40,6 +40,15 @@ pub(super) fn pattern_r(p: &mut Parser, recovery_set: TokenSet) { atom_pat(p, recovery_set); m.complete(p, RANGE_PAT); } + // test marco_pat + // fn main() { + // let m!(x) = 0; + // } + else if lhs.kind() == PATH_PAT && p.at(EXCL) { + let m = lhs.precede(p); + items::macro_call_after_excl(p); + m.complete(p, MACRO_CALL); + } } } @@ -51,7 +60,7 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option { let la1 = p.nth(1); if la0 == REF_KW || la0 == MUT_KW - || (la0 == IDENT && !(la1 == COLONCOLON || la1 == L_PAREN || la1 == L_CURLY)) + || (la0 == IDENT && !(la1 == COLONCOLON || la1 == L_PAREN || la1 == L_CURLY || la1 == EXCL)) { return Some(bind_pat(p, true)); } -- cgit v1.2.3