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
use crate::*;

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

#[tracable_parser]
#[packrat_parser]
pub(crate) fn specify_input_terminal_descriptor(
    s: Span,
) -> IResult<Span, SpecifyInputTerminalDescriptor> {
    let (s, a) = input_identifier(s)?;
    let (s, b) = opt(bracket(constant_range_expression))(s)?;
    Ok((s, SpecifyInputTerminalDescriptor { nodes: (a, b) }))
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn specify_output_terminal_descriptor(
    s: Span,
) -> IResult<Span, SpecifyOutputTerminalDescriptor> {
    let (s, a) = output_identifier(s)?;
    let (s, b) = opt(bracket(constant_range_expression))(s)?;
    Ok((s, SpecifyOutputTerminalDescriptor { nodes: (a, b) }))
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn input_identifier(s: Span) -> IResult<Span, InputIdentifier> {
    alt((
        input_identifier_interface,
        map(input_port_identifier, |x| {
            InputIdentifier::InputPortIdentifier(Box::new(x))
        }),
        map(inout_port_identifier, |x| {
            InputIdentifier::InoutPortIdentifier(Box::new(x))
        }),
    ))(s)
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn input_identifier_interface(s: Span) -> IResult<Span, InputIdentifier> {
    let (s, a) = interface_identifier(s)?;
    let (s, b) = symbol(".")(s)?;
    let (s, c) = port_identifier(s)?;
    Ok((
        s,
        InputIdentifier::Interface(Box::new(InputIdentifierInterface { nodes: (a, b, c) })),
    ))
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn output_identifier(s: Span) -> IResult<Span, OutputIdentifier> {
    alt((
        output_identifier_interface,
        map(output_port_identifier, |x| {
            OutputIdentifier::OutputPortIdentifier(Box::new(x))
        }),
        map(inout_port_identifier, |x| {
            OutputIdentifier::InoutPortIdentifier(Box::new(x))
        }),
    ))(s)
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn output_identifier_interface(s: Span) -> IResult<Span, OutputIdentifier> {
    let (s, a) = interface_identifier(s)?;
    let (s, b) = symbol(".")(s)?;
    let (s, c) = port_identifier(s)?;
    Ok((
        s,
        OutputIdentifier::Interface(Box::new(OutputIdentifierInterface { nodes: (a, b, c) })),
    ))
}