/// Parse a group declaration or group template declaration. See IEEE 1076-2008
/// sections 6.9 and 6.10.
///
/// ```text
/// group_decl
///   := "group" ident "is" "(" {entity_class ["<>"]}","+ ")" ";"
///   := "group" ident ":" name ";"
/// ```
Parse a group declaration or group template declaration.


Parse a group declaration or group template declaration .
pub fn parse_group_decl<P: Parser>(p: &mut P) -> ReportedResult<ast::GroupDecl> {
    let mut span = p.peek(0).span;
    require(p, Keyword(Kw::Group))?;
    let name = parse_ident(p, "group name")?;
    // Parse either a declaration or template declaration, depending on the next
    // token.
    let data = if accept(p, Colon) {
        let ty = parse_name(p)?;
        ast::GroupData::Decl(ty)
    } else if accept(p, Keyword(Kw::Is)) {
        let elems = flanked(p, Paren, |p| {
            separated_nonempty(p, Comma, CloseDelim(Paren), "group element", |p| {
                let cls = parse_entity_class(p)?;
                let open = accept(p, LtGt);
                Ok((cls, open))
            })
            .map_err(|e| e.into())
        })?;
        ast::GroupData::Temp(elems)
    } else {
        let pk = p.peek(0);
        p.emit(
            DiagBuilder2::error(format!(
                "Expected `:` or `is` after group name, found {} instead",
                pk.value
            ))
            .span(pk.span)
            .add_note("`group <name> is ...` declares a group template")
            .add_note("`group <name> : ...` declares group")
            .add_note("see IEEE 1076-2008 sections 6.9 and 6.10"),
        );
        return Err(Reported);
    };
    require(p, Semicolon)?;
    span.expand(p.last_span());
    Ok(ast::GroupDecl {
        id: Default::default(),
        span: span,
        name: name,
        data: data,
    })
}
pub fn parse_group_decl < P : Parser > ( p : & mut P ) -> ReportedResult < ast :: GroupDecl > { let mut span = p . peek ( 0 ) . span ; require ( p , Keyword ( Kw :: Group ) ) ? ; let name = parse_ident ( p , " " ) ? ; // Parse either a declaration or template declaration, depending on the next // token. let data = if accept ( p , Colon ) { let ty = parse_name ( p ) ? ; ast :: GroupData :: Decl ( ty ) } else if accept ( p , Keyword ( Kw :: Is ) ) { let elems = flanked ( p , Paren , | p | { separated_nonempty ( p , Comma , CloseDelim ( Paren ) , " " , | p | { let cls = parse_entity_class ( p ) ? ; let open = accept ( p , LtGt ) ; Ok ( ( cls , open ) ) } ) . map_err ( | e | e . into ( ) ) } ) ? ; ast :: GroupData :: Temp ( elems ) } else { let pk = p . peek ( 0 ) ; p . emit ( DiagBuilder2 :: error ( format ! ( " " pk value ) ) . span ( pk . span ) . add_note ( " " ) . add_note ( " " ) . add_note ( " " ) , ) ; return Err ( Reported ) ; } ; require ( p , Semicolon ) ? ; span . expand ( p . last_span ( ) ) ; Ok ( ast :: GroupDecl { id : Default :: default ( ) , span : span , name : name , data : data , } ) }
Parse a group declaration or group template declaration.
Parse a group declaration or group template declaration .
p
&mut P