use crate::*; // ----------------------------------------------------------------------------- #[parser] pub(crate) fn udp_port_list(s: Span) -> IResult { let (s, a) = output_port_identifier(s)?; let (s, b) = symbol(",")(s)?; let (s, c) = list(symbol(","), input_port_identifier)(s)?; Ok((s, UdpPortList { nodes: (a, b, c) })) } #[parser] pub(crate) fn udp_declaration_port_list(s: Span) -> IResult { let (s, a) = udp_output_declaration(s)?; let (s, b) = symbol(",")(s)?; let (s, c) = list(symbol(","), udp_input_declaration)(s)?; Ok((s, UdpDeclarationPortList { nodes: (a, b, c) })) } #[parser] pub(crate) fn udp_port_declaration(s: Span) -> IResult { alt(( map(pair(udp_output_declaration, symbol(";")), |x| { UdpPortDeclaration::UdpOutputDeclaration(Box::new(x)) }), map(pair(udp_input_declaration, symbol(";")), |x| { UdpPortDeclaration::UdpInputDeclaration(Box::new(x)) }), map(pair(udp_reg_declaration, symbol(";")), |x| { UdpPortDeclaration::UdpRegDeclaration(Box::new(x)) }), ))(s) } #[parser] pub(crate) fn udp_output_declaration(s: Span) -> IResult { alt((udp_output_declaration_nonreg, udp_output_declaration_reg))(s) } #[parser] pub(crate) fn udp_output_declaration_nonreg(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("output")(s)?; let (s, c) = port_identifier(s)?; Ok(( s, UdpOutputDeclaration::Nonreg(Box::new(UdpOutputDeclarationNonreg { nodes: (a, b, c) })), )) } #[parser] pub(crate) fn udp_output_declaration_reg(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("output")(s)?; let (s, c) = keyword("reg")(s)?; let (s, d) = port_identifier(s)?; let (s, e) = opt(pair(symbol("="), constant_expression))(s)?; Ok(( s, UdpOutputDeclaration::Reg(Box::new(UdpOutputDeclarationReg { nodes: (a, b, c, d, e), })), )) } #[parser] pub(crate) fn udp_input_declaration(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("input")(s)?; let (s, c) = list_of_udp_port_identifiers(s)?; Ok((s, UdpInputDeclaration { nodes: (a, b, c) })) } #[parser] pub(crate) fn udp_reg_declaration(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("reg")(s)?; let (s, c) = variable_identifier(s)?; Ok((s, UdpRegDeclaration { nodes: (a, b, c) })) }