sv_parser_parser/source_text/
configuration_source_text.rs1use crate::*;
2
3#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn config_declaration(s: Span) -> IResult<Span, ConfigDeclaration> {
8 let (s, a) = context("config", keyword("config"))(s)?;
9 let (s, b) = config_identifier(s)?;
10 let (s, c) = symbol(";")(s)?;
11 let (s, d) = many0(pair(local_parameter_declaration, symbol(";")))(s)?;
12 let (s, e) = design_statement(s)?;
13 let (s, (f, g)) = many_till(config_rule_statement, keyword("endconfig"))(s)?;
14 let (s, h) = opt(pair(symbol(":"), config_identifier))(s)?;
15 Ok((
16 s,
17 ConfigDeclaration {
18 nodes: (a, b, c, d, e, f, g, h),
19 },
20 ))
21}
22
23#[tracable_parser]
24#[packrat_parser]
25pub(crate) fn design_statement(s: Span) -> IResult<Span, DesignStatement> {
26 let (s, a) = keyword("design")(s)?;
27 let (s, (b, c)) = many_till(
28 pair(opt(pair(library_identifier, symbol("."))), cell_identifier),
29 symbol(";"),
30 )(s)?;
31 Ok((s, DesignStatement { nodes: (a, b, c) }))
32}
33
34#[tracable_parser]
35#[packrat_parser]
36pub(crate) fn config_rule_statement(s: Span) -> IResult<Span, ConfigRuleStatement> {
37 alt((
38 config_rule_statement_default,
39 config_rule_statement_inst_lib,
40 config_rule_statement_inst_use,
41 config_rule_statement_cell_lib,
42 config_rule_statement_cell_use,
43 ))(s)
44}
45
46#[tracable_parser]
47#[packrat_parser]
48pub(crate) fn config_rule_statement_default(s: Span) -> IResult<Span, ConfigRuleStatement> {
49 let (s, a) = default_clause(s)?;
50 let (s, b) = liblist_clause(s)?;
51 let (s, c) = symbol(";")(s)?;
52 Ok((
53 s,
54 ConfigRuleStatement::Default(Box::new(ConfigRuleStatementDefault { nodes: (a, b, c) })),
55 ))
56}
57
58#[tracable_parser]
59#[packrat_parser]
60pub(crate) fn config_rule_statement_inst_lib(s: Span) -> IResult<Span, ConfigRuleStatement> {
61 let (s, a) = inst_clause(s)?;
62 let (s, b) = liblist_clause(s)?;
63 let (s, c) = symbol(";")(s)?;
64 Ok((
65 s,
66 ConfigRuleStatement::InstLib(Box::new(ConfigRuleStatementInstLib { nodes: (a, b, c) })),
67 ))
68}
69
70#[tracable_parser]
71#[packrat_parser]
72pub(crate) fn config_rule_statement_inst_use(s: Span) -> IResult<Span, ConfigRuleStatement> {
73 let (s, a) = inst_clause(s)?;
74 let (s, b) = use_clause(s)?;
75 let (s, c) = symbol(";")(s)?;
76 Ok((
77 s,
78 ConfigRuleStatement::InstUse(Box::new(ConfigRuleStatementInstUse { nodes: (a, b, c) })),
79 ))
80}
81
82#[tracable_parser]
83#[packrat_parser]
84pub(crate) fn config_rule_statement_cell_lib(s: Span) -> IResult<Span, ConfigRuleStatement> {
85 let (s, a) = cell_clause(s)?;
86 let (s, b) = liblist_clause(s)?;
87 let (s, c) = symbol(";")(s)?;
88 Ok((
89 s,
90 ConfigRuleStatement::CellLib(Box::new(ConfigRuleStatementCellLib { nodes: (a, b, c) })),
91 ))
92}
93
94#[tracable_parser]
95#[packrat_parser]
96pub(crate) fn config_rule_statement_cell_use(s: Span) -> IResult<Span, ConfigRuleStatement> {
97 let (s, a) = cell_clause(s)?;
98 let (s, b) = use_clause(s)?;
99 let (s, c) = symbol(";")(s)?;
100 Ok((
101 s,
102 ConfigRuleStatement::CellUse(Box::new(ConfigRuleStatementCellUse { nodes: (a, b, c) })),
103 ))
104}
105
106#[tracable_parser]
107#[packrat_parser]
108pub(crate) fn default_clause(s: Span) -> IResult<Span, DefaultClause> {
109 let (s, a) = keyword("default")(s)?;
110 Ok((s, DefaultClause { nodes: (a,) }))
111}
112
113#[tracable_parser]
114#[packrat_parser]
115pub(crate) fn inst_clause(s: Span) -> IResult<Span, InstClause> {
116 let (s, a) = keyword("instance")(s)?;
117 let (s, b) = inst_name(s)?;
118 Ok((s, InstClause { nodes: (a, b) }))
119}
120
121#[tracable_parser]
122#[packrat_parser]
123pub(crate) fn inst_name(s: Span) -> IResult<Span, InstName> {
124 let (s, a) = topmodule_identifier(s)?;
125 let (s, b) = many0(pair(symbol("."), instance_identifier))(s)?;
126 Ok((s, InstName { nodes: (a, b) }))
127}
128
129#[tracable_parser]
130#[packrat_parser]
131pub(crate) fn cell_clause(s: Span) -> IResult<Span, CellClause> {
132 let (s, a) = keyword("cell")(s)?;
133 let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
134 let (s, c) = cell_identifier(s)?;
135 Ok((s, CellClause { nodes: (a, b, c) }))
136}
137
138#[tracable_parser]
139#[packrat_parser]
140pub(crate) fn liblist_clause(s: Span) -> IResult<Span, LiblistClause> {
141 let (s, a) = keyword("liblist")(s)?;
142 let (s, b) = many0(library_identifier)(s)?;
143 Ok((s, LiblistClause { nodes: (a, b) }))
144}
145
146#[tracable_parser]
147#[packrat_parser]
148pub(crate) fn use_clause(s: Span) -> IResult<Span, UseClause> {
149 alt((use_clause_cell, use_clause_named, use_clause_cell_named))(s)
150}
151
152#[tracable_parser]
153#[packrat_parser]
154pub(crate) fn use_clause_cell(s: Span) -> IResult<Span, UseClause> {
155 let (s, a) = keyword("use")(s)?;
156 let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
157 let (s, c) = cell_identifier(s)?;
158 let (s, d) = opt(pair(symbol(":"), config))(s)?;
159 Ok((
160 s,
161 UseClause::Cell(Box::new(UseClauseCell {
162 nodes: (a, b, c, d),
163 })),
164 ))
165}
166
167#[tracable_parser]
168#[packrat_parser]
169pub(crate) fn use_clause_named(s: Span) -> IResult<Span, UseClause> {
170 let (s, a) = keyword("use")(s)?;
171 let (s, b) = list(symbol(","), named_parameter_assignment)(s)?;
172 let (s, c) = opt(pair(symbol(":"), config))(s)?;
173 Ok((
174 s,
175 UseClause::Named(Box::new(UseClauseNamed { nodes: (a, b, c) })),
176 ))
177}
178
179#[tracable_parser]
180#[packrat_parser]
181pub(crate) fn use_clause_cell_named(s: Span) -> IResult<Span, UseClause> {
182 let (s, a) = keyword("use")(s)?;
183 let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
184 let (s, c) = cell_identifier(s)?;
185 let (s, d) = list(symbol(","), named_parameter_assignment)(s)?;
186 let (s, e) = opt(pair(symbol(":"), config))(s)?;
187 Ok((
188 s,
189 UseClause::CellNamed(Box::new(UseClauseCellNamed {
190 nodes: (a, b, c, d, e),
191 })),
192 ))
193}
194
195#[tracable_parser]
196#[packrat_parser]
197pub(crate) fn config(s: Span) -> IResult<Span, Config> {
198 let (s, a) = keyword("config")(s)?;
199 Ok((s, Config { nodes: (a,) }))
200}