From 45b194c76c1b4c1b58ec584ff55b55b7d43e2a33 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 22 Jan 2024 11:32:10 -0500 Subject: [PATCH] feat: half-open range patterns --- grammar.js | 11 ++++++++--- test/corpus/patterns.txt | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/grammar.js b/grammar.js index fdbcdc78..ab76f0ec 100644 --- a/grammar.js +++ b/grammar.js @@ -1388,10 +1388,15 @@ module.exports = grammar({ $._literal_pattern, $._path, ), - choice('...', '..='), choice( - $._literal_pattern, - $._path, + seq( + choice('...', '..='), + choice( + $._literal_pattern, + $._path, + ), + ), + '..', ), ), diff --git a/test/corpus/patterns.txt b/test/corpus/patterns.txt index 4205811e..a93bcb33 100644 --- a/test/corpus/patterns.txt +++ b/test/corpus/patterns.txt @@ -162,6 +162,7 @@ match x { Some(1 ... 5) => a, a @ b...c => a, a @ b..=c => a, + d.. => a, } -------------------------------------------------------------------------------- @@ -215,6 +216,11 @@ match x { (range_pattern (identifier) (identifier)))) + value: (identifier)) + (match_arm + pattern: (match_pattern + (range_pattern + (identifier))) value: (identifier)))))) ================================================================================