xsd_schema/xpath/ast/
control_flow.rs1use super::{AstNodeId, SourceSpan};
6
7#[derive(Debug, Clone)]
9pub struct IfNode {
10 pub test: AstNodeId,
12 pub then_branch: AstNodeId,
14 pub else_branch: AstNodeId,
16 pub span: SourceSpan,
18}
19
20impl IfNode {
21 pub fn new(
22 test: AstNodeId,
23 then_branch: AstNodeId,
24 else_branch: AstNodeId,
25 span: SourceSpan,
26 ) -> Self {
27 Self {
28 test,
29 then_branch,
30 else_branch,
31 span,
32 }
33 }
34}
35
36#[derive(Debug, Clone)]
38pub struct ForBinding {
39 pub prefix: String,
41 pub local_name: String,
43 pub in_expr: AstNodeId,
45 pub slot: Option<u32>,
47 pub span: SourceSpan,
49}
50
51impl ForBinding {
52 pub fn new(prefix: String, local_name: String, in_expr: AstNodeId, span: SourceSpan) -> Self {
53 Self {
54 prefix,
55 local_name,
56 in_expr,
57 slot: None,
58 span,
59 }
60 }
61}
62
63#[derive(Debug, Clone)]
67pub struct ForNode {
68 pub bindings: Vec<ForBinding>,
70 pub return_expr: AstNodeId,
72 pub span: SourceSpan,
74}
75
76impl ForNode {
77 pub fn new(bindings: Vec<ForBinding>, return_expr: AstNodeId, span: SourceSpan) -> Self {
78 Self {
79 bindings,
80 return_expr,
81 span,
82 }
83 }
84}
85
86#[derive(Debug, Clone, Copy, PartialEq, Eq)]
88pub enum QuantifierKind {
89 Some,
91 Every,
93}
94
95#[derive(Debug, Clone)]
97pub struct QuantifiedNode {
98 pub kind: QuantifierKind,
100 pub bindings: Vec<ForBinding>,
102 pub satisfies: AstNodeId,
104 pub span: SourceSpan,
106}
107
108impl QuantifiedNode {
109 pub fn new(
110 kind: QuantifierKind,
111 bindings: Vec<ForBinding>,
112 satisfies: AstNodeId,
113 span: SourceSpan,
114 ) -> Self {
115 Self {
116 kind,
117 bindings,
118 satisfies,
119 span,
120 }
121 }
122}