/// Parse a next or exit statement. See IEEE 1076-2008 sections 10.11 and 10.12.
///
/// ```text
/// nexit_stmt := ("next"|"exit") [ident] ["when" expr] ";"
/// ```
Parse a next or exit statement.
Parse a next or exit statement .
pub fn parse_nexit_stmt<P: Parser>(p: &mut P) -> ReportedResult<ast::StmtData> {
    let pk = p.peek(0);
    let mode = match pk.value {
        Keyword(Kw::Next) => {
            p.bump();
            ast::NexitMode::Next
        }
        Keyword(Kw::Exit) => {
            p.bump();
            ast::NexitMode::Exit
        }
        _ => {
            p.emit(
                DiagBuilder2::error(format!(
                    "Expected `next` or `exit`, found {} instead",
                    pk.value
                ))
                .span(pk.span)
                .add_note("see IEEE 1076-2008 sections 10.11 and 10.12"),
            );
            return Err(Reported);
        }
    };
    let target = try_ident(p);
    let cond = if accept(p, Keyword(Kw::When)) {
        Some(parse_expr(p)?)
    } else {
        None
    };
    require(p, Semicolon)?;
    Ok(ast::NexitStmt {
        mode: mode,
        target: target.map(|t| t.into()),
        cond: cond,
    })
}
pub fn parse_nexit_stmt < P : Parser > ( p : & mut P ) -> ReportedResult < ast :: StmtData > { let pk = p . peek ( 0 ) ; let mode = match pk . value { Keyword ( Kw :: Next ) => { p . bump ( ) ; ast :: NexitMode :: Next } Keyword ( Kw :: Exit ) => { p . bump ( ) ; ast :: NexitMode :: Exit } _ => { p . emit ( DiagBuilder2 :: error ( format ! ( " " pk value ) ) . span ( pk . span ) . add_note ( " " ) , ) ; return Err ( Reported ) ; } } ; let target = try_ident ( p ) ; let cond = if accept ( p , Keyword ( Kw :: When ) ) { Some ( parse_expr ( p ) ? ) } else { None } ; require ( p , Semicolon ) ? ; Ok ( ast :: NexitStmt { mode : mode , target : target . map ( | t | t . into ( ) ) , cond : cond , } ) }
Parse a next or exit statement.
Parse a next or exit statement .
p
&mut P