luaur_ast/methods/
parser_parse_binary_op.rs1use crate::records::ast_expr_binary::AstExprBinary_Op as Op;
2use crate::records::lexeme::Lexeme;
3use crate::records::parser::Parser;
4
5impl Parser {
6 #[allow(non_snake_case)]
7 pub(crate) fn parse_binary_op(&self, l: &Lexeme) -> Option<Op> {
8 if l.r#type == crate::records::lexeme::Type('+' as i32) {
9 Some(Op::Add)
10 } else if l.r#type == crate::records::lexeme::Type('-' as i32) {
11 Some(Op::Sub)
12 } else if l.r#type == crate::records::lexeme::Type('*' as i32) {
13 Some(Op::Mul)
14 } else if l.r#type == crate::records::lexeme::Type('/' as i32) {
15 Some(Op::Div)
16 } else if l.r#type == crate::records::lexeme::Type::FloorDiv {
17 Some(Op::FloorDiv)
18 } else if l.r#type == crate::records::lexeme::Type('%' as i32) {
19 Some(Op::Mod)
20 } else if l.r#type == crate::records::lexeme::Type('^' as i32) {
21 Some(Op::Pow)
22 } else if l.r#type == crate::records::lexeme::Type::Dot2 {
23 Some(Op::Concat)
24 } else if l.r#type == crate::records::lexeme::Type::NotEqual {
25 Some(Op::CompareNe)
26 } else if l.r#type == crate::records::lexeme::Type::Equal {
27 Some(Op::CompareEq)
28 } else if l.r#type == crate::records::lexeme::Type('<' as i32) {
29 Some(Op::CompareLt)
30 } else if l.r#type == crate::records::lexeme::Type::LessEqual {
31 Some(Op::CompareLe)
32 } else if l.r#type == crate::records::lexeme::Type('>' as i32) {
33 Some(Op::CompareGt)
34 } else if l.r#type == crate::records::lexeme::Type::GreaterEqual {
35 Some(Op::CompareGe)
36 } else if l.r#type == crate::records::lexeme::Type::ReservedAnd {
37 Some(Op::And)
38 } else if l.r#type == crate::records::lexeme::Type::ReservedOr {
39 Some(Op::Or)
40 } else {
41 None
42 }
43 }
44}
45
46#[allow(non_snake_case)]
47pub fn parser_parse_binary_op(this: &Parser, l: &Lexeme) -> Option<Op> {
48 this.parse_binary_op(l)
49}