sv_parser_syntaxtree/general/
compiler_directives.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[derive(Clone, Debug, PartialEq, Node)]
6pub enum CompilerDirective {
7    ResetallCompilerDirective(Box<ResetallCompilerDirective>),
8    IncludeCompilerDirective(Box<IncludeCompilerDirective>),
9    TextMacroDefinition(Box<TextMacroDefinition>),
10    TextMacroUsage(Box<TextMacroUsage>),
11    UndefineCompilerDirective(Box<UndefineCompilerDirective>),
12    UndefineallCompilerDirective(Box<UndefineallCompilerDirective>),
13    ConditionalCompilerDirective(Box<ConditionalCompilerDirective>),
14    TimescaleCompilerDirective(Box<TimescaleCompilerDirective>),
15    DefaultNettypeCompilerDirective(Box<DefaultNettypeCompilerDirective>),
16    UnconnectedDriveCompilerDirective(Box<UnconnectedDriveCompilerDirective>),
17    NounconnectedDriveCompilerDirective(Box<NounconnectedDriveCompilerDirective>),
18    CelldefineDriveCompilerDirective(Box<CelldefineDriveCompilerDirective>),
19    EndcelldefineDriveCompilerDirective(Box<EndcelldefineDriveCompilerDirective>),
20    Pragma(Box<Pragma>),
21    LineCompilerDirective(Box<LineCompilerDirective>),
22    PositionCompilerDirective(Box<PositionCompilerDirective>),
23    KeywordsDirective(Box<KeywordsDirective>),
24    EndkeywordsDirective(Box<EndkeywordsDirective>),
25}
26
27#[derive(Clone, Debug, PartialEq, Node)]
28pub struct ResetallCompilerDirective {
29    pub nodes: (Symbol, Keyword),
30}
31
32#[derive(Clone, Debug, PartialEq, Node)]
33pub enum IncludeCompilerDirective {
34    DoubleQuote(Box<IncludeCompilerDirectiveDoubleQuote>),
35    AngleBracket(Box<IncludeCompilerDirectiveAngleBracket>),
36    TextMacroUsage(Box<IncludeCompilerDirectiveTextMacroUsage>),
37}
38
39#[derive(Clone, Debug, PartialEq, Node)]
40pub struct IncludeCompilerDirectiveDoubleQuote {
41    pub nodes: (Symbol, Keyword, StringLiteral),
42}
43
44#[derive(Clone, Debug, PartialEq, Node)]
45pub struct IncludeCompilerDirectiveAngleBracket {
46    pub nodes: (Symbol, Keyword, AngleBracketLiteral),
47}
48
49#[derive(Clone, Debug, PartialEq, Node)]
50pub struct IncludeCompilerDirectiveTextMacroUsage {
51    pub nodes: (Symbol, Keyword, TextMacroUsage),
52}
53
54#[derive(Clone, Debug, PartialEq, Node)]
55pub struct AngleBracketLiteral {
56    pub nodes: (Locate, Vec<WhiteSpace>),
57}
58
59#[derive(Clone, Debug, PartialEq, Node)]
60pub struct TextMacroDefinition {
61    pub nodes: (Symbol, Keyword, TextMacroName, Option<MacroText>),
62}
63
64#[derive(Clone, Debug, PartialEq, Node)]
65pub struct TextMacroName {
66    pub nodes: (TextMacroIdentifier, Option<Paren<ListOfFormalArguments>>),
67}
68
69#[derive(Clone, Debug, PartialEq, Node)]
70pub struct ListOfFormalArguments {
71    pub nodes: (List<Symbol, FormalArgument>,),
72}
73
74#[derive(Clone, Debug, PartialEq, Node)]
75pub struct FormalArgument {
76    pub nodes: (SimpleIdentifier, Option<(Symbol, DefaultText)>),
77}
78
79#[derive(Clone, Debug, PartialEq, Node)]
80pub struct TextMacroIdentifier {
81    pub nodes: (Identifier,),
82}
83
84#[derive(Clone, Debug, PartialEq, Node)]
85pub struct MacroText {
86    pub nodes: (Locate,),
87}
88
89#[derive(Clone, Debug, PartialEq, Node)]
90pub struct DefaultText {
91    pub nodes: (Locate,),
92}
93
94#[derive(Clone, Debug, PartialEq, Node)]
95pub struct TextMacroUsage {
96    pub nodes: (
97        Symbol,
98        TextMacroIdentifier,
99        Option<Paren<ListOfActualArguments>>,
100    ),
101}
102
103#[derive(Clone, Debug, PartialEq, Node)]
104pub struct ListOfActualArguments {
105    pub nodes: (List<Symbol, Option<ActualArgument>>,),
106}
107
108#[derive(Clone, Debug, PartialEq, Node)]
109pub struct ActualArgument {
110    pub nodes: (Locate,),
111}
112
113#[derive(Clone, Debug, PartialEq, Node)]
114pub struct UndefineCompilerDirective {
115    pub nodes: (Symbol, Keyword, TextMacroIdentifier),
116}
117
118#[derive(Clone, Debug, PartialEq, Node)]
119pub struct UndefineallCompilerDirective {
120    pub nodes: (Symbol, Keyword),
121}
122
123#[derive(Clone, Debug, PartialEq, Node)]
124pub enum ConditionalCompilerDirective {
125    IfdefDirective(Box<IfdefDirective>),
126    IfndefDirective(Box<IfndefDirective>),
127}
128
129#[derive(Clone, Debug, PartialEq, Node)]
130pub struct IfdefDirective {
131    pub nodes: (
132        Symbol,
133        Keyword,
134        TextMacroIdentifier,
135        IfdefGroupOfLines,
136        Vec<(Symbol, Keyword, TextMacroIdentifier, ElsifGroupOfLines)>,
137        Option<(Symbol, Keyword, ElseGroupOfLines)>,
138        Symbol,
139        Keyword,
140    ),
141}
142
143#[derive(Clone, Debug, PartialEq, Node)]
144pub struct IfndefDirective {
145    pub nodes: (
146        Symbol,
147        Keyword,
148        TextMacroIdentifier,
149        IfndefGroupOfLines,
150        Vec<(Symbol, Keyword, TextMacroIdentifier, ElsifGroupOfLines)>,
151        Option<(Symbol, Keyword, ElseGroupOfLines)>,
152        Symbol,
153        Keyword,
154    ),
155}
156
157#[derive(Clone, Debug, PartialEq, Node)]
158pub struct IfdefGroupOfLines {
159    pub nodes: (Vec<SourceDescription>,),
160}
161
162#[derive(Clone, Debug, PartialEq, Node)]
163pub struct IfndefGroupOfLines {
164    pub nodes: (Vec<SourceDescription>,),
165}
166
167#[derive(Clone, Debug, PartialEq, Node)]
168pub struct ElsifGroupOfLines {
169    pub nodes: (Vec<SourceDescription>,),
170}
171
172#[derive(Clone, Debug, PartialEq, Node)]
173pub struct ElseGroupOfLines {
174    pub nodes: (Vec<SourceDescription>,),
175}
176
177#[derive(Clone, Debug, PartialEq, Node)]
178pub enum SourceDescription {
179    Comment(Box<Comment>),
180    StringLiteral(Box<StringLiteral>),
181    NotDirective(Box<SourceDescriptionNotDirective>),
182    CompilerDirective(Box<CompilerDirective>),
183    EscapedIdentifier(Box<EscapedIdentifier>),
184}
185
186#[derive(Clone, Debug, PartialEq, Node)]
187pub struct SourceDescriptionNotDirective {
188    pub nodes: (Locate,),
189}
190
191#[derive(Clone, Debug, PartialEq, Node)]
192pub struct TimescaleCompilerDirective {
193    pub nodes: (
194        Symbol,
195        Keyword,
196        UnsignedNumber,
197        TimeUnit,
198        Symbol,
199        UnsignedNumber,
200        TimeUnit,
201    ),
202}
203
204#[derive(Clone, Debug, PartialEq, Node)]
205pub struct DefaultNettypeCompilerDirective {
206    pub nodes: (Symbol, Keyword, DefaultNettypeValue),
207}
208
209#[derive(Clone, Debug, PartialEq, Node)]
210pub struct DefaultNettypeValue {
211    pub nodes: (Keyword,),
212}
213
214#[derive(Clone, Debug, PartialEq, Node)]
215pub struct UnconnectedDriveCompilerDirective {
216    pub nodes: (Symbol, Keyword, Keyword),
217}
218
219#[derive(Clone, Debug, PartialEq, Node)]
220pub struct NounconnectedDriveCompilerDirective {
221    pub nodes: (Symbol, Keyword),
222}
223
224#[derive(Clone, Debug, PartialEq, Node)]
225pub struct CelldefineDriveCompilerDirective {
226    pub nodes: (Symbol, Keyword),
227}
228
229#[derive(Clone, Debug, PartialEq, Node)]
230pub struct EndcelldefineDriveCompilerDirective {
231    pub nodes: (Symbol, Keyword),
232}
233
234#[derive(Clone, Debug, PartialEq, Node)]
235pub struct Pragma {
236    pub nodes: (
237        Symbol,
238        Keyword,
239        PragmaName,
240        Option<List<Symbol, PragmaExpression>>,
241    ),
242}
243
244#[derive(Clone, Debug, PartialEq, Node)]
245pub struct PragmaName {
246    pub nodes: (SimpleIdentifier,),
247}
248
249#[derive(Clone, Debug, PartialEq, Node)]
250pub enum PragmaExpression {
251    PragmaKeyword(Box<PragmaKeyword>),
252    Assignment(Box<PragmaExpressionAssignment>),
253    PragmaValue(Box<PragmaValue>),
254}
255
256#[derive(Clone, Debug, PartialEq, Node)]
257pub struct PragmaExpressionAssignment {
258    pub nodes: (PragmaKeyword, Symbol, PragmaValue),
259}
260
261#[derive(Clone, Debug, PartialEq, Node)]
262pub enum PragmaValue {
263    Paren(Box<PragmaValueParen>),
264    Number(Box<Number>),
265    StringLiteral(Box<StringLiteral>),
266    Identifier(Box<Identifier>),
267}
268
269#[derive(Clone, Debug, PartialEq, Node)]
270pub struct PragmaValueParen {
271    pub nodes: (Paren<List<Symbol, PragmaExpression>>,),
272}
273
274#[derive(Clone, Debug, PartialEq, Node)]
275pub struct PragmaKeyword {
276    pub nodes: (SimpleIdentifier,),
277}
278
279#[derive(Clone, Debug, PartialEq, Node)]
280pub struct LineCompilerDirective {
281    pub nodes: (Symbol, Keyword, Number, StringLiteral, Level),
282}
283
284#[derive(Clone, Debug, PartialEq, Node)]
285pub struct PositionCompilerDirective {
286    pub nodes: (Symbol, Keyword),
287}
288
289#[derive(Clone, Debug, PartialEq, Node)]
290pub struct Level {
291    pub nodes: (Symbol,),
292}
293
294#[derive(Clone, Debug, PartialEq, Node)]
295pub struct KeywordsDirective {
296    pub nodes: (Symbol, Keyword, Symbol, VersionSpecifier, Symbol),
297}
298
299#[derive(Clone, Debug, PartialEq, Node)]
300pub struct VersionSpecifier {
301    pub nodes: (Keyword,),
302}
303
304#[derive(Clone, Debug, PartialEq, Node)]
305pub struct EndkeywordsDirective {
306    pub nodes: (Symbol, Keyword),
307}