Skip to main content

sv_parser_syntaxtree/expressions/
expressions.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[derive(Clone, Debug, PartialEq, Node)]
6pub enum IncOrDecExpression {
7    Prefix(Box<IncOrDecExpressionPrefix>),
8    Suffix(Box<IncOrDecExpressionSuffix>),
9}
10
11#[derive(Clone, Debug, PartialEq, Node)]
12pub struct IncOrDecExpressionPrefix {
13    pub nodes: (IncOrDecOperator, Vec<AttributeInstance>, VariableLvalue),
14}
15
16#[derive(Clone, Debug, PartialEq, Node)]
17pub struct IncOrDecExpressionSuffix {
18    pub nodes: (VariableLvalue, Vec<AttributeInstance>, IncOrDecOperator),
19}
20
21#[derive(Clone, Debug, PartialEq, Node)]
22pub struct ConditionalExpression {
23    pub nodes: (
24        CondPredicate,
25        Symbol,
26        Vec<AttributeInstance>,
27        Expression,
28        Symbol,
29        Expression,
30    ),
31}
32
33#[derive(Clone, Debug, PartialEq, Node)]
34pub enum ConstantExpression {
35    ConstantPrimary(Box<ConstantPrimary>),
36    Unary(Box<ConstantExpressionUnary>),
37    Binary(Box<ConstantExpressionBinary>),
38    Ternary(Box<ConstantExpressionTernary>),
39    Inside(Box<ConstantInsideExpression>),
40}
41
42#[derive(Clone, Debug, PartialEq, Node)]
43pub struct ConstantExpressionUnary {
44    pub nodes: (UnaryOperator, Vec<AttributeInstance>, ConstantPrimary),
45}
46
47#[derive(Clone, Debug, PartialEq, Node)]
48pub struct ConstantExpressionBinary {
49    pub nodes: (
50        ConstantExpression,
51        BinaryOperator,
52        Vec<AttributeInstance>,
53        ConstantExpression,
54    ),
55}
56
57#[derive(Clone, Debug, PartialEq, Node)]
58pub struct ConstantExpressionTernary {
59    pub nodes: (
60        ConstantExpression,
61        Symbol,
62        Vec<AttributeInstance>,
63        ConstantExpression,
64        Symbol,
65        ConstantExpression,
66    ),
67}
68
69#[derive(Clone, Debug, PartialEq, Node)]
70pub struct ConstantInsideExpression {
71    pub nodes: (ConstantExpression, Keyword, Brace<OpenRangeList>),
72}
73
74#[derive(Clone, Debug, PartialEq, Node)]
75pub enum ConstantMintypmaxExpression {
76    Unary(Box<ConstantExpression>),
77    Ternary(Box<ConstantMintypmaxExpressionTernary>),
78}
79
80#[derive(Clone, Debug, PartialEq, Node)]
81pub struct ConstantMintypmaxExpressionTernary {
82    pub nodes: (
83        ConstantExpression,
84        Symbol,
85        ConstantExpression,
86        Symbol,
87        ConstantExpression,
88    ),
89}
90
91#[derive(Clone, Debug, PartialEq, Node)]
92pub enum ConstantParamExpression {
93    ConstantMintypmaxExpression(Box<ConstantMintypmaxExpression>),
94    DataType(Box<DataType>),
95    Dollar(Box<Symbol>),
96}
97
98#[derive(Clone, Debug, PartialEq, Node)]
99pub enum ParamExpression {
100    MintypmaxExpression(Box<MintypmaxExpression>),
101    DataType(Box<DataType>),
102    Dollar(Box<Symbol>),
103}
104
105#[derive(Clone, Debug, PartialEq, Node)]
106pub enum ConstantRangeExpression {
107    ConstantExpression(Box<ConstantExpression>),
108    ConstantPartSelectRange(Box<ConstantPartSelectRange>),
109}
110
111#[derive(Clone, Debug, PartialEq, Node)]
112pub enum ConstantPartSelectRange {
113    ConstantRange(Box<ConstantRange>),
114    ConstantIndexedRange(Box<ConstantIndexedRange>),
115}
116
117#[derive(Clone, Debug, PartialEq, Node)]
118pub struct ConstantRange {
119    pub nodes: (ConstantExpression, Symbol, ConstantExpression),
120}
121
122#[derive(Clone, Debug, PartialEq, Node)]
123pub struct ConstantIndexedRange {
124    pub nodes: (ConstantExpression, Symbol, ConstantExpression),
125}
126
127#[derive(Clone, Debug, PartialEq, Node)]
128pub enum Expression {
129    Primary(Box<Primary>),
130    Unary(Box<ExpressionUnary>),
131    IncOrDecExpression(Box<IncOrDecExpression>),
132    OperatorAssignment(Box<ExpressionOperatorAssignment>),
133    Binary(Box<ExpressionBinary>),
134    ConditionalExpression(Box<ConditionalExpression>),
135    InsideExpression(Box<InsideExpression>),
136    TaggedUnionExpression(Box<TaggedUnionExpression>),
137}
138
139#[derive(Clone, Debug, PartialEq, Node)]
140pub struct ExpressionUnary {
141    pub nodes: (UnaryOperator, Vec<AttributeInstance>, Primary),
142}
143
144#[derive(Clone, Debug, PartialEq, Node)]
145pub struct ExpressionOperatorAssignment {
146    pub nodes: (Paren<OperatorAssignment>,),
147}
148
149#[derive(Clone, Debug, PartialEq, Node)]
150pub struct ExpressionBinary {
151    pub nodes: (
152        Expression,
153        BinaryOperator,
154        Vec<AttributeInstance>,
155        Expression,
156    ),
157}
158
159#[derive(Clone, Debug, PartialEq, Node)]
160pub struct TaggedUnionExpression {
161    pub nodes: (Keyword, MemberIdentifier, Option<Expression>),
162}
163
164#[derive(Clone, Debug, PartialEq, Node)]
165pub struct InsideExpression {
166    pub nodes: (Expression, Keyword, Brace<OpenRangeList>),
167}
168
169#[derive(Clone, Debug, PartialEq, Node)]
170pub enum ValueRange {
171    Expression(Box<Expression>),
172    Binary(Box<ValueRangeBinary>),
173}
174
175#[derive(Clone, Debug, PartialEq, Node)]
176pub struct ValueRangeBinary {
177    pub nodes: (Bracket<(Expression, Symbol, Expression)>,),
178}
179
180#[derive(Clone, Debug, PartialEq, Node)]
181pub enum MintypmaxExpression {
182    Expression(Box<Expression>),
183    Ternary(Box<MintypmaxExpressionTernary>),
184}
185
186#[derive(Clone, Debug, PartialEq, Node)]
187pub struct MintypmaxExpressionTernary {
188    pub nodes: (Expression, Symbol, Expression, Symbol, Expression),
189}
190
191#[derive(Clone, Debug, PartialEq, Node)]
192pub struct ModulePathConditionalExpression {
193    pub nodes: (
194        ModulePathExpression,
195        Symbol,
196        Vec<AttributeInstance>,
197        ModulePathExpression,
198        Symbol,
199        ModulePathExpression,
200    ),
201}
202
203#[derive(Clone, Debug, PartialEq, Node)]
204pub enum ModulePathExpression {
205    ModulePathPrimary(Box<ModulePathPrimary>),
206    Unary(Box<ModulePathExpressionUnary>),
207    Binary(Box<ModulePathExpressionBinary>),
208    ModulePathConditionalExpression(Box<ModulePathConditionalExpression>),
209}
210
211#[derive(Clone, Debug, PartialEq, Node)]
212pub struct ModulePathExpressionUnary {
213    pub nodes: (
214        UnaryModulePathOperator,
215        Vec<AttributeInstance>,
216        ModulePathPrimary,
217    ),
218}
219
220#[derive(Clone, Debug, PartialEq, Node)]
221pub struct ModulePathExpressionBinary {
222    pub nodes: (
223        ModulePathExpression,
224        BinaryModulePathOperator,
225        Vec<AttributeInstance>,
226        ModulePathExpression,
227    ),
228}
229
230#[derive(Clone, Debug, PartialEq, Node)]
231pub enum ModulePathMintypmaxExpression {
232    ModulePathExpression(Box<ModulePathExpression>),
233    Ternary(Box<ModulePathMintypmaxExpressionTernary>),
234}
235
236#[derive(Clone, Debug, PartialEq, Node)]
237pub struct ModulePathMintypmaxExpressionTernary {
238    pub nodes: (
239        ModulePathExpression,
240        Symbol,
241        ModulePathExpression,
242        Symbol,
243        ModulePathExpression,
244    ),
245}
246
247#[derive(Clone, Debug, PartialEq, Node)]
248pub enum PartSelectRange {
249    ConstantRange(Box<ConstantRange>),
250    IndexedRange(Box<IndexedRange>),
251}
252
253#[derive(Clone, Debug, PartialEq, Node)]
254pub struct IndexedRange {
255    pub nodes: (Expression, Symbol, ConstantExpression),
256}
257
258#[derive(Clone, Debug, PartialEq, Node)]
259pub struct GenvarExpression {
260    pub nodes: (ConstantExpression,),
261}