1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
4pub enum UnaryOperator {
5 Not,
7}
8
9impl UnaryOperator {
10 pub fn name(self) -> &'static str {
11 match self {
12 UnaryOperator::Not => "!",
13 }
14 }
15}
16
17#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
18pub enum BinaryOperator {
19 Add,
21 Sub,
23 Div,
25 Mul,
27 Rem,
29 And,
31 Or,
33 Xor,
35
36 Equal,
38 NotEqual,
40 Less,
42 LessOrEqual,
44 Greater,
46 GreaterOrEqual,
48}
49
50impl BinaryOperator {
51 pub fn name(self) -> &'static str {
52 match self {
53 BinaryOperator::Add => "+",
54 BinaryOperator::Sub => "-",
55 BinaryOperator::Mul => "*",
56 BinaryOperator::Div => "/",
57 BinaryOperator::Rem => "%",
58 BinaryOperator::And => "&",
59 BinaryOperator::Or => "|",
60 BinaryOperator::Xor => "^",
61
62 BinaryOperator::Equal => "==",
63 BinaryOperator::NotEqual => "!=",
64 BinaryOperator::Greater => ">",
65 BinaryOperator::GreaterOrEqual => ">=",
66 BinaryOperator::Less => "<",
67 BinaryOperator::LessOrEqual => "<=",
68 }
69 }
70}
71
72#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
73pub enum TernaryOperator {
74 Conditional,
76}
77
78impl TernaryOperator {
79 pub fn first_name(self) -> &'static str {
80 match self {
81 TernaryOperator::Conditional => "?",
82 }
83 }
84
85 pub fn second_name(self) -> &'static str {
86 match self {
87 TernaryOperator::Conditional => ":",
88 }
89 }
90}