/// Parse an expression with a precedence higher than `prec`.
///
/// ```text
/// expr[10] := "inertial" expr[9]
/// ```
Parse an expression with a precedence higher than `prec`.
Parse an expression with a precedence higher than ` prec ` .
pub fn parse_expr_prec<P: Parser>(p: &mut P, prec: ExprPrec) -> ReportedResult<ast::Expr> {
    let tkn = p.peek(0);
    let mut span = tkn.span;
    // Try to parse a unary operator.
    if let Some(op) = as_unary_op(tkn.value) {
        let op_prec = unary_prec(op);
        if prec <= op_prec {
            p.bump();
            let arg = parse_expr_prec(p, op_prec)?;
            span.expand(p.last_span());
            return parse_expr_suffix(
                p,
                ast::Expr {
                    span: span,
                    data: ast::UnaryExpr(Spanned::new(op, tkn.span), Box::new(arg)),
                },
                prec,
            );
        }
    }
    // Parse a primary expression.
    let primary = parse_primary_expr(p)?;
    // Parse any optional expression suffix.
    parse_expr_suffix(p, primary, prec)
}
pub fn parse_expr_prec < P : Parser > ( p : & mut P , prec : ExprPrec ) -> ReportedResult < ast :: Expr > { let tkn = p . peek ( 0 ) ; let mut span = tkn . span ; // Try to parse a unary operator. if let Some ( op ) = as_unary_op ( tkn . value ) { let op_prec = unary_prec ( op ) ; if prec <= op_prec { p . bump ( ) ; let arg = parse_expr_prec ( p , op_prec ) ? ; span . expand ( p . last_span ( ) ) ; return parse_expr_suffix ( p , ast :: Expr { span : span , data : ast :: UnaryExpr ( Spanned :: new ( op , tkn . span ) , Box :: new ( arg ) ) , } , prec , ) ; } } // Parse a primary expression. let primary = parse_primary_expr ( p ) ? ; // Parse any optional expression suffix. parse_expr_suffix ( p , primary , prec ) }
Parse an expression with a precedence higher than `prec`.
Parse an expression with a precedence higher than ` prec ` .
p
&mut P
prec
ExprPrec