[fine] Implement the wildcard pattern

This commit is contained in:
John Doty 2024-02-04 19:36:47 -08:00
parent e0721d09fc
commit 65ec2d4cca
5 changed files with 104 additions and 25 deletions

View file

@ -163,6 +163,7 @@ pub enum TreeKind {
MatchExpression,
MatchBody,
MatchArm,
WildcardPattern,
}
pub struct Tree<'a> {
@ -998,7 +999,11 @@ fn pattern(p: &mut CParser, right_power: u8) {
variable_binding(p);
}
type_expr(p);
if p.peek() == TokenKind::Underscore {
wildcard_pattern(p);
} else {
type_expr(p);
}
if p.eat(TokenKind::And) {
expression_with_power(p, right_power);
@ -1016,6 +1021,12 @@ fn variable_binding(p: &mut CParser) {
p.end(m, TreeKind::VariableBinding);
}
fn wildcard_pattern(p: &mut CParser) {
let m = p.start();
p.expect_start(TokenKind::Underscore);
p.end(m, TreeKind::WildcardPattern);
}
fn argument_list(p: &mut CParser) {
let m = p.start();