fn parse_case_expr(
        &mut self,
        start_token: Token<'file>,
    ) -> Result<Term<'file>, Diagnostic<FileSpan>> {
        let scrutinee = self.parse_arg_term(Prec(0))?;

        self.expect_match(TokenKind::Open(DelimKind::Brace))?;

        let mut clauses = Vec::new();
        while !self.is_peek_match(TokenKind::Close(DelimKind::Brace)) {
            let pattern = self.parse_pattern(Prec(0))?;

            self.expect_match(TokenKind::RFatArrow)?;

            let body = self.parse_term(Prec(0))?;

            clauses.push((pattern, body));

            if self.try_match(TokenKind::Semicolon).is_some() {
                continue;
            } else {
                let end_token = self.expect_match(TokenKind::Close(DelimKind::Brace))?;
                let span = FileSpan::merge(start_token.span(), end_token.span());

                return Ok(Term::Case(span, Box::new(scrutinee), clauses));
            }
        }

        let end_token = self.expect_match(TokenKind::Close(DelimKind::Brace))?;
        let span = FileSpan::merge(start_token.span(), end_token.span());

        Ok(Term::Case(span, Box::new(scrutinee), clauses))
    }
/// Parse the trailing part of a case expression.
///
/// ```text
/// case-expr   ::= arg-term(0) "{" (case-clause ";")* case-clause? "}"
/// case-clause ::= pattern(0) "=>" term(0)
/// ```
Parse the trailing part of a case expression.
Parse the trailing part of a case expression .
fn parse_case_expr(
        &mut self,
        start_token: Token<'file>,
    ) -> Result<Term<'file>, Diagnostic<FileSpan>> {
        let scrutinee = self.parse_arg_term(Prec(0))?;
        self.expect_match(TokenKind::Open(DelimKind::Brace))?;
        let mut clauses = Vec::new();
        while !self.is_peek_match(TokenKind::Close(DelimKind::Brace)) {
            let pattern = self.parse_pattern(Prec(0))?;
            self.expect_match(TokenKind::RFatArrow)?;
            let body = self.parse_term(Prec(0))?;
            clauses.push((pattern, body));
            if self.try_match(TokenKind::Semicolon).is_some() {
                continue;
            } else {
                let end_token = self.expect_match(TokenKind::Close(DelimKind::Brace))?;
                let span = FileSpan::merge(start_token.span(), end_token.span());
                return Ok(Term::Case(span, Box::new(scrutinee), clauses));
            }
        }
        let end_token = self.expect_match(TokenKind::Close(DelimKind::Brace))?;
        let span = FileSpan::merge(start_token.span(), end_token.span());
        Ok(Term::Case(span, Box::new(scrutinee), clauses))
    }
fn parse_case_expr ( & mut self , start_token : Token < ' file > , ) -> Result < Term < ' file > , Diagnostic < FileSpan > > { let scrutinee = self . parse_arg_term ( Prec ( 0 ) ) ? ; self . expect_match ( TokenKind :: Open ( DelimKind :: Brace ) ) ? ; let mut clauses = Vec :: new ( ) ; while ! self . is_peek_match ( TokenKind :: Close ( DelimKind :: Brace ) ) { let pattern = self . parse_pattern ( Prec ( 0 ) ) ? ; self . expect_match ( TokenKind :: RFatArrow ) ? ; let body = self . parse_term ( Prec ( 0 ) ) ? ; clauses . push ( ( pattern , body ) ) ; if self . try_match ( TokenKind :: Semicolon ) . is_some ( ) { continue ; } else { let end_token = self . expect_match ( TokenKind :: Close ( DelimKind :: Brace ) ) ? ; let span = FileSpan :: merge ( start_token . span ( ) , end_token . span ( ) ) ; return Ok ( Term :: Case ( span , Box :: new ( scrutinee ) , clauses ) ) ; } } let end_token = self . expect_match ( TokenKind :: Close ( DelimKind :: Brace ) ) ? ; let span = FileSpan :: merge ( start_token . span ( ) , end_token . span ( ) ) ; Ok ( Term :: Case ( span , Box :: new ( scrutinee ) , clauses ) ) }
Parse the trailing part of a case expression.
Parse the trailing part of a case expression .
&mut self
start_token
Token<'file>
&mut self
start_token
Token<'file>