pub fn parse_infix(
        &mut self,
        expr: ASTNode,
        precedence: u8,
    ) -> Result<Option<ASTNode>, ParserError> {
        debug!("parsing infix");
        match self.next_token() {
            Some(tok) => match tok {
                Token::Keyword(ref k) => {
                    if k == "IS" {
                        if self.parse_keywords(vec!["NULL"]) {
                            Ok(Some(ASTNode::SQLIsNull(Box::new(expr))))
                        } else if self.parse_keywords(vec!["NOT", "NULL"]) {
                            Ok(Some(ASTNode::SQLIsNotNull(Box::new(expr))))
                        } else {
                            parser_err!("Invalid tokens after IS")
                        }
                    } else {
                        Ok(Some(ASTNode::SQLBinaryExpr {
                            left: Box::new(expr),
                            op: self.to_sql_operator(&tok)?,
                            right: Box::new(self.parse_expr(precedence)?),
                        }))
                    }
                }
                Token::Eq
                | Token::Neq
                | Token::Gt
                | Token::GtEq
                | Token::Lt
                | Token::LtEq
                | Token::Plus
                | Token::Minus
                | Token::Mult
                | Token::Mod
                | Token::Div => Ok(Some(ASTNode::SQLBinaryExpr {
                    left: Box::new(expr),
                    op: self.to_sql_operator(&tok)?,
                    right: Box::new(self.parse_expr(precedence)?),
                })),
                Token::DoubleColon => {
                    let pg_cast = self.parse_pg_cast(expr)?;
                    Ok(Some(pg_cast))
                }
                _ => parser_err!(format!("No infix parser for token {:?}", tok)),
            },
            None => Ok(None),
        }
    }
/// Parse an expression infix (typically an operator)
Parse an expression infix (typically an operator)
Parse an expression infix ( typically an operator )
pub fn parse_infix(
        &mut self,
        expr: ASTNode,
        precedence: u8,
    ) -> Result<Option<ASTNode>, ParserError> {
        debug!("parsing infix");
        match self.next_token() {
            Some(tok) => match tok {
                Token::Keyword(ref k) => {
                    if k == "IS" {
                        if self.parse_keywords(vec!["NULL"]) {
                            Ok(Some(ASTNode::SQLIsNull(Box::new(expr))))
                        } else if self.parse_keywords(vec!["NOT", "NULL"]) {
                            Ok(Some(ASTNode::SQLIsNotNull(Box::new(expr))))
                        } else {
                            parser_err!("Invalid tokens after IS")
                        }
                    } else {
                        Ok(Some(ASTNode::SQLBinaryExpr {
                            left: Box::new(expr),
                            op: self.to_sql_operator(&tok)?,
                            right: Box::new(self.parse_expr(precedence)?),
                        }))
                    }
                }
                Token::Eq
                | Token::Neq
                | Token::Gt
                | Token::GtEq
                | Token::Lt
                | Token::LtEq
                | Token::Plus
                | Token::Minus
                | Token::Mult
                | Token::Mod
                | Token::Div => Ok(Some(ASTNode::SQLBinaryExpr {
                    left: Box::new(expr),
                    op: self.to_sql_operator(&tok)?,
                    right: Box::new(self.parse_expr(precedence)?),
                })),
                Token::DoubleColon => {
                    let pg_cast = self.parse_pg_cast(expr)?;
                    Ok(Some(pg_cast))
                }
                _ => parser_err!(format!("No infix parser for token {:?}", tok)),
            },
            None => Ok(None),
        }
    }
pub fn parse_infix ( & mut self , expr : ASTNode , precedence : u8 , ) -> Result < Option < ASTNode > , ParserError > { debug ! ( " " ) ; match self . next_token ( ) { Some ( tok ) => match tok { Token :: Keyword ( ref k ) => { if k == " " { if self . parse_keywords ( vec ! [ " " ] ) { Ok ( Some ( ASTNode :: SQLIsNull ( Box :: new ( expr ) ) ) ) } else if self . parse_keywords ( vec ! [ " " " " ] ) { Ok ( Some ( ASTNode :: SQLIsNotNull ( Box :: new ( expr ) ) ) ) } else { parser_err ! ( " " ) } } else { Ok ( Some ( ASTNode :: SQLBinaryExpr { left : Box :: new ( expr ) , op : self . to_sql_operator ( & tok ) ? , right : Box :: new ( self . parse_expr ( precedence ) ? ) , } ) ) } } Token :: Eq | Token :: Neq | Token :: Gt | Token :: GtEq | Token :: Lt | Token :: LtEq | Token :: Plus | Token :: Minus | Token :: Mult | Token :: Mod | Token :: Div => Ok ( Some ( ASTNode :: SQLBinaryExpr { left : Box :: new ( expr ) , op : self . to_sql_operator ( & tok ) ? , right : Box :: new ( self . parse_expr ( precedence ) ? ) , } ) ) , Token :: DoubleColon => { let pg_cast = self . parse_pg_cast ( expr ) ? ; Ok ( Some ( pg_cast ) ) } _ => parser_err ! ( format ( " " tok ) ) , } , None => Ok ( None ) , } }
Parse an expression infix (typically an operator)
Parse an expression infix ( typically an operator )
&mut self
expr
ASTNode
precedence
u8
&mut self
expr
ASTNode
precedence
u8