pub fn term_to_range<'t, C>(term: Spanned<Term<'t>>, ctx: C) -> Result<Spanned<hir::Range2<'t>>>
where
    C: SessionContext + Copy + for<'a> Alloc<'a, 't, hir::LitExpr>,
{
    let v = match term.value {
        // Term::Attr(..) => ...
        Term::Range(dir, lb, rb) => {
            let le = term_to_expr(*lb, ctx);
            let re = term_to_expr(*rb, ctx);
            hir::Range2::Immediate(term.span, dir, le?, re?)
        }
        _ => {
            ctx.emit(
                DiagBuilder2::error(format!("`{}` is not a valid range", term.span.extract()))
                    .span(term.span)
                    .add_note("A range can be one of the following:")
                    .add_note("- an ascending range of the form `a to b`")
                    .add_note("- a descending range of the form `a downto b`")
                    .add_note("- a range attribute of the form `T'range`")
                    .add_note("See IEEE 1076-2008 section 5.2.1."),
            );
            debugln!("It is a {:#?}", term);
            return Err(());
        }
    };
    Ok(Spanned::new(v, term.span))
}
/// Map a term to a range.
Map a term to a range.
Map a term to a range .
pub fn term_to_range<'t, C>(term: Spanned<Term<'t>>, ctx: C) -> Result<Spanned<hir::Range2<'t>>>
where
    C: SessionContext + Copy + for<'a> Alloc<'a, 't, hir::LitExpr>,
{
    let v = match term.value {
        // Term::Attr(..) => ...
        Term::Range(dir, lb, rb) => {
            let le = term_to_expr(*lb, ctx);
            let re = term_to_expr(*rb, ctx);
            hir::Range2::Immediate(term.span, dir, le?, re?)
        }
        _ => {
            ctx.emit(
                DiagBuilder2::error(format!("`{}` is not a valid range", term.span.extract()))
                    .span(term.span)
                    .add_note("A range can be one of the following:")
                    .add_note("- an ascending range of the form `a to b`")
                    .add_note("- a descending range of the form `a downto b`")
                    .add_note("- a range attribute of the form `T'range`")
                    .add_note("See IEEE 1076-2008 section 5.2.1."),
            );
            debugln!("It is a {:#?}", term);
            return Err(());
        }
    };
    Ok(Spanned::new(v, term.span))
}
pub fn term_to_range < ' t , C > ( term : Spanned < Term < ' t > > , ctx : C ) -> Result < Spanned < hir :: Range2 < ' t > > > where C : SessionContext + Copy + for < ' a > Alloc < ' a , ' t , hir :: LitExpr > , { let v = match term . value { // Term::Attr(..) => ... Term :: Range ( dir , lb , rb ) => { let le = term_to_expr ( * lb , ctx ) ; let re = term_to_expr ( * rb , ctx ) ; hir :: Range2 :: Immediate ( term . span , dir , le ? , re ? ) } _ => { ctx . emit ( DiagBuilder2 :: error ( format ! ( " " term span extract ( ) ) ) . span ( term . span ) . add_note ( " " ) . add_note ( " " ) . add_note ( " " ) . add_note ( " " ) . add_note ( " " ) , ) ; debugln ! ( " " term ) ; return Err ( ( ) ) ; } } ; Ok ( Spanned :: new ( v , term . span ) ) }
Map a term to a range.
Map a term to a range .
term
Spanned<Term<'t>>
ctx
C
term
Spanned<Term<'t>>
ctx
C