xsd_schema/xpath/ast/
operators.rs1use super::{AstNodeId, SourceSpan};
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
9pub struct OpFlags {
10 pub atomize: bool,
11 pub singleton: bool,
12 pub ordered: bool,
13}
14
15impl OpFlags {
16 pub fn atomized() -> Self {
17 Self {
18 atomize: true,
19 ..Default::default()
20 }
21 }
22 pub fn singleton() -> Self {
23 Self {
24 singleton: true,
25 ..Default::default()
26 }
27 }
28 pub fn ordered() -> Self {
29 Self {
30 ordered: true,
31 ..Default::default()
32 }
33 }
34}
35
36#[derive(Debug, Clone)]
38pub struct RangeNode {
39 pub start: AstNodeId,
41 pub end: AstNodeId,
43 pub span: SourceSpan,
45}
46
47impl RangeNode {
48 pub fn new(start: AstNodeId, end: AstNodeId, span: SourceSpan) -> Self {
49 Self { start, end, span }
50 }
51}
52
53#[derive(Debug, Clone, Copy, PartialEq, Eq)]
55pub enum UnaryOpKind {
56 Negate,
58 Identity,
60}
61
62#[derive(Debug, Clone)]
64pub struct UnaryOpNode {
65 pub kind: UnaryOpKind,
67 pub operand: AstNodeId,
69 pub span: SourceSpan,
71}
72
73impl UnaryOpNode {
74 pub fn new(kind: UnaryOpKind, operand: AstNodeId, span: SourceSpan) -> Self {
75 Self {
76 kind,
77 operand,
78 span,
79 }
80 }
81}
82
83#[derive(Debug, Clone, Copy, PartialEq, Eq)]
85pub enum BinaryOpKind {
86 Or,
89 And,
91
92 GeneralEq,
95 GeneralNe,
97 GeneralLt,
99 GeneralLe,
101 GeneralGt,
103 GeneralGe,
105
106 ValueEq,
109 ValueNe,
111 ValueLt,
113 ValueLe,
115 ValueGt,
117 ValueGe,
119
120 Is,
123 Before,
125 After,
127
128 Add,
131 Sub,
133 Mul,
135 Div,
137 IDiv,
139 Mod,
141
142 Union,
145 Intersect,
147 Except,
149}
150
151#[derive(Debug, Clone)]
153pub struct BinaryOpNode {
154 pub kind: BinaryOpKind,
156 pub left: AstNodeId,
158 pub right: AstNodeId,
160 pub span: SourceSpan,
162 pub flags: OpFlags,
164}
165
166impl BinaryOpNode {
167 pub fn new(kind: BinaryOpKind, left: AstNodeId, right: AstNodeId, span: SourceSpan) -> Self {
168 Self {
169 kind,
170 left,
171 right,
172 span,
173 flags: OpFlags::default(),
174 }
175 }
176}