pub fn parse_attr_decl<P: Parser>(p: &mut P) -> ReportedResult<ast::AttrDecl> {
    let mut span = p.peek(0).span;
    require(p, Keyword(Kw::Attribute))?;
    let name = parse_ident(p, "attribute name")?;

    // Depending on the next token, parse either a declaration or a
    // specification.
    if accept(p, Colon) {
        let ty = parse_name(p)?;
        require(p, Semicolon)?;
        span.expand(p.last_span());
        Ok(ast::AttrDecl {
            id: Default::default(),
            span: span,
            name: name,
            data: ast::AttrData::Decl(ty),
        })
    } else if accept(p, Keyword(Kw::Of)) {
        // Parse the entity specification.
        let target = match p.peek(0).value {
            Keyword(Kw::Others) => {
                p.bump();
                ast::AttrTarget::Others
            }
            Keyword(Kw::All) => {
                p.bump();
                ast::AttrTarget::All
            }
            _ => {
                let l = separated_nonempty(p, Comma, Colon, "name", |p| {
                    let name = parse_name(p)?;
                    let sig = try_flanked(p, Brack, parse_signature)?;
                    Ok((name, sig))
                })?;
                ast::AttrTarget::List(l)
            }
        };

        // Parse the entity class.
        require(p, Colon)?;
        let cls = parse_entity_class(p)?;

        // Parse the rest.
        require(p, Keyword(Kw::Is))?;
        let expr = parse_expr(p)?;
        require(p, Semicolon)?;
        span.expand(p.last_span());
        Ok(ast::AttrDecl {
            id: Default::default(),
            span: span,
            name: name,
            data: ast::AttrData::Spec {
                target: target,
                cls: cls,
                expr: expr,
            },
        })
    } else {
        let pk = p.peek(0);
        p.emit(
            DiagBuilder2::error(format!(
                "Expected `:` or `of` after attribute name, found {} instead",
                pk.value
            ))
            .span(pk.span)
            .add_note("see IEEE 1076-2008 sections 6.7 and 7.2"),
        );
        Err(Reported)
    }
}
/// Parse an attribute declaration or specification. See IEEE 1076-2008 sections
/// 6.7 and 7.2.
///
/// ```text
/// attribute_decl
///   := "attribute" ident ":" name ";"
///   := "attribute" ident "of" ({name [signature]}","+ | "others" | "all") ":" entity_class "is" expr ";"
/// ```
Parse an attribute declaration or specification.


Parse an attribute declaration or specification .
pub fn parse_attr_decl<P: Parser>(p: &mut P) -> ReportedResult<ast::AttrDecl> {
    let mut span = p.peek(0).span;
    require(p, Keyword(Kw::Attribute))?;
    let name = parse_ident(p, "attribute name")?;
    // Depending on the next token, parse either a declaration or a
    // specification.
    if accept(p, Colon) {
        let ty = parse_name(p)?;
        require(p, Semicolon)?;
        span.expand(p.last_span());
        Ok(ast::AttrDecl {
            id: Default::default(),
            span: span,
            name: name,
            data: ast::AttrData::Decl(ty),
        })
    } else if accept(p, Keyword(Kw::Of)) {
        // Parse the entity specification.
        let target = match p.peek(0).value {
            Keyword(Kw::Others) => {
                p.bump();
                ast::AttrTarget::Others
            }
            Keyword(Kw::All) => {
                p.bump();
                ast::AttrTarget::All
            }
            _ => {
                let l = separated_nonempty(p, Comma, Colon, "name", |p| {
                    let name = parse_name(p)?;
                    let sig = try_flanked(p, Brack, parse_signature)?;
                    Ok((name, sig))
                })?;
                ast::AttrTarget::List(l)
            }
        };
        // Parse the entity class.
        require(p, Colon)?;
        let cls = parse_entity_class(p)?;
        // Parse the rest.
        require(p, Keyword(Kw::Is))?;
        let expr = parse_expr(p)?;
        require(p, Semicolon)?;
        span.expand(p.last_span());
        Ok(ast::AttrDecl {
            id: Default::default(),
            span: span,
            name: name,
            data: ast::AttrData::Spec {
                target: target,
                cls: cls,
                expr: expr,
            },
        })
    } else {
        let pk = p.peek(0);
        p.emit(
            DiagBuilder2::error(format!(
                "Expected `:` or `of` after attribute name, found {} instead",
                pk.value
            ))
            .span(pk.span)
            .add_note("see IEEE 1076-2008 sections 6.7 and 7.2"),
        );
        Err(Reported)
    }
}
pub fn parse_attr_decl < P : Parser > ( p : & mut P ) -> ReportedResult < ast :: AttrDecl > { let mut span = p . peek ( 0 ) . span ; require ( p , Keyword ( Kw :: Attribute ) ) ? ; let name = parse_ident ( p , " " ) ? ; // Depending on the next token, parse either a declaration or a // specification. if accept ( p , Colon ) { let ty = parse_name ( p ) ? ; require ( p , Semicolon ) ? ; span . expand ( p . last_span ( ) ) ; Ok ( ast :: AttrDecl { id : Default :: default ( ) , span : span , name : name , data : ast :: AttrData :: Decl ( ty ) , } ) } else if accept ( p , Keyword ( Kw :: Of ) ) { // Parse the entity specification. let target = match p . peek ( 0 ) . value { Keyword ( Kw :: Others ) => { p . bump ( ) ; ast :: AttrTarget :: Others } Keyword ( Kw :: All ) => { p . bump ( ) ; ast :: AttrTarget :: All } _ => { let l = separated_nonempty ( p , Comma , Colon , " " , | p | { let name = parse_name ( p ) ? ; let sig = try_flanked ( p , Brack , parse_signature ) ? ; Ok ( ( name , sig ) ) } ) ? ; ast :: AttrTarget :: List ( l ) } } ; // Parse the entity class. require ( p , Colon ) ? ; let cls = parse_entity_class ( p ) ? ; // Parse the rest. require ( p , Keyword ( Kw :: Is ) ) ? ; let expr = parse_expr ( p ) ? ; require ( p , Semicolon ) ? ; span . expand ( p . last_span ( ) ) ; Ok ( ast :: AttrDecl { id : Default :: default ( ) , span : span , name : name , data : ast :: AttrData :: Spec { target : target , cls : cls , expr : expr , } , } ) } else { let pk = p . peek ( 0 ) ; p . emit ( DiagBuilder2 :: error ( format ! ( " " pk value ) ) . span ( pk . span ) . add_note ( " " ) , ) ; Err ( Reported ) } }
Parse an attribute declaration or specification.
Parse an attribute declaration or specification .
p
&mut P
p
&mut P