Skip to main content

limbo_sqlite3_parser/parser/ast/
operator_traits.rs

1//! # `Operator` - Trait Implementations
2//!
3//! This module contains trait implementations for `Operator`.
4//!
5//! ## Implemented Traits
6//!
7//! - `From`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use crate::dialect::TokenType::*;
12use crate::parser::parse::YYCODETYPE;
13
14use super::types::Operator;
15
16impl From<YYCODETYPE> for Operator {
17    fn from(token_type: YYCODETYPE) -> Self {
18        match token_type {
19            x if x == TK_AND as YYCODETYPE => Self::And,
20            x if x == TK_OR as YYCODETYPE => Self::Or,
21            x if x == TK_LT as YYCODETYPE => Self::Less,
22            x if x == TK_GT as YYCODETYPE => Self::Greater,
23            x if x == TK_GE as YYCODETYPE => Self::GreaterEquals,
24            x if x == TK_LE as YYCODETYPE => Self::LessEquals,
25            x if x == TK_EQ as YYCODETYPE => Self::Equals,
26            x if x == TK_NE as YYCODETYPE => Self::NotEquals,
27            x if x == TK_BITAND as YYCODETYPE => Self::BitwiseAnd,
28            x if x == TK_BITOR as YYCODETYPE => Self::BitwiseOr,
29            x if x == TK_BITNOT as YYCODETYPE => Self::BitwiseNot,
30            x if x == TK_LSHIFT as YYCODETYPE => Self::LeftShift,
31            x if x == TK_RSHIFT as YYCODETYPE => Self::RightShift,
32            x if x == TK_PLUS as YYCODETYPE => Self::Add,
33            x if x == TK_MINUS as YYCODETYPE => Self::Subtract,
34            x if x == TK_STAR as YYCODETYPE => Self::Multiply,
35            x if x == TK_SLASH as YYCODETYPE => Self::Divide,
36            x if x == TK_REM as YYCODETYPE => Self::Modulus,
37            x if x == TK_CONCAT as YYCODETYPE => Self::Concat,
38            x if x == TK_IS as YYCODETYPE => Self::Is,
39            x if x == TK_NOT as YYCODETYPE => Self::IsNot,
40            _ => unreachable!(),
41        }
42    }
43}