diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-01 15:09:44 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-01 15:09:44 +0100 |
commit | 71c13528cdcad9930ded24054daf6bb1678835e7 (patch) | |
tree | 701ee4bd27cfae3421c059d064db6f9ab1f9b9f0 /crates/ra_parser/src/grammar | |
parent | c368b147e339e7c1a5eca9c6f56fb897f72781cf (diff) | |
parent | b454eb5a600779a9ab6f7bea251772bdd98b81b9 (diff) |
Merge #1220
1220: Add macro pat parsing r=matklad a=edwin0cheng
This PR add support to parsing macro call in pattern , e.g :
```
let m!(x) = 0;
```
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r-- | crates/ra_parser/src/grammar/patterns.rs | 11 |
1 files changed, 10 insertions, 1 deletions
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) { | |||
40 | atom_pat(p, recovery_set); | 40 | atom_pat(p, recovery_set); |
41 | m.complete(p, RANGE_PAT); | 41 | m.complete(p, RANGE_PAT); |
42 | } | 42 | } |
43 | // test marco_pat | ||
44 | // fn main() { | ||
45 | // let m!(x) = 0; | ||
46 | // } | ||
47 | else if lhs.kind() == PATH_PAT && p.at(EXCL) { | ||
48 | let m = lhs.precede(p); | ||
49 | items::macro_call_after_excl(p); | ||
50 | m.complete(p, MACRO_CALL); | ||
51 | } | ||
43 | } | 52 | } |
44 | } | 53 | } |
45 | 54 | ||
@@ -51,7 +60,7 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { | |||
51 | let la1 = p.nth(1); | 60 | let la1 = p.nth(1); |
52 | if la0 == REF_KW | 61 | if la0 == REF_KW |
53 | || la0 == MUT_KW | 62 | || la0 == MUT_KW |
54 | || (la0 == IDENT && !(la1 == COLONCOLON || la1 == L_PAREN || la1 == L_CURLY)) | 63 | || (la0 == IDENT && !(la1 == COLONCOLON || la1 == L_PAREN || la1 == L_CURLY || la1 == EXCL)) |
55 | { | 64 | { |
56 | return Some(bind_pat(p, true)); | 65 | return Some(bind_pat(p, true)); |
57 | } | 66 | } |