Skip to main content

rexlang_parser/
op.rs

1use std::fmt::{self, Display, Formatter};
2
3#[derive(Clone, Debug, Eq, Hash, PartialEq)]
4pub enum Operator {
5    Add,
6    And,
7    Concat,
8    Div,
9    Eq,
10    Ne,
11    Ge,
12    Gt,
13    Le,
14    Lt,
15    Mod,
16    Mul,
17    Or,
18    Sub,
19}
20
21impl Display for Operator {
22    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
23        let s = match self {
24            Operator::Add => "+".to_string(),
25            Operator::And => "&&".to_string(),
26            Operator::Concat => "++".to_string(),
27            Operator::Div => "/".to_string(),
28            Operator::Eq => "==".to_string(),
29            Operator::Ne => "!=".to_string(),
30            Operator::Ge => ">=".to_string(),
31            Operator::Gt => ">".to_string(),
32            Operator::Le => "<=".to_string(),
33            Operator::Lt => "<".to_string(),
34            Operator::Mod => "%".to_string(),
35            Operator::Mul => "*".to_string(),
36            Operator::Or => "||".to_string(),
37            Operator::Sub => "-".to_string(),
38        };
39        write!(f, "{}", s)
40    }
41}