sv_parser_parser/specify_section/
specify_path_declarations.rs1use crate::*;
2
3#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn path_declaration(s: Span) -> IResult<Span, PathDeclaration> {
8 alt((
9 map(pair(simple_path_declaration, symbol(";")), |x| {
10 PathDeclaration::SimplePathDeclaration(Box::new(x))
11 }),
12 map(pair(edge_sensitive_path_declaration, symbol(";")), |x| {
13 PathDeclaration::EdgeSensitivePathDeclaration(Box::new(x))
14 }),
15 map(pair(state_dependent_path_declaration, symbol(";")), |x| {
16 PathDeclaration::StateDependentPathDeclaration(Box::new(x))
17 }),
18 ))(s)
19}
20
21#[tracable_parser]
22#[packrat_parser]
23pub(crate) fn simple_path_declaration(s: Span) -> IResult<Span, SimplePathDeclaration> {
24 alt((
25 simple_path_declaration_parallel,
26 simple_path_declaration_full,
27 ))(s)
28}
29
30#[tracable_parser]
31#[packrat_parser]
32pub(crate) fn simple_path_declaration_parallel(s: Span) -> IResult<Span, SimplePathDeclaration> {
33 let (s, a) = parallel_path_description(s)?;
34 let (s, b) = symbol("=")(s)?;
35 let (s, c) = path_delay_value(s)?;
36 Ok((
37 s,
38 SimplePathDeclaration::Parallel(Box::new(SimplePathDeclarationParallel {
39 nodes: (a, b, c),
40 })),
41 ))
42}
43
44#[tracable_parser]
45#[packrat_parser]
46pub(crate) fn simple_path_declaration_full(s: Span) -> IResult<Span, SimplePathDeclaration> {
47 let (s, a) = full_path_description(s)?;
48 let (s, b) = symbol("=")(s)?;
49 let (s, c) = path_delay_value(s)?;
50 Ok((
51 s,
52 SimplePathDeclaration::Full(Box::new(SimplePathDeclarationFull { nodes: (a, b, c) })),
53 ))
54}
55
56#[tracable_parser]
57#[packrat_parser]
58pub(crate) fn parallel_path_description(s: Span) -> IResult<Span, ParallelPathDescription> {
59 let (s, a) = paren(tuple((
60 specify_input_terminal_descriptor,
61 opt(polarity_operator),
62 symbol("=>"),
63 specify_output_terminal_descriptor,
64 )))(s)?;
65 Ok((s, ParallelPathDescription { nodes: (a,) }))
66}
67
68#[tracable_parser]
69#[packrat_parser]
70pub(crate) fn full_path_description(s: Span) -> IResult<Span, FullPathDescription> {
71 let (s, a) = paren(tuple((
72 list_of_path_inputs,
73 opt(polarity_operator),
74 symbol("*>"),
75 list_of_path_outputs,
76 )))(s)?;
77 Ok((s, FullPathDescription { nodes: (a,) }))
78}
79
80#[tracable_parser]
81#[packrat_parser]
82pub(crate) fn list_of_path_inputs(s: Span) -> IResult<Span, ListOfPathInputs> {
83 let (s, a) = list(symbol(","), specify_input_terminal_descriptor)(s)?;
84 Ok((s, ListOfPathInputs { nodes: (a,) }))
85}
86
87#[tracable_parser]
88#[packrat_parser]
89pub(crate) fn list_of_path_outputs(s: Span) -> IResult<Span, ListOfPathOutputs> {
90 let (s, a) = list(symbol(","), specify_output_terminal_descriptor)(s)?;
91 Ok((s, ListOfPathOutputs { nodes: (a,) }))
92}