sv_parser_syntaxtree/source_text/
constraints.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[derive(Clone, Debug, PartialEq, Node)]
6pub struct ConstraintDeclaration {
7    pub nodes: (
8        Option<Static>,
9        Keyword,
10        ConstraintIdentifier,
11        ConstraintBlock,
12    ),
13}
14
15#[derive(Clone, Debug, PartialEq, Node)]
16pub struct Static {
17    pub nodes: (Keyword,),
18}
19
20#[derive(Clone, Debug, PartialEq, Node)]
21pub struct ConstraintBlock {
22    pub nodes: (Brace<Vec<ConstraintBlockItem>>,),
23}
24
25#[derive(Clone, Debug, PartialEq, Node)]
26pub enum ConstraintBlockItem {
27    Solve(Box<ConstraintBlockItemSolve>),
28    ConstraintExpression(Box<ConstraintExpression>),
29}
30
31#[derive(Clone, Debug, PartialEq, Node)]
32pub struct ConstraintBlockItemSolve {
33    pub nodes: (Keyword, SolveBeforeList, Keyword, SolveBeforeList, Symbol),
34}
35
36#[derive(Clone, Debug, PartialEq, Node)]
37pub struct SolveBeforeList {
38    pub nodes: (List<Symbol, ConstraintPrimary>,),
39}
40
41#[derive(Clone, Debug, PartialEq, Node)]
42pub struct ConstraintPrimary {
43    pub nodes: (
44        Option<ImplicitClassHandleOrClassScope>,
45        HierarchicalIdentifier,
46        Select,
47    ),
48}
49
50#[derive(Clone, Debug, PartialEq, Node)]
51pub enum ConstraintExpression {
52    Expression(Box<ConstraintExpressionExpression>),
53    UniquenessConstraint(Box<(UniquenessConstraint, Symbol)>),
54    Arrow(Box<ConstraintExpressionArrow>),
55    If(Box<ConstraintExpressionIf>),
56    Foreach(Box<ConstraintExpressionForeach>),
57    Disable(Box<ConstraintExpressionDisable>),
58}
59
60#[derive(Clone, Debug, PartialEq, Node)]
61pub struct ConstraintExpressionExpression {
62    pub nodes: (Option<Soft>, ExpressionOrDist, Symbol),
63}
64
65#[derive(Clone, Debug, PartialEq, Node)]
66pub struct Soft {
67    pub nodes: (Keyword,),
68}
69
70#[derive(Clone, Debug, PartialEq, Node)]
71pub struct ConstraintExpressionArrow {
72    pub nodes: (Expression, Symbol, ConstraintSet),
73}
74
75#[derive(Clone, Debug, PartialEq, Node)]
76pub struct ConstraintExpressionIf {
77    pub nodes: (
78        Keyword,
79        Paren<Expression>,
80        ConstraintSet,
81        Option<(Keyword, ConstraintSet)>,
82    ),
83}
84
85#[derive(Clone, Debug, PartialEq, Node)]
86pub struct ConstraintExpressionForeach {
87    pub nodes: (
88        Keyword,
89        Paren<(PsOrHierarchicalArrayIdentifier, Bracket<LoopVariables>)>,
90        ConstraintSet,
91    ),
92}
93
94#[derive(Clone, Debug, PartialEq, Node)]
95pub struct ConstraintExpressionDisable {
96    pub nodes: (Keyword, Keyword, ConstraintPrimary, Symbol),
97}
98
99#[derive(Clone, Debug, PartialEq, Node)]
100pub struct UniquenessConstraint {
101    pub nodes: (Keyword, Brace<OpenRangeList>),
102}
103
104#[derive(Clone, Debug, PartialEq, Node)]
105pub enum ConstraintSet {
106    ConstraintExpression(Box<ConstraintExpression>),
107    Brace(Box<ConstraintSetBrace>),
108}
109
110#[derive(Clone, Debug, PartialEq, Node)]
111pub struct ConstraintSetBrace {
112    pub nodes: (Brace<Vec<ConstraintExpression>>,),
113}
114
115#[derive(Clone, Debug, PartialEq, Node)]
116pub struct DistList {
117    pub nodes: (List<Symbol, DistItem>,),
118}
119
120#[derive(Clone, Debug, PartialEq, Node)]
121pub struct DistItem {
122    pub nodes: (ValueRange, Option<DistWeight>),
123}
124
125#[derive(Clone, Debug, PartialEq, Node)]
126pub enum DistWeight {
127    Equal(Box<DistWeightEqual>),
128    Divide(Box<DistWeightDivide>),
129}
130
131#[derive(Clone, Debug, PartialEq, Node)]
132pub struct DistWeightEqual {
133    pub nodes: (Symbol, Expression),
134}
135
136#[derive(Clone, Debug, PartialEq, Node)]
137pub struct DistWeightDivide {
138    pub nodes: (Symbol, Expression),
139}
140
141#[derive(Clone, Debug, PartialEq, Node)]
142pub struct ConstraintPrototype {
143    pub nodes: (
144        Option<ConstraintPrototypeQualifier>,
145        Option<Static>,
146        Keyword,
147        ConstraintIdentifier,
148        Symbol,
149    ),
150}
151
152#[derive(Clone, Debug, PartialEq, Node)]
153pub enum ConstraintPrototypeQualifier {
154    Extern(Box<Keyword>),
155    Pure(Box<Keyword>),
156}
157
158#[derive(Clone, Debug, PartialEq, Node)]
159pub struct ExternConstraintDeclaration {
160    pub nodes: (
161        Option<Static>,
162        Keyword,
163        ClassScope,
164        ConstraintIdentifier,
165        ConstraintBlock,
166    ),
167}
168
169#[derive(Clone, Debug, PartialEq, Node)]
170pub struct IdentifierList {
171    pub nodes: (List<Symbol, Identifier>,),
172}