Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/grammar/patterns.rs')
-rw-r--r--crates/parser/src/grammar/patterns.rs75
1 files changed, 43 insertions, 32 deletions
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index bc1224af9b..633e3e0a0b 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -62,39 +62,50 @@ fn pattern_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
}
fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
- if let Some(lhs) = atom_pat(p, recovery_set) {
- // test range_pat
- // fn main() {
- // match 92 {
- // 0 ... 100 => (),
- // 101 ..= 200 => (),
- // 200 .. 301 => (),
- // 302 .. => (),
- // }
- //
- // match Some(10 as u8) {
- // Some(0) | None => (),
- // Some(1..) => ()
- // }
- //
- // match () {
- // S { a: 0 } => (),
- // S { a: 1.. } => (),
- // }
- //
- // match () {
- // [0] => (),
- // [1..] => (),
- // }
- //
- // match (10 as u8, 5 as u8) {
- // (0, _) => (),
- // (1.., _) => ()
- // }
- // }
+ // test range_pat
+ // fn main() {
+ // match 92 {
+ // 0 ... 100 => (),
+ // 101 ..= 200 => (),
+ // 200 .. 301 => (),
+ // 302 .. => (),
+ // ..= 303 => (),
+ // }
+ //
+ // match Some(10 as u8) {
+ // Some(0) | None => (),
+ // Some(1..) => (),
+ // Some(..=2) => (),
+ // }
+ //
+ // match () {
+ // S { a: 0 } => (),
+ // S { a: 1.. } => (),
+ // S { a: ..=2 } => (),
+ // }
+ //
+ // match () {
+ // [0] => (),
+ // [1..] => (),
+ // [..=2] => (),
+ // }
+ //
+ // match (10 as u8, 5 as u8) {
+ // (0, _) => (),
+ // (1.., _) => (),
+ // (..=2, _) => (),
+ // }
+ // }
+
+ if p.at(T![..=]) {
+ let m = p.start();
+ p.bump(T![..=]);
+ atom_pat(p, recovery_set);
+ m.complete(p, RANGE_PAT);
+ return;
+ }
- // FIXME: support half_open_range_patterns (`..=2`),
- // exclusive_range_pattern (`..5`) with missing lhs
+ if let Some(lhs) = atom_pat(p, recovery_set) {
for range_op in [T![...], T![..=], T![..]] {
if p.at(range_op) {
let m = lhs.precede(p);