1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
use crate::*;

// -----------------------------------------------------------------------------

#[tracable_parser]
#[packrat_parser]
pub(crate) fn checker_instantiation(s: Span) -> IResult<Span, CheckerInstantiation> {
    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),
        },
    ))
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_checker_port_connections(
    s: Span,
) -> IResult<Span, ListOfCheckerPortConnections> {
    alt((
        list_of_checker_port_connections_named,
        list_of_checker_port_connections_ordered,
    ))(s)
}

#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_checker_port_connections_ordered(
    s: Span,
) -> IResult<Span, ListOfCheckerPortConnections> {
    let (s, a) = list(symbol(","), ordered_checker_port_connection)(s)?;
    Ok((
        s,
        ListOfCheckerPortConnections::Ordered(Box::new(ListOfCheckerPortConnectionsOrdered {
            nodes: (a,),
        })),
    ))
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_checker_port_connections_named(
    s: Span,
) -> IResult<Span, ListOfCheckerPortConnections> {
    let (s, a) = list(symbol(","), named_checker_port_connection)(s)?;
    Ok((
        s,
        ListOfCheckerPortConnections::Named(Box::new(ListOfCheckerPortConnectionsNamed {
            nodes: (a,),
        })),
    ))
}

#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn ordered_checker_port_connection(
    s: Span,
) -> IResult<Span, OrderedCheckerPortConnection> {
    let (s, x) = many0(attribute_instance)(s)?;
    let (s, y) = opt(property_actual_arg)(s)?;
    Ok((s, OrderedCheckerPortConnection { nodes: (x, y) }))
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn named_checker_port_connection(s: Span) -> IResult<Span, NamedCheckerPortConnection> {
    alt((
        named_checker_port_connection_identifier,
        named_checker_port_connection_asterisk,
    ))(s)
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn named_checker_port_connection_identifier(
    s: Span,
) -> IResult<Span, NamedCheckerPortConnection> {
    let (s, (a, b)) = many_till(attribute_instance, 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),
        })),
    ))
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn named_checker_port_connection_asterisk(
    s: Span,
) -> IResult<Span, NamedCheckerPortConnection> {
    let (s, (a, b)) = many_till(attribute_instance, symbol(".*"))(s)?;
    Ok((
        s,
        NamedCheckerPortConnection::Asterisk(Box::new(NamedCheckerPortConnectionAsterisk {
            nodes: (a, b),
        })),
    ))
}