/// Parse a generate if statement. See IEEE 1076-2008 section 11.8.
///
/// ```text
/// generate_if_stmt :=
///   "if" [ident ":"] expr "generate" generate_body
///   {"elsif" [ident ":"] expr "generate" generate_body}
///   ["else" [ident ":"] "generate" generate_body]
///   "end" "generate" [ident] ";"
/// ```
Parse a generate if statement.
Parse a generate if statement .
pub fn parse_if_generate_stmt<P: Parser>(
    p: &mut P,
    label: Option<Spanned<Name>>,
) -> ReportedResult<ast::StmtData> {
    require(p, Keyword(Kw::If))?;
    // Parse the first `if` and subsequent `elsif` branches.
    let conds = separated_nonempty(
        p,
        Keyword(Kw::Elsif),
        token_predicate!(Keyword(Kw::Else), Keyword(Kw::End)),
        "if generate branch",
        |p| {
            let label = try_label(p);
            let cond = parse_expr(p)?;
            require(p, Keyword(Kw::Generate))?;
            let body = parse_generate_body(
                p,
                label,
                token_predicate!(Keyword(Kw::Elsif), Keyword(Kw::Else), Keyword(Kw::End)),
            )?;
            Ok((cond, body))
        },
    )?;
    // Parse the optional `else` branch.
    let alt = if accept(p, Keyword(Kw::Else)) {
        let label = try_label(p);
        require(p, Keyword(Kw::Generate))?;
        let body = parse_generate_body(p, label, Keyword(Kw::End))?;
        Some(body)
    } else {
        None
    };
    // Parse the rest.
    require(p, Keyword(Kw::End))?;
    require(p, Keyword(Kw::Generate))?;
    parse_optional_matching_ident(p, label, "generate statement", "section 11.8");
    require(p, Semicolon)?;
    Ok(ast::IfGenStmt {
        conds: conds,
        alt: alt,
    })
}
pub fn parse_if_generate_stmt < P : Parser > ( p : & mut P , label : Option < Spanned < Name > > , ) -> ReportedResult < ast :: StmtData > { require ( p , Keyword ( Kw :: If ) ) ? ; // Parse the first `if` and subsequent `elsif` branches. let conds = separated_nonempty ( p , Keyword ( Kw :: Elsif ) , token_predicate ! ( Keyword ( Kw Else ) Keyword ( Kw End ) ) , " " , | p | { let label = try_label ( p ) ; let cond = parse_expr ( p ) ? ; require ( p , Keyword ( Kw :: Generate ) ) ? ; let body = parse_generate_body ( p , label , token_predicate ! ( Keyword ( Kw Elsif ) Keyword ( Kw Else ) Keyword ( Kw End ) ) , ) ? ; Ok ( ( cond , body ) ) } , ) ? ; // Parse the optional `else` branch. let alt = if accept ( p , Keyword ( Kw :: Else ) ) { let label = try_label ( p ) ; require ( p , Keyword ( Kw :: Generate ) ) ? ; let body = parse_generate_body ( p , label , Keyword ( Kw :: End ) ) ? ; Some ( body ) } else { None } ; // Parse the rest. require ( p , Keyword ( Kw :: End ) ) ? ; require ( p , Keyword ( Kw :: Generate ) ) ? ; parse_optional_matching_ident ( p , label , " " , " " ) ; require ( p , Semicolon ) ? ; Ok ( ast :: IfGenStmt { conds : conds , alt : alt , } ) }
Parse a generate if statement.
Parse a generate if statement .
p
&mut P
label
Option<Spanned<Name>>