From d62fef4f217875572552adc55ccddae0a4c05271 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Sun, 11 Aug 2024 09:00:45 -0700 Subject: [PATCH] Documenting expression patterns --- guide/src/reference.md | 3 ++- guide/src/reference/pattern-matching.md | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/guide/src/reference.md b/guide/src/reference.md index 2421b81..1d7dc93 100644 --- a/guide/src/reference.md +++ b/guide/src/reference.md @@ -147,9 +147,10 @@ MatchBody: ( (',' )*)?; MatchPattern: '=>' ; GuardedPattern: ('if' )?; Pattern: ('|' )*; -PatternKind: ; +PatternKind: ; IdentifierPattern: '_' | '...' | ; ListPattern: '[' ( (',' )*)? ']'; +ExpressionPattern: ('<=' | '>=' | '<' | '>' | '=' | '!=') ; MapPattern: '{' ( (',' )*)? ','? '}'; EntryPattern: ':' ; diff --git a/guide/src/reference/pattern-matching.md b/guide/src/reference/pattern-matching.md index 9587b27..47840c5 100644 --- a/guide/src/reference/pattern-matching.md +++ b/guide/src/reference/pattern-matching.md @@ -6,9 +6,10 @@ MatchBody: ( (',' )*)?; MatchPattern: '=>' ; GuardedPattern: ('if' )?; Pattern: ('|' )*; -PatternKind: ; +PatternKind: ; IdentifierPattern: '_' | '...' | ; ListPattern: '[' ( (',' )*)? ']'; +ExpressionPattern: ('<=' | '>=' | '<' | '>' | '=' | '!=') ; MapPattern: '{' ( (',' )*)? ','? '}'; EntryPattern: ':' ; @@ -38,11 +39,12 @@ pattern is considered a match. ## Pattern -A pattern can one one of four kinds: +A pattern can one one of these kinds: - Wildcard: `_` will match any value. - Named wildcard: Any identifier - Remaining Wildcard: `...` will match all remaining elements in a collection/ +- An expression comparison: A comparison operator followed by an expression. - Tuple pattern: A comma separated list of patterns enclosed in parentheses. - List pattern: A comma separated list of patterns enclosed in square brackets.