/// Parse a generate case statement. See IEEE 1076-2008 section 11.8.
///
/// ```text
/// generate_case_stmt := "case" expr "generate" {"when" [ident ":"] {expr}"|"+ "=>" generate_body}+ "end" "generate" [ident] ";"
/// ```
Parse a generate case statement.
Parse a generate case statement .
pub fn parse_case_generate_stmt<P: Parser>(
    p: &mut P,
    label: Option<Spanned<Name>>,
) -> ReportedResult<ast::StmtData> {
    require(p, Keyword(Kw::Case))?;
    let switch = parse_expr(p)?;
    require(p, Keyword(Kw::Generate))?;
    // Parse the cases.
    let cases = repeat(
        p,
        |p| -> ReportedResult<Option<(Spanned<Vec<ast::Expr>>, ast::GenBody)>> {
            if accept(p, Keyword(Kw::When)) {
                let label = try_label(p);
                let mut choices_span = p.peek(0).span;
                let choices = separated_nonempty(p, Pipe, Arrow, "choice", parse_expr)?;
                choices_span.expand(p.last_span());
                require(p, Arrow)?;
                let body = parse_generate_body(
                    p,
                    label,
                    token_predicate!(Keyword(Kw::When), Keyword(Kw::End)),
                )?;
                Ok(Some((Spanned::new(choices, choices_span), body)))
            } else {
                Ok(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::CaseGenStmt {
        switch: switch,
        cases: cases,
    })
}
pub fn parse_case_generate_stmt < P : Parser > ( p : & mut P , label : Option < Spanned < Name > > , ) -> ReportedResult < ast :: StmtData > { require ( p , Keyword ( Kw :: Case ) ) ? ; let switch = parse_expr ( p ) ? ; require ( p , Keyword ( Kw :: Generate ) ) ? ; // Parse the cases. let cases = repeat ( p , | p | -> ReportedResult < Option < ( Spanned < Vec < ast :: Expr > > , ast :: GenBody ) > > { if accept ( p , Keyword ( Kw :: When ) ) { let label = try_label ( p ) ; let mut choices_span = p . peek ( 0 ) . span ; let choices = separated_nonempty ( p , Pipe , Arrow , " " , parse_expr ) ? ; choices_span . expand ( p . last_span ( ) ) ; require ( p , Arrow ) ? ; let body = parse_generate_body ( p , label , token_predicate ! ( Keyword ( Kw When ) Keyword ( Kw End ) ) , ) ? ; Ok ( Some ( ( Spanned :: new ( choices , choices_span ) , body ) ) ) } else { Ok ( 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 :: CaseGenStmt { switch : switch , cases : cases , } ) }
Parse a generate case statement.
Parse a generate case statement .
p
&mut P
label
Option<Spanned<Name>>