mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
feat(parse): support capturing a str in Pattern::Underscore
This commit is contained in:
parent
ce67f28c42
commit
8df5d5c13c
5 changed files with 15 additions and 12 deletions
|
@ -437,7 +437,7 @@ pub enum Pattern<'a> {
|
|||
},
|
||||
FloatLiteral(&'a str),
|
||||
StrLiteral(StrLiteral<'a>),
|
||||
Underscore,
|
||||
Underscore(&'a str),
|
||||
|
||||
// Space
|
||||
SpaceBefore(&'a Pattern<'a>, &'a [CommentOrNewline<'a>]),
|
||||
|
@ -554,7 +554,8 @@ impl<'a> Pattern<'a> {
|
|||
) => string_x == string_y && base_x == base_y && is_negative_x == is_negative_y,
|
||||
(FloatLiteral(x), FloatLiteral(y)) => x == y,
|
||||
(StrLiteral(x), StrLiteral(y)) => x == y,
|
||||
(Underscore, Underscore) => true,
|
||||
// TODO do we want to compare anything here?
|
||||
(Underscore(_), Underscore(_)) => true,
|
||||
|
||||
// Space
|
||||
(SpaceBefore(x, _), SpaceBefore(y, _)) => x.equivalent(y),
|
||||
|
|
|
@ -666,7 +666,7 @@ fn annotation_or_alias<'a>(
|
|||
NumLiteral(_) | NonBase10Literal { .. } | FloatLiteral(_) | StrLiteral(_) => {
|
||||
Def::NotYetImplemented("TODO gracefully handle trying to annotate a litera")
|
||||
}
|
||||
Underscore => {
|
||||
Underscore(_) => {
|
||||
Def::NotYetImplemented("TODO gracefully handle trying to give a type annotation to an undrscore")
|
||||
}
|
||||
Malformed(_) => {
|
||||
|
@ -1086,7 +1086,9 @@ fn string_pattern<'a>() -> impl Parser<'a, Pattern<'a>> {
|
|||
}
|
||||
|
||||
fn underscore_pattern<'a>() -> impl Parser<'a, Pattern<'a>> {
|
||||
map!(ascii_char(b'_'), |_| Pattern::Underscore)
|
||||
map_with_arena!(ascii_char(b'_'), |_arena, _thing| {
|
||||
Pattern::Underscore(&"_")
|
||||
})
|
||||
}
|
||||
|
||||
fn record_destructure<'a>(min_indent: u16) -> impl Parser<'a, Pattern<'a>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue