1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6pub enum BinaryOperator {
7 Equal,
9 NotEqual,
11 StrictEqual,
13 StrictNotEqual,
15 LessThan,
17 LessThanOrEqual,
19 GreaterThan,
21 GreaterThanOrEqual,
23 LeftShift,
25 RightShift,
27 UnsignedRightShift,
29 Add,
31 Subtract,
33 Multiply,
35 Divide,
37 Remainder,
39 Exponentiation,
41 BitwiseOr,
43 BitwiseXor,
45 BitwiseAnd,
47 In,
49 InstanceOf,
51}
52
53impl std::fmt::Display for BinaryOperator {
54 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55 f.write_str(match self {
56 Self::Equal => "==",
57 Self::NotEqual => "!=",
58 Self::StrictEqual => "===",
59 Self::StrictNotEqual => "!==",
60 Self::LessThan => "<",
61 Self::LessThanOrEqual => "<=",
62 Self::GreaterThan => ">",
63 Self::GreaterThanOrEqual => ">=",
64 Self::LeftShift => "<<",
65 Self::RightShift => ">>",
66 Self::UnsignedRightShift => ">>>",
67 Self::Add => "+",
68 Self::Subtract => "-",
69 Self::Multiply => "*",
70 Self::Divide => "/",
71 Self::Remainder => "%",
72 Self::Exponentiation => "**",
73 Self::BitwiseOr => "|",
74 Self::BitwiseXor => "^",
75 Self::BitwiseAnd => "&",
76 Self::In => "in",
77 Self::InstanceOf => "instanceof",
78 })
79 }
80}
81
82#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
84pub enum LogicalOperator {
85 And,
87 Or,
89 NullishCoalescing,
91}
92
93impl std::fmt::Display for LogicalOperator {
94 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
95 f.write_str(match self {
96 Self::And => "&&",
97 Self::Or => "||",
98 Self::NullishCoalescing => "??",
99 })
100 }
101}
102
103#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
105pub enum UnaryOperator {
106 Minus,
108 Plus,
110 LogicalNot,
112 BitwiseNot,
114 TypeOf,
116 Void,
118 Delete,
120}
121
122impl std::fmt::Display for UnaryOperator {
123 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
124 f.write_str(match self {
125 Self::Minus => "-",
126 Self::Plus => "+",
127 Self::LogicalNot => "!",
128 Self::BitwiseNot => "~",
129 Self::TypeOf => "typeof",
130 Self::Void => "void",
131 Self::Delete => "delete",
132 })
133 }
134}
135
136#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
141pub enum UpdateOperator {
142 Increment,
144 Decrement,
146}
147
148impl std::fmt::Display for UpdateOperator {
149 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
150 f.write_str(match self {
151 Self::Increment => "++",
152 Self::Decrement => "--",
153 })
154 }
155}
156
157#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
160pub enum AssignmentOperator {
161 Assign,
163 AddAssign,
165 SubtractAssign,
167 MultiplyAssign,
169 DivideAssign,
171 RemainderAssign,
173 ExponentiationAssign,
175 LeftShiftAssign,
177 RightShiftAssign,
179 UnsignedRightShiftAssign,
181 BitwiseOrAssign,
183 BitwiseXorAssign,
185 BitwiseAndAssign,
187 LogicalOrAssign,
189 LogicalAndAssign,
191 NullishCoalescingAssign,
193}
194
195impl std::fmt::Display for AssignmentOperator {
196 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
197 f.write_str(match self {
198 Self::Assign => "=",
199 Self::AddAssign => "+=",
200 Self::SubtractAssign => "-=",
201 Self::MultiplyAssign => "*=",
202 Self::DivideAssign => "/=",
203 Self::RemainderAssign => "%=",
204 Self::ExponentiationAssign => "**=",
205 Self::LeftShiftAssign => "<<=",
206 Self::RightShiftAssign => ">>=",
207 Self::UnsignedRightShiftAssign => ">>>=",
208 Self::BitwiseOrAssign => "|=",
209 Self::BitwiseXorAssign => "^=",
210 Self::BitwiseAndAssign => "&=",
211 Self::LogicalOrAssign => "||=",
212 Self::LogicalAndAssign => "&&=",
213 Self::NullishCoalescingAssign => "??=",
214 })
215 }
216}