diff options
author | Ville Penttinen <[email protected]> | 2019-03-05 09:28:53 +0000 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-03-05 09:31:25 +0000 |
commit | eb1ac43867921501723457846f7aaaa36cd4ebdd (patch) | |
tree | bd835b7ceb245823d5ddd7bd725c99463e798774 /crates/ra_parser/src/grammar/patterns.rs | |
parent | 1f4468a8dae10db4f500bde3c1708228de6137b6 (diff) |
Introduce pattern_list to parse pipe separated patterns
pattern_list comes in two variants, one uses the default PAT_RECOVERY_SET as the
recovery set, while other allows the user to provide a recovery set.
Diffstat (limited to 'crates/ra_parser/src/grammar/patterns.rs')
-rw-r--r-- | crates/ra_parser/src/grammar/patterns.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index 9d7da639d..befe6687d 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs | |||
@@ -8,6 +8,22 @@ pub(super) fn pattern(p: &mut Parser) { | |||
8 | pattern_r(p, PAT_RECOVERY_SET) | 8 | pattern_r(p, PAT_RECOVERY_SET) |
9 | } | 9 | } |
10 | 10 | ||
11 | /// Parses a pattern list separated by pipes `|` | ||
12 | pub(super) fn pattern_list(p: &mut Parser) { | ||
13 | pattern_list_r(p, PAT_RECOVERY_SET) | ||
14 | } | ||
15 | |||
16 | /// Parses a pattern list separated by pipes `|` | ||
17 | /// using the given `recovery_set` | ||
18 | pub(super) fn pattern_list_r(p: &mut Parser, recovery_set: TokenSet) { | ||
19 | p.eat(PIPE); | ||
20 | pattern_r(p, recovery_set); | ||
21 | |||
22 | while p.eat(PIPE) { | ||
23 | pattern_r(p, recovery_set); | ||
24 | } | ||
25 | } | ||
26 | |||
11 | pub(super) fn pattern_r(p: &mut Parser, recovery_set: TokenSet) { | 27 | pub(super) fn pattern_r(p: &mut Parser, recovery_set: TokenSet) { |
12 | if let Some(lhs) = atom_pat(p, recovery_set) { | 28 | if let Some(lhs) = atom_pat(p, recovery_set) { |
13 | // test range_pat | 29 | // test range_pat |