sv_parser_syntaxtree/behavioral_statements/
looping_statements.rs1use crate::*;
2
3#[derive(Clone, Debug, PartialEq, Node)]
6pub enum LoopStatement {
7 Forever(Box<LoopStatementForever>),
8 Repeat(Box<LoopStatementRepeat>),
9 While(Box<LoopStatementWhile>),
10 For(Box<LoopStatementFor>),
11 DoWhile(Box<LoopStatementDoWhile>),
12 Foreach(Box<LoopStatementForeach>),
13}
14
15#[derive(Clone, Debug, PartialEq, Node)]
16pub struct LoopStatementForever {
17 pub nodes: (Keyword, StatementOrNull),
18}
19
20#[derive(Clone, Debug, PartialEq, Node)]
21pub struct LoopStatementRepeat {
22 pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
23}
24
25#[derive(Clone, Debug, PartialEq, Node)]
26pub struct LoopStatementWhile {
27 pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
28}
29
30#[derive(Clone, Debug, PartialEq, Node)]
31pub struct LoopStatementFor {
32 pub nodes: (
33 Keyword,
34 Paren<(
35 Option<ForInitialization>,
36 Symbol,
37 Option<Expression>,
38 Symbol,
39 Option<ForStep>,
40 )>,
41 StatementOrNull,
42 ),
43}
44
45#[derive(Clone, Debug, PartialEq, Node)]
46pub struct LoopStatementDoWhile {
47 pub nodes: (Keyword, StatementOrNull, Keyword, Paren<Expression>, Symbol),
48}
49
50#[derive(Clone, Debug, PartialEq, Node)]
51pub struct LoopStatementForeach {
52 pub nodes: (
53 Keyword,
54 Paren<(PsOrHierarchicalArrayIdentifier, Bracket<LoopVariables>)>,
55 Statement,
56 ),
57}
58
59#[derive(Clone, Debug, PartialEq, Node)]
60pub enum ForInitialization {
61 ListOfVariableAssignments(Box<ListOfVariableAssignments>),
62 Declaration(Box<ForInitializationDeclaration>),
63}
64
65#[derive(Clone, Debug, PartialEq, Node)]
66pub struct ForInitializationDeclaration {
67 pub nodes: (List<Symbol, ForVariableDeclaration>,),
68}
69
70#[derive(Clone, Debug, PartialEq, Node)]
71pub struct ForVariableDeclaration {
72 pub nodes: (
73 Option<Var>,
74 DataType,
75 List<Symbol, (VariableIdentifier, Symbol, Expression)>,
76 ),
77}
78
79#[derive(Clone, Debug, PartialEq, Node)]
80pub struct Var {
81 pub nodes: (Keyword,),
82}
83
84#[derive(Clone, Debug, PartialEq, Node)]
85pub struct ForStep {
86 pub nodes: (List<Symbol, ForStepAssignment>,),
87}
88
89#[derive(Clone, Debug, PartialEq, Node)]
90pub enum ForStepAssignment {
91 OperatorAssignment(Box<OperatorAssignment>),
92 IncOrDecExpression(Box<IncOrDecExpression>),
93 FunctionSubroutineCall(Box<FunctionSubroutineCall>),
94}
95
96#[derive(Clone, Debug, PartialEq, Node)]
97pub struct LoopVariables {
98 pub nodes: (List<Symbol, Option<IndexVariableIdentifier>>,),
99}