use crate::ast::*; use crate::parser::*; use nom::branch::*; use nom::combinator::*; use nom::multi::*; use nom::IResult; // ----------------------------------------------------------------------------- #[derive(Clone, Debug, Node)] pub struct CheckerInstantiation { pub nodes: ( PsCheckerIdentifier, NameOfInstance, Paren>, Symbol, ), } #[derive(Clone, Debug, Node)] pub enum ListOfCheckerPortConnections { Ordered(Box), Named(Box), } #[derive(Clone, Debug, Node)] pub struct ListOfCheckerPortConnectionsOrdered { pub nodes: (List,), } #[derive(Clone, Debug, Node)] pub struct ListOfCheckerPortConnectionsNamed { pub nodes: (List,), } #[derive(Clone, Debug, Node)] pub struct OrderedCheckerPortConnection { pub nodes: (Vec, Option), } #[derive(Clone, Debug, Node)] pub enum NamedCheckerPortConnection { Identifier(Box), Asterisk(Box), } #[derive(Clone, Debug, Node)] pub struct NamedCheckerPortConnectionIdentifier { pub nodes: ( Vec, Symbol, FormalPortIdentifier, Option>>, ), } #[derive(Clone, Debug, Node)] pub struct NamedCheckerPortConnectionAsterisk { pub nodes: (Vec, Symbol), } // ----------------------------------------------------------------------------- #[parser] pub(crate) fn checker_instantiation(s: Span) -> IResult { let (s, a) = ps_checker_identifier(s)?; let (s, b) = name_of_instance(s)?; let (s, c) = paren(opt(list_of_checker_port_connections))(s)?; let (s, d) = symbol(";")(s)?; Ok(( s, CheckerInstantiation { nodes: (a, b, c, d), }, )) } #[parser] pub(crate) fn list_of_checker_port_connections(s: Span) -> IResult { alt(( list_of_checker_port_connections_ordered, list_of_checker_port_connections_named, ))(s) } #[parser(MaybeRecursive)] pub(crate) fn list_of_checker_port_connections_ordered( s: Span, ) -> IResult { let (s, a) = list(symbol(","), ordered_checker_port_connection)(s)?; Ok(( s, ListOfCheckerPortConnections::Ordered(Box::new(ListOfCheckerPortConnectionsOrdered { nodes: (a,), })), )) } #[parser] pub(crate) fn list_of_checker_port_connections_named( s: Span, ) -> IResult { let (s, a) = list(symbol(","), named_checker_port_connection)(s)?; Ok(( s, ListOfCheckerPortConnections::Named(Box::new(ListOfCheckerPortConnectionsNamed { nodes: (a,), })), )) } #[parser(MaybeRecursive)] pub(crate) fn ordered_checker_port_connection(s: Span) -> IResult { let (s, x) = many0(attribute_instance)(s)?; let (s, y) = opt(property_actual_arg)(s)?; Ok((s, OrderedCheckerPortConnection { nodes: (x, y) })) } #[parser] pub(crate) fn named_checker_port_connection(s: Span) -> IResult { alt(( named_checker_port_connection_identifier, named_checker_port_connection_asterisk, ))(s) } #[parser] pub(crate) fn named_checker_port_connection_identifier( s: Span, ) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = symbol(".")(s)?; let (s, c) = formal_port_identifier(s)?; let (s, d) = opt(paren(opt(property_actual_arg)))(s)?; Ok(( s, NamedCheckerPortConnection::Identifier(Box::new(NamedCheckerPortConnectionIdentifier { nodes: (a, b, c, d), })), )) } #[parser] pub(crate) fn named_checker_port_connection_asterisk( s: Span, ) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = symbol(".*")(s)?; Ok(( s, NamedCheckerPortConnection::Asterisk(Box::new(NamedCheckerPortConnectionAsterisk { nodes: (a, b), })), )) } // -----------------------------------------------------------------------------