sv_parser_syntaxtree/source_text/
system_verilog_source_text.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[derive(Clone, Debug, PartialEq, Node)]
6pub struct SourceText {
7    pub nodes: (
8        Vec<WhiteSpace>,
9        Option<TimeunitsDeclaration>,
10        Vec<Description>,
11    ),
12}
13
14#[derive(Clone, Debug, PartialEq, Node)]
15pub enum Description {
16    ResetallCompilerDirective(Box<ResetallCompilerDirective>),
17    ModuleDeclaration(Box<ModuleDeclaration>),
18    UdpDeclaration(Box<UdpDeclaration>),
19    InterfaceDeclaration(Box<InterfaceDeclaration>),
20    InterfaceClassDeclaration(Box<InterfaceClassDeclaration>),
21    ProgramDeclaration(Box<ProgramDeclaration>),
22    PackageDeclaration(Box<PackageDeclaration>),
23    PackageItem(Box<DescriptionPackageItem>),
24    BindDirective(Box<DescriptionBindDirective>),
25    ConfigDeclaration(Box<ConfigDeclaration>),
26}
27
28#[derive(Clone, Debug, PartialEq, Node)]
29pub struct DescriptionPackageItem {
30    pub nodes: (Vec<AttributeInstance>, PackageItem),
31}
32
33#[derive(Clone, Debug, PartialEq, Node)]
34pub struct DescriptionBindDirective {
35    pub nodes: (Vec<AttributeInstance>, BindDirective),
36}
37
38#[derive(Clone, Debug, PartialEq, Node)]
39pub struct ModuleNonansiHeader {
40    pub nodes: (
41        Vec<AttributeInstance>,
42        ModuleKeyword,
43        Option<Lifetime>,
44        ModuleIdentifier,
45        Vec<PackageImportDeclaration>,
46        Option<ParameterPortList>,
47        ListOfPorts,
48        Symbol,
49    ),
50}
51
52#[derive(Clone, Debug, PartialEq, Node)]
53pub struct ModuleAnsiHeader {
54    pub nodes: (
55        Vec<AttributeInstance>,
56        ModuleKeyword,
57        Option<Lifetime>,
58        ModuleIdentifier,
59        Vec<PackageImportDeclaration>,
60        Option<ParameterPortList>,
61        Option<ListOfPortDeclarations>,
62        Symbol,
63    ),
64}
65
66#[derive(Clone, Debug, PartialEq, Node)]
67pub enum ModuleDeclaration {
68    Nonansi(Box<ModuleDeclarationNonansi>),
69    Ansi(Box<ModuleDeclarationAnsi>),
70    Wildcard(Box<ModuleDeclarationWildcard>),
71    ExternNonansi(Box<ModuleDeclarationExternNonansi>),
72    ExternAnsi(Box<ModuleDeclarationExternAnsi>),
73}
74
75#[derive(Clone, Debug, PartialEq, Node)]
76pub struct ModuleDeclarationNonansi {
77    pub nodes: (
78        ModuleNonansiHeader,
79        Option<TimeunitsDeclaration>,
80        Vec<ModuleItem>,
81        Keyword,
82        Option<(Symbol, ModuleIdentifier)>,
83    ),
84}
85
86#[derive(Clone, Debug, PartialEq, Node)]
87pub struct ModuleDeclarationAnsi {
88    pub nodes: (
89        ModuleAnsiHeader,
90        Option<TimeunitsDeclaration>,
91        Vec<NonPortModuleItem>,
92        Keyword,
93        Option<(Symbol, ModuleIdentifier)>,
94    ),
95}
96
97#[derive(Clone, Debug, PartialEq, Node)]
98pub struct ModuleDeclarationWildcard {
99    pub nodes: (
100        Vec<AttributeInstance>,
101        ModuleKeyword,
102        Option<Lifetime>,
103        ModuleIdentifier,
104        Paren<Symbol>,
105        Symbol,
106        Option<TimeunitsDeclaration>,
107        Vec<ModuleItem>,
108        Keyword,
109        Option<(Symbol, ModuleIdentifier)>,
110    ),
111}
112
113#[derive(Clone, Debug, PartialEq, Node)]
114pub struct ModuleDeclarationExternNonansi {
115    pub nodes: (Keyword, ModuleNonansiHeader),
116}
117
118#[derive(Clone, Debug, PartialEq, Node)]
119pub struct ModuleDeclarationExternAnsi {
120    pub nodes: (Keyword, ModuleAnsiHeader),
121}
122
123#[derive(Clone, Debug, PartialEq, Node)]
124pub enum ModuleKeyword {
125    Module(Box<Keyword>),
126    Macromodule(Box<Keyword>),
127}
128
129#[derive(Clone, Debug, PartialEq, Node)]
130pub enum InterfaceDeclaration {
131    Nonansi(Box<InterfaceDeclarationNonansi>),
132    Ansi(Box<InterfaceDeclarationAnsi>),
133    Wildcard(Box<InterfaceDeclarationWildcard>),
134    ExternNonansi(Box<InterfaceDeclarationExternNonansi>),
135    ExternAnsi(Box<InterfaceDeclarationExternAnsi>),
136}
137
138#[derive(Clone, Debug, PartialEq, Node)]
139pub struct InterfaceDeclarationNonansi {
140    pub nodes: (
141        InterfaceNonansiHeader,
142        Option<TimeunitsDeclaration>,
143        Vec<InterfaceItem>,
144        Keyword,
145        Option<(Symbol, InterfaceIdentifier)>,
146    ),
147}
148
149#[derive(Clone, Debug, PartialEq, Node)]
150pub struct InterfaceDeclarationAnsi {
151    pub nodes: (
152        InterfaceAnsiHeader,
153        Option<TimeunitsDeclaration>,
154        Vec<NonPortInterfaceItem>,
155        Keyword,
156        Option<(Symbol, InterfaceIdentifier)>,
157    ),
158}
159
160#[derive(Clone, Debug, PartialEq, Node)]
161pub struct InterfaceDeclarationWildcard {
162    pub nodes: (
163        Vec<AttributeInstance>,
164        Keyword,
165        Option<Lifetime>,
166        InterfaceIdentifier,
167        Paren<Symbol>,
168        Symbol,
169        Option<TimeunitsDeclaration>,
170        Vec<InterfaceItem>,
171        Keyword,
172        Option<(Symbol, InterfaceIdentifier)>,
173    ),
174}
175
176#[derive(Clone, Debug, PartialEq, Node)]
177pub struct InterfaceDeclarationExternNonansi {
178    pub nodes: (Keyword, InterfaceNonansiHeader),
179}
180
181#[derive(Clone, Debug, PartialEq, Node)]
182pub struct InterfaceDeclarationExternAnsi {
183    pub nodes: (Keyword, InterfaceAnsiHeader),
184}
185
186#[derive(Clone, Debug, PartialEq, Node)]
187pub struct InterfaceNonansiHeader {
188    pub nodes: (
189        Vec<AttributeInstance>,
190        Keyword,
191        Option<Lifetime>,
192        InterfaceIdentifier,
193        Vec<PackageImportDeclaration>,
194        Option<ParameterPortList>,
195        ListOfPorts,
196        Symbol,
197    ),
198}
199
200#[derive(Clone, Debug, PartialEq, Node)]
201pub struct InterfaceAnsiHeader {
202    pub nodes: (
203        Vec<AttributeInstance>,
204        Keyword,
205        Option<Lifetime>,
206        InterfaceIdentifier,
207        Vec<PackageImportDeclaration>,
208        Option<ParameterPortList>,
209        Option<ListOfPortDeclarations>,
210        Symbol,
211    ),
212}
213
214#[derive(Clone, Debug, PartialEq, Node)]
215pub enum ProgramDeclaration {
216    Nonansi(Box<ProgramDeclarationNonansi>),
217    Ansi(Box<ProgramDeclarationAnsi>),
218    Wildcard(Box<ProgramDeclarationWildcard>),
219    ExternNonansi(Box<ProgramDeclarationExternNonansi>),
220    ExternAnsi(Box<ProgramDeclarationExternAnsi>),
221}
222
223#[derive(Clone, Debug, PartialEq, Node)]
224pub struct ProgramDeclarationNonansi {
225    pub nodes: (
226        ProgramNonansiHeader,
227        Option<TimeunitsDeclaration>,
228        Vec<ProgramItem>,
229        Keyword,
230        Option<(Symbol, ProgramIdentifier)>,
231    ),
232}
233
234#[derive(Clone, Debug, PartialEq, Node)]
235pub struct ProgramDeclarationAnsi {
236    pub nodes: (
237        ProgramAnsiHeader,
238        Option<TimeunitsDeclaration>,
239        Vec<NonPortProgramItem>,
240        Keyword,
241        Option<(Symbol, ProgramIdentifier)>,
242    ),
243}
244
245#[derive(Clone, Debug, PartialEq, Node)]
246pub struct ProgramDeclarationWildcard {
247    pub nodes: (
248        Vec<AttributeInstance>,
249        Keyword,
250        ProgramIdentifier,
251        Paren<Symbol>,
252        Symbol,
253        Option<TimeunitsDeclaration>,
254        Vec<ProgramItem>,
255        Keyword,
256        Option<(Symbol, ProgramIdentifier)>,
257    ),
258}
259
260#[derive(Clone, Debug, PartialEq, Node)]
261pub struct ProgramDeclarationExternNonansi {
262    pub nodes: (Keyword, ProgramNonansiHeader),
263}
264
265#[derive(Clone, Debug, PartialEq, Node)]
266pub struct ProgramDeclarationExternAnsi {
267    pub nodes: (Keyword, ProgramAnsiHeader),
268}
269
270#[derive(Clone, Debug, PartialEq, Node)]
271pub struct ProgramNonansiHeader {
272    pub nodes: (
273        Vec<AttributeInstance>,
274        Keyword,
275        Option<Lifetime>,
276        ProgramIdentifier,
277        Vec<PackageImportDeclaration>,
278        Option<ParameterPortList>,
279        ListOfPorts,
280        Symbol,
281    ),
282}
283
284#[derive(Clone, Debug, PartialEq, Node)]
285pub struct ProgramAnsiHeader {
286    pub nodes: (
287        Vec<AttributeInstance>,
288        Keyword,
289        Option<Lifetime>,
290        ProgramIdentifier,
291        Vec<PackageImportDeclaration>,
292        Option<ParameterPortList>,
293        Option<ListOfPortDeclarations>,
294        Symbol,
295    ),
296}
297
298#[derive(Clone, Debug, PartialEq, Node)]
299pub struct CheckerDeclaration {
300    pub nodes: (
301        Keyword,
302        CheckerIdentifier,
303        Option<Paren<Option<CheckerPortList>>>,
304        Symbol,
305        Vec<(Vec<AttributeInstance>, CheckerOrGenerateItem)>,
306        Keyword,
307        Option<(Symbol, CheckerIdentifier)>,
308    ),
309}
310
311#[derive(Clone, Debug, PartialEq, Node)]
312pub struct ClassDeclaration {
313    pub nodes: (
314        Option<Virtual>,
315        Keyword,
316        Option<Lifetime>,
317        ClassIdentifier,
318        Option<ParameterPortList>,
319        Option<(Keyword, ClassType, Option<Paren<ListOfArguments>>)>,
320        Option<(Keyword, List<Symbol, InterfaceClassType>)>,
321        Symbol,
322        Vec<ClassItem>,
323        Keyword,
324        Option<(Symbol, ClassIdentifier)>,
325    ),
326}
327
328#[derive(Clone, Debug, PartialEq, Node)]
329pub struct Virtual {
330    pub nodes: (Keyword,),
331}
332
333#[derive(Clone, Debug, PartialEq, Node)]
334pub struct InterfaceClassType {
335    pub nodes: (PsClassIdentifier, Option<ParameterValueAssignment>),
336}
337
338#[derive(Clone, Debug, PartialEq, Node)]
339pub struct InterfaceClassDeclaration {
340    pub nodes: (
341        Keyword,
342        Keyword,
343        ClassIdentifier,
344        Option<ParameterPortList>,
345        Option<(Keyword, List<Symbol, InterfaceClassType>)>,
346        Symbol,
347        Vec<InterfaceClassItem>,
348        Keyword,
349        Option<(Symbol, ClassIdentifier)>,
350    ),
351}
352
353#[derive(Clone, Debug, PartialEq, Node)]
354pub enum InterfaceClassItem {
355    TypeDeclaration(Box<TypeDeclaration>),
356    Method(Box<InterfaceClassItemMethod>),
357    LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>),
358    ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>),
359    Null(Box<Symbol>),
360}
361
362#[derive(Clone, Debug, PartialEq, Node)]
363pub struct InterfaceClassItemMethod {
364    pub nodes: (Vec<AttributeInstance>, InterfaceClassMethod),
365}
366
367#[derive(Clone, Debug, PartialEq, Node)]
368pub struct InterfaceClassMethod {
369    pub nodes: (Keyword, Keyword, MethodPrototype, Symbol),
370}
371
372#[derive(Clone, Debug, PartialEq, Node)]
373pub struct PackageDeclaration {
374    pub nodes: (
375        Vec<AttributeInstance>,
376        Keyword,
377        Option<Lifetime>,
378        PackageIdentifier,
379        Symbol,
380        Option<TimeunitsDeclaration>,
381        Vec<(Vec<AttributeInstance>, PackageItem)>,
382        Keyword,
383        Option<(Symbol, PackageIdentifier)>,
384    ),
385}
386
387#[derive(Clone, Debug, PartialEq, Node)]
388pub enum TimeunitsDeclaration {
389    Timeunit(Box<TimeunitsDeclarationTimeunit>),
390    Timeprecision(Box<TimeunitsDeclarationTimeprecision>),
391    TimeunitTimeprecision(Box<TimeunitsDeclarationTimeunitTimeprecision>),
392    TimeprecisionTimeunit(Box<TimeunitsDeclarationTimeprecisionTimeunit>),
393}
394
395#[derive(Clone, Debug, PartialEq, Node)]
396pub struct TimeunitsDeclarationTimeunit {
397    pub nodes: (Keyword, TimeLiteral, Option<(Symbol, TimeLiteral)>, Symbol),
398}
399
400#[derive(Clone, Debug, PartialEq, Node)]
401pub struct TimeunitsDeclarationTimeprecision {
402    pub nodes: (Keyword, TimeLiteral, Symbol),
403}
404
405#[derive(Clone, Debug, PartialEq, Node)]
406pub struct TimeunitsDeclarationTimeunitTimeprecision {
407    pub nodes: (Keyword, TimeLiteral, Symbol, Keyword, TimeLiteral, Symbol),
408}
409
410#[derive(Clone, Debug, PartialEq, Node)]
411pub struct TimeunitsDeclarationTimeprecisionTimeunit {
412    pub nodes: (Keyword, TimeLiteral, Symbol, Keyword, TimeLiteral, Symbol),
413}