pub fn parse_control_instruction(input: &[u8]) -> IResult<&[u8], ControlInstruction> {
    alt((
        map(match_byte(0x00), |_| ControlInstruction::Unreachable),
        map(match_byte(0x01), |_| ControlInstruction::Nop),
        map(
            preceded(
                match_byte(0x02),
                tuple((parse_block_type, parse_expression)),
            ),
            |(kind, expression)| ControlInstruction::Block(kind, expression),
        ),
        map(
            preceded(
                match_byte(0x03),
                tuple((parse_block_type, parse_expression)),
            ),
            |(kind, expression)| ControlInstruction::Loop(kind, expression),
        ),
        map(
            preceded(
                match_byte(0x04),
                tuple((parse_block_type, parse_expression)),
            ),
            |(kind, expression)| ControlInstruction::If(kind, expression, None),
        ),
        map(
            preceded(
                match_byte(0x04),
                tuple((
                    parse_block_type,
                    parse_expression_with_terminal(0x05),
                    parse_expression,
                )),
            ),
            |(kind, true_expression, false_expression)| {
                ControlInstruction::If(kind, true_expression, Some(false_expression))
            },
        ),
        map(
            preceded(match_byte(0x0C), parse_u32),
            ControlInstruction::Branch,
        ),
        map(
            preceded(match_byte(0x0D), parse_u32),
            ControlInstruction::BranchIf,
        ),
        map(
            preceded(
                match_byte(0x0E),
                tuple((parse_vector(parse_u32), parse_u32)),
            ),
            |(head, last)| ControlInstruction::BranchTable(head, last),
        ),
        map(match_byte(0x0F), |_| ControlInstruction::Return),
        map(
            preceded(match_byte(0x10), parse_u32),
            ControlInstruction::Call,
        ),
        map(
            preceded(match_byte(0x11), tuple((parse_u32, parse_u32))),
            |(type_index, table_index)| ControlInstruction::CallIndirect(type_index, table_index),
        ),
    ))(input)
}
/// Parses a WebAssembly control instruction from the input.
///
/// See <https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions>
Parses a WebAssembly control instruction from the input.
See
Parses a WebAssembly control instruction from the input . See
pub fn parse_control_instruction(input: &[u8]) -> IResult<&[u8], ControlInstruction> {
    alt((
        map(match_byte(0x00), |_| ControlInstruction::Unreachable),
        map(match_byte(0x01), |_| ControlInstruction::Nop),
        map(
            preceded(
                match_byte(0x02),
                tuple((parse_block_type, parse_expression)),
            ),
            |(kind, expression)| ControlInstruction::Block(kind, expression),
        ),
        map(
            preceded(
                match_byte(0x03),
                tuple((parse_block_type, parse_expression)),
            ),
            |(kind, expression)| ControlInstruction::Loop(kind, expression),
        ),
        map(
            preceded(
                match_byte(0x04),
                tuple((parse_block_type, parse_expression)),
            ),
            |(kind, expression)| ControlInstruction::If(kind, expression, None),
        ),
        map(
            preceded(
                match_byte(0x04),
                tuple((
                    parse_block_type,
                    parse_expression_with_terminal(0x05),
                    parse_expression,
                )),
            ),
            |(kind, true_expression, false_expression)| {
                ControlInstruction::If(kind, true_expression, Some(false_expression))
            },
        ),
        map(
            preceded(match_byte(0x0C), parse_u32),
            ControlInstruction::Branch,
        ),
        map(
            preceded(match_byte(0x0D), parse_u32),
            ControlInstruction::BranchIf,
        ),
        map(
            preceded(
                match_byte(0x0E),
                tuple((parse_vector(parse_u32), parse_u32)),
            ),
            |(head, last)| ControlInstruction::BranchTable(head, last),
        ),
        map(match_byte(0x0F), |_| ControlInstruction::Return),
        map(
            preceded(match_byte(0x10), parse_u32),
            ControlInstruction::Call,
        ),
        map(
            preceded(match_byte(0x11), tuple((parse_u32, parse_u32))),
            |(type_index, table_index)| ControlInstruction::CallIndirect(type_index, table_index),
        ),
    ))(input)
}
pub fn parse_control_instruction ( input : & [ u8 ] ) -> IResult < & [ u8 ] , ControlInstruction > { alt ( ( map ( match_byte ( 0x00 ) , | _ | ControlInstruction :: Unreachable ) , map ( match_byte ( 0x01 ) , | _ | ControlInstruction :: Nop ) , map ( preceded ( match_byte ( 0x02 ) , tuple ( ( parse_block_type , parse_expression ) ) , ) , | ( kind , expression ) | ControlInstruction :: Block ( kind , expression ) , ) , map ( preceded ( match_byte ( 0x03 ) , tuple ( ( parse_block_type , parse_expression ) ) , ) , | ( kind , expression ) | ControlInstruction :: Loop ( kind , expression ) , ) , map ( preceded ( match_byte ( 0x04 ) , tuple ( ( parse_block_type , parse_expression ) ) , ) , | ( kind , expression ) | ControlInstruction :: If ( kind , expression , None ) , ) , map ( preceded ( match_byte ( 0x04 ) , tuple ( ( parse_block_type , parse_expression_with_terminal ( 0x05 ) , parse_expression , ) ) , ) , | ( kind , true_expression , false_expression ) | { ControlInstruction :: If ( kind , true_expression , Some ( false_expression ) ) } , ) , map ( preceded ( match_byte ( 0x0C ) , parse_u32 ) , ControlInstruction :: Branch , ) , map ( preceded ( match_byte ( 0x0D ) , parse_u32 ) , ControlInstruction :: BranchIf , ) , map ( preceded ( match_byte ( 0x0E ) , tuple ( ( parse_vector ( parse_u32 ) , parse_u32 ) ) , ) , | ( head , last ) | ControlInstruction :: BranchTable ( head , last ) , ) , map ( match_byte ( 0x0F ) , | _ | ControlInstruction :: Return ) , map ( preceded ( match_byte ( 0x10 ) , parse_u32 ) , ControlInstruction :: Call , ) , map ( preceded ( match_byte ( 0x11 ) , tuple ( ( parse_u32 , parse_u32 ) ) ) , | ( type_index , table_index ) | ControlInstruction :: CallIndirect ( type_index , table_index ) , ) , ) ) ( input ) }
Parses a WebAssembly control instruction from the input.
Parses a WebAssembly control instruction from the input .
input
&[u8]
input
&[u8]