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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
use crate::*;
#[tracable_parser]
#[packrat_parser]
pub(crate) fn module_instantiation(s: Span) -> IResult<Span, ModuleInstantiation> {
let (s, a) = module_identifier(s)?;
let (s, b) = opt(parameter_value_assignment)(s)?;
let (s, c) = list(symbol(","), hierarchical_instance)(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
s,
ModuleInstantiation {
nodes: (a, b, c, d),
},
))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn parameter_value_assignment(s: Span) -> IResult<Span, ParameterValueAssignment> {
let (s, a) = symbol("#")(s)?;
let (s, b) = paren(opt(list_of_parameter_assignments))(s)?;
Ok((s, ParameterValueAssignment { nodes: (a, b) }))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_parameter_assignments(s: Span) -> IResult<Span, ListOfParameterAssignments> {
alt((
list_of_parameter_assignments_named,
list_of_parameter_assignments_ordered,
))(s)
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_parameter_assignments_ordered(
s: Span,
) -> IResult<Span, ListOfParameterAssignments> {
let (s, a) = list(symbol(","), ordered_parameter_assignment)(s)?;
Ok((
s,
ListOfParameterAssignments::Ordered(Box::new(ListOfParameterAssignmentsOrdered {
nodes: (a,),
})),
))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_parameter_assignments_named(
s: Span,
) -> IResult<Span, ListOfParameterAssignments> {
let (s, a) = list(symbol(","), named_parameter_assignment)(s)?;
Ok((
s,
ListOfParameterAssignments::Named(Box::new(ListOfParameterAssignmentsNamed {
nodes: (a,),
})),
))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn ordered_parameter_assignment(s: Span) -> IResult<Span, OrderedParameterAssignment> {
let (s, x) = param_expression(s)?;
Ok((s, OrderedParameterAssignment { nodes: (x,) }))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn named_parameter_assignment(s: Span) -> IResult<Span, NamedParameterAssignment> {
let (s, a) = symbol(".")(s)?;
let (s, b) = parameter_identifier(s)?;
let (s, c) = paren(opt(param_expression))(s)?;
Ok((s, NamedParameterAssignment { nodes: (a, b, c) }))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn hierarchical_instance(s: Span) -> IResult<Span, HierarchicalInstance> {
let (s, a) = name_of_instance(s)?;
let (s, b) = paren(opt(list_of_port_connections))(s)?;
Ok((s, HierarchicalInstance { nodes: (a, b) }))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn name_of_instance(s: Span) -> IResult<Span, NameOfInstance> {
let (s, x) = instance_identifier(s)?;
let (s, y) = many0(unpacked_dimension)(s)?;
Ok((s, NameOfInstance { nodes: (x, y) }))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_port_connections(s: Span) -> IResult<Span, ListOfPortConnections> {
alt((
list_of_port_connections_named,
list_of_port_connections_ordered,
))(s)
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_port_connections_ordered(s: Span) -> IResult<Span, ListOfPortConnections> {
let (s, a) = list(symbol(","), ordered_port_connection)(s)?;
Ok((
s,
ListOfPortConnections::Ordered(Box::new(ListOfPortConnectionsOrdered { nodes: (a,) })),
))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn list_of_port_connections_named(s: Span) -> IResult<Span, ListOfPortConnections> {
let (s, a) = list(symbol(","), named_port_connection)(s)?;
Ok((
s,
ListOfPortConnections::Named(Box::new(ListOfPortConnectionsNamed { nodes: (a,) })),
))
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn ordered_port_connection(s: Span) -> IResult<Span, OrderedPortConnection> {
let (s, x) = many0(attribute_instance)(s)?;
let (s, y) = opt(expression)(s)?;
Ok((s, OrderedPortConnection { nodes: (x, y) }))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn named_port_connection(s: Span) -> IResult<Span, NamedPortConnection> {
alt((
named_port_connection_identifier,
named_port_connection_asterisk,
))(s)
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn named_port_connection_identifier(s: Span) -> IResult<Span, NamedPortConnection> {
let (s, (a, b)) = many_till(attribute_instance, symbol("."))(s)?;
let (s, c) = port_identifier(s)?;
let (s, d) = opt(paren(opt(expression)))(s)?;
Ok((
s,
NamedPortConnection::Identifier(Box::new(NamedPortConnectionIdentifier {
nodes: (a, b, c, d),
})),
))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn named_port_connection_asterisk(s: Span) -> IResult<Span, NamedPortConnection> {
let (s, (a, b)) = many_till(attribute_instance, symbol(".*"))(s)?;
Ok((
s,
NamedPortConnection::Asterisk(Box::new(NamedPortConnectionAsterisk { nodes: (a, b) })),
))
}