sv_parser_syntaxtree/declarations/
type_declarations.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[derive(Clone, Debug, PartialEq, Node)]
6pub enum DataDeclaration {
7    Variable(Box<DataDeclarationVariable>),
8    TypeDeclaration(Box<TypeDeclaration>),
9    PackageImportDeclaration(Box<PackageImportDeclaration>),
10    NetTypeDeclaration(Box<NetTypeDeclaration>),
11}
12
13#[derive(Clone, Debug, PartialEq, Node)]
14pub struct DataDeclarationVariable {
15    pub nodes: (
16        Option<Const>,
17        Option<Var>,
18        Option<Lifetime>,
19        DataTypeOrImplicit,
20        ListOfVariableDeclAssignments,
21        Symbol,
22    ),
23}
24
25#[derive(Clone, Debug, PartialEq, Node)]
26pub struct Const {
27    pub nodes: (Keyword,),
28}
29
30#[derive(Clone, Debug, PartialEq, Node)]
31pub struct PackageImportDeclaration {
32    pub nodes: (Keyword, List<Symbol, PackageImportItem>, Symbol),
33}
34
35#[derive(Clone, Debug, PartialEq, Node)]
36pub enum PackageImportItem {
37    Identifier(Box<PackageImportItemIdentifier>),
38    Asterisk(Box<PackageImportItemAsterisk>),
39}
40
41#[derive(Clone, Debug, PartialEq, Node)]
42pub struct PackageImportItemIdentifier {
43    pub nodes: (PackageIdentifier, Symbol, Identifier),
44}
45
46#[derive(Clone, Debug, PartialEq, Node)]
47pub struct PackageImportItemAsterisk {
48    pub nodes: (PackageIdentifier, Symbol, Symbol),
49}
50
51#[derive(Clone, Debug, PartialEq, Node)]
52pub enum PackageExportDeclaration {
53    Asterisk(Box<PackageExportDeclarationAsterisk>),
54    Item(Box<PackageExportDeclarationItem>),
55}
56
57#[derive(Clone, Debug, PartialEq, Node)]
58pub struct PackageExportDeclarationAsterisk {
59    pub nodes: (Keyword, Symbol, Symbol),
60}
61
62#[derive(Clone, Debug, PartialEq, Node)]
63pub struct PackageExportDeclarationItem {
64    pub nodes: (Keyword, List<Symbol, PackageImportItem>, Symbol),
65}
66
67#[derive(Clone, Debug, PartialEq, Node)]
68pub struct GenvarDeclaration {
69    pub nodes: (Keyword, ListOfGenvarIdentifiers, Symbol),
70}
71
72#[derive(Clone, Debug, PartialEq, Node)]
73pub enum NetDeclaration {
74    NetType(Box<NetDeclarationNetType>),
75    NetTypeIdentifier(Box<NetDeclarationNetTypeIdentifier>),
76    Interconnect(Box<NetDeclarationInterconnect>),
77}
78
79#[derive(Clone, Debug, PartialEq, Node)]
80pub struct NetDeclarationNetType {
81    pub nodes: (
82        NetType,
83        Option<Strength>,
84        Option<VectorScalar>,
85        DataTypeOrImplicit,
86        Option<Delay3>,
87        ListOfNetDeclAssignments,
88        Symbol,
89    ),
90}
91
92#[derive(Clone, Debug, PartialEq, Node)]
93pub enum Strength {
94    Drive(Box<DriveStrength>),
95    Charge(Box<ChargeStrength>),
96}
97
98#[derive(Clone, Debug, PartialEq, Node)]
99pub enum VectorScalar {
100    Vectored(Box<Keyword>),
101    Scalared(Box<Keyword>),
102}
103
104#[derive(Clone, Debug, PartialEq, Node)]
105pub struct NetDeclarationNetTypeIdentifier {
106    pub nodes: (
107        NetTypeIdentifier,
108        Option<DelayControl>,
109        ListOfNetDeclAssignments,
110        Symbol,
111    ),
112}
113
114#[derive(Clone, Debug, PartialEq, Node)]
115pub struct NetDeclarationInterconnect {
116    pub nodes: (
117        Keyword,
118        ImplicitDataType,
119        Option<(Symbol, DelayValue)>,
120        NetIdentifier,
121        Vec<UnpackedDimension>,
122        Option<(Symbol, NetIdentifier, Vec<UnpackedDimension>)>,
123        Symbol,
124    ),
125}
126
127#[derive(Clone, Debug, PartialEq, Node)]
128pub enum TypeDeclaration {
129    DataType(Box<TypeDeclarationDataType>),
130    Interface(Box<TypeDeclarationInterface>),
131    Reserved(Box<TypeDeclarationReserved>),
132}
133
134#[derive(Clone, Debug, PartialEq, Node)]
135pub struct TypeDeclarationDataType {
136    pub nodes: (
137        Keyword,
138        DataType,
139        TypeIdentifier,
140        Vec<VariableDimension>,
141        Symbol,
142    ),
143}
144
145#[derive(Clone, Debug, PartialEq, Node)]
146pub struct TypeDeclarationInterface {
147    pub nodes: (
148        Keyword,
149        InterfaceInstanceIdentifier,
150        ConstantBitSelect,
151        Symbol,
152        TypeIdentifier,
153        TypeIdentifier,
154        Symbol,
155    ),
156}
157
158#[derive(Clone, Debug, PartialEq, Node)]
159pub struct TypeDeclarationReserved {
160    pub nodes: (
161        Keyword,
162        Option<TypeDeclarationKeyword>,
163        TypeIdentifier,
164        Symbol,
165    ),
166}
167
168#[derive(Clone, Debug, PartialEq, Node)]
169pub enum TypeDeclarationKeyword {
170    Enum(Box<Keyword>),
171    Struct(Box<Keyword>),
172    Union(Box<Keyword>),
173    Class(Box<Keyword>),
174    InterfaceClass(Box<(Keyword, Keyword)>),
175}
176
177#[derive(Clone, Debug, PartialEq, Node)]
178pub enum NetTypeDeclaration {
179    DataType(Box<NetTypeDeclarationDataType>),
180    NetType(Box<NetTypeDeclarationNetType>),
181}
182
183#[derive(Clone, Debug, PartialEq, Node)]
184pub struct NetTypeDeclarationDataType {
185    pub nodes: (
186        Keyword,
187        DataType,
188        NetTypeIdentifier,
189        Option<(Keyword, Option<PackageScopeOrClassScope>, TfIdentifier)>,
190        Symbol,
191    ),
192}
193
194#[derive(Clone, Debug, PartialEq, Node)]
195pub struct NetTypeDeclarationNetType {
196    pub nodes: (
197        Keyword,
198        Option<PackageScopeOrClassScope>,
199        NetTypeIdentifier,
200        NetTypeIdentifier,
201        Symbol,
202    ),
203}
204
205#[derive(Clone, Debug, PartialEq, Node)]
206pub enum Lifetime {
207    Static(Box<Keyword>),
208    Automatic(Box<Keyword>),
209}