Skip to content

Commit

Permalink
feat: half-open range patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Jan 22, 2024
1 parent 79456e6 commit 45b194c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,10 +1388,15 @@ module.exports = grammar({
$._literal_pattern,
$._path,
),
choice('...', '..='),
choice(
$._literal_pattern,
$._path,
seq(
choice('...', '..='),
choice(
$._literal_pattern,
$._path,
),
),
'..',
),
),

Expand Down
6 changes: 6 additions & 0 deletions test/corpus/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ match x {
Some(1 ... 5) => a,
a @ b...c => a,
a @ b..=c => a,
d.. => a,
}

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -215,6 +216,11 @@ match x {
(range_pattern
(identifier)
(identifier))))
value: (identifier))
(match_arm
pattern: (match_pattern
(range_pattern
(identifier)))
value: (identifier))))))

================================================================================
Expand Down

0 comments on commit 45b194c

Please sign in to comment.