sv_parser_parser/specify_section/
specify_block_terminals.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn specify_input_terminal_descriptor(
8    s: Span,
9) -> IResult<Span, SpecifyInputTerminalDescriptor> {
10    let (s, a) = input_identifier(s)?;
11    let (s, b) = opt(bracket(constant_range_expression))(s)?;
12    Ok((s, SpecifyInputTerminalDescriptor { nodes: (a, b) }))
13}
14
15#[tracable_parser]
16#[packrat_parser]
17pub(crate) fn specify_output_terminal_descriptor(
18    s: Span,
19) -> IResult<Span, SpecifyOutputTerminalDescriptor> {
20    let (s, a) = output_identifier(s)?;
21    let (s, b) = opt(bracket(constant_range_expression))(s)?;
22    Ok((s, SpecifyOutputTerminalDescriptor { nodes: (a, b) }))
23}
24
25#[tracable_parser]
26#[packrat_parser]
27pub(crate) fn input_identifier(s: Span) -> IResult<Span, InputIdentifier> {
28    alt((
29        input_identifier_interface,
30        map(input_port_identifier, |x| {
31            InputIdentifier::InputPortIdentifier(Box::new(x))
32        }),
33        map(inout_port_identifier, |x| {
34            InputIdentifier::InoutPortIdentifier(Box::new(x))
35        }),
36    ))(s)
37}
38
39#[tracable_parser]
40#[packrat_parser]
41pub(crate) fn input_identifier_interface(s: Span) -> IResult<Span, InputIdentifier> {
42    let (s, a) = interface_identifier(s)?;
43    let (s, b) = symbol(".")(s)?;
44    let (s, c) = port_identifier(s)?;
45    Ok((
46        s,
47        InputIdentifier::Interface(Box::new(InputIdentifierInterface { nodes: (a, b, c) })),
48    ))
49}
50
51#[tracable_parser]
52#[packrat_parser]
53pub(crate) fn output_identifier(s: Span) -> IResult<Span, OutputIdentifier> {
54    alt((
55        output_identifier_interface,
56        map(output_port_identifier, |x| {
57            OutputIdentifier::OutputPortIdentifier(Box::new(x))
58        }),
59        map(inout_port_identifier, |x| {
60            OutputIdentifier::InoutPortIdentifier(Box::new(x))
61        }),
62    ))(s)
63}
64
65#[tracable_parser]
66#[packrat_parser]
67pub(crate) fn output_identifier_interface(s: Span) -> IResult<Span, OutputIdentifier> {
68    let (s, a) = interface_identifier(s)?;
69    let (s, b) = symbol(".")(s)?;
70    let (s, c) = port_identifier(s)?;
71    Ok((
72        s,
73        OutputIdentifier::Interface(Box::new(OutputIdentifierInterface { nodes: (a, b, c) })),
74    ))
75}