#[cfg(not(feature = "std"))]
use alloc::boxed::Box;
use crate::{
ast::{BinaryOperator, Expr},
dialect::Dialect,
keywords::Keyword,
};
#[derive(Debug)]
pub struct MySqlDialect {}
impl Dialect for MySqlDialect {
fn is_identifier_start(&self, ch: char) -> bool {
ch.is_alphabetic()
|| ch == '_'
|| ch == '$'
|| ch == '@'
|| ('\u{0080}'..='\u{ffff}').contains(&ch)
}
fn is_identifier_part(&self, ch: char) -> bool {
self.is_identifier_start(ch) || ch.is_ascii_digit()
}
fn is_delimited_identifier_start(&self, ch: char) -> bool {
ch == '`'
}
fn parse_infix(
&self,
parser: &mut crate::parser::Parser,
expr: &crate::ast::Expr,
_precedence: u8,
) -> Option<Result<crate::ast::Expr, crate::parser::ParserError>> {
if parser.parse_keyword(Keyword::DIV) {
Some(Ok(Expr::BinaryOp {
left: Box::new(expr.clone()),
op: BinaryOperator::MyIntegerDivide,
right: Box::new(parser.parse_expr().unwrap()),
}))
} else {
None
}
}
}