pub fn parse_block_comp_spec<P: Parser>(p: &mut P) -> ReportedResult<Spanned<ast::BlockCompSpec>> {
    let mut span = p.peek(0).span;

    // Try to detect if this is a block or component specification.
    let spec = match (p.peek(0).value, p.peek(1).value) {
        (Keyword(Kw::Others), _) => {
            p.bump();
            require(p, Colon)?;
            let name = parse_name(p)?;
            ast::BlockCompSpec::CompOthers(name)
        }

        (Keyword(Kw::All), _) => {
            p.bump();
            require(p, Colon)?;
            let name = parse_name(p)?;
            ast::BlockCompSpec::CompAll(name)
        }

        (Ident(_), Comma) | (Ident(_), Colon) => {
            let names = separated_nonempty(p, Comma, Colon, "label", |p| {
                parse_ident(p, "label").map(|n| n.into())
            })?;
            require(p, Colon)?;
            let name = parse_name(p)?;
            ast::BlockCompSpec::CompNames(names, name)
        }

        (wrong, _) => {
            if let Some(name) = try_name(p)? {
                ast::BlockCompSpec::Block(name)
            } else {
                let sp = p.peek(0).span;
                p.emit(
                    DiagBuilder2::error(format!(
                        "Expected block name, component label, `all`, or `others`, found {} \
                         instead",
                        wrong
                    ))
                    .span(sp),
                );
                return Err(Reported);
            }
        }
    };

    span.expand(p.last_span());
    Ok(Spanned::new(spec, span))
}
/// Parse a block or component specification. See IEEE 1067-2008 section 7.3.1.
///
/// ```text
/// block_comp_spec
///   := name
///   := {ident}","+ ":" name
///   := "others" ":" name
///   := "all" ":" name
/// ```
Parse a block or component specification.
Parse a block or component specification .
pub fn parse_block_comp_spec<P: Parser>(p: &mut P) -> ReportedResult<Spanned<ast::BlockCompSpec>> {
    let mut span = p.peek(0).span;
    // Try to detect if this is a block or component specification.
    let spec = match (p.peek(0).value, p.peek(1).value) {
        (Keyword(Kw::Others), _) => {
            p.bump();
            require(p, Colon)?;
            let name = parse_name(p)?;
            ast::BlockCompSpec::CompOthers(name)
        }
        (Keyword(Kw::All), _) => {
            p.bump();
            require(p, Colon)?;
            let name = parse_name(p)?;
            ast::BlockCompSpec::CompAll(name)
        }
        (Ident(_), Comma) | (Ident(_), Colon) => {
            let names = separated_nonempty(p, Comma, Colon, "label", |p| {
                parse_ident(p, "label").map(|n| n.into())
            })?;
            require(p, Colon)?;
            let name = parse_name(p)?;
            ast::BlockCompSpec::CompNames(names, name)
        }
        (wrong, _) => {
            if let Some(name) = try_name(p)? {
                ast::BlockCompSpec::Block(name)
            } else {
                let sp = p.peek(0).span;
                p.emit(
                    DiagBuilder2::error(format!(
                        "Expected block name, component label, `all`, or `others`, found {} \
                         instead",
                        wrong
                    ))
                    .span(sp),
                );
                return Err(Reported);
            }
        }
    };
    span.expand(p.last_span());
    Ok(Spanned::new(spec, span))
}
pub fn parse_block_comp_spec < P : Parser > ( p : & mut P ) -> ReportedResult < Spanned < ast :: BlockCompSpec > > { let mut span = p . peek ( 0 ) . span ; // Try to detect if this is a block or component specification. let spec = match ( p . peek ( 0 ) . value , p . peek ( 1 ) . value ) { ( Keyword ( Kw :: Others ) , _ ) => { p . bump ( ) ; require ( p , Colon ) ? ; let name = parse_name ( p ) ? ; ast :: BlockCompSpec :: CompOthers ( name ) } ( Keyword ( Kw :: All ) , _ ) => { p . bump ( ) ; require ( p , Colon ) ? ; let name = parse_name ( p ) ? ; ast :: BlockCompSpec :: CompAll ( name ) } ( Ident ( _ ) , Comma ) | ( Ident ( _ ) , Colon ) => { let names = separated_nonempty ( p , Comma , Colon , " " , | p | { parse_ident ( p , " " ) . map ( | n | n . into ( ) ) } ) ? ; require ( p , Colon ) ? ; let name = parse_name ( p ) ? ; ast :: BlockCompSpec :: CompNames ( names , name ) } ( wrong , _ ) => { if let Some ( name ) = try_name ( p ) ? { ast :: BlockCompSpec :: Block ( name ) } else { let sp = p . peek ( 0 ) . span ; p . emit ( DiagBuilder2 :: error ( format ! ( " \
 " wrong ) ) . span ( sp ) , ) ; return Err ( Reported ) ; } } } ; span . expand ( p . last_span ( ) ) ; Ok ( Spanned :: new ( spec , span ) ) }
Parse a block or component specification.
Parse a block or component specification .
p
&mut P
p
&mut P