Skip to content

Commit 45b194c

Browse files
committed
feat: half-open range patterns
1 parent 79456e6 commit 45b194c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

grammar.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,10 +1388,15 @@ module.exports = grammar({
13881388
$._literal_pattern,
13891389
$._path,
13901390
),
1391-
choice('...', '..='),
13921391
choice(
1393-
$._literal_pattern,
1394-
$._path,
1392+
seq(
1393+
choice('...', '..='),
1394+
choice(
1395+
$._literal_pattern,
1396+
$._path,
1397+
),
1398+
),
1399+
'..',
13951400
),
13961401
),
13971402

test/corpus/patterns.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ match x {
162162
Some(1 ... 5) => a,
163163
a @ b...c => a,
164164
a @ b..=c => a,
165+
d.. => a,
165166
}
166167

167168
--------------------------------------------------------------------------------
@@ -215,6 +216,11 @@ match x {
215216
(range_pattern
216217
(identifier)
217218
(identifier))))
219+
value: (identifier))
220+
(match_arm
221+
pattern: (match_pattern
222+
(range_pattern
223+
(identifier)))
218224
value: (identifier))))))
219225

220226
================================================================================

0 commit comments

Comments
 (0)