1#![doc = include_str!("readme.md")]
2use oak_core::{Language, LanguageCategory};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct SqlLanguage {
8 pub case_sensitive: bool,
10 pub quoted_identifiers: bool,
12 pub backtick_identifiers: bool,
14 pub bracket_identifiers: bool,
16}
17
18impl SqlLanguage {
19 pub fn new() -> Self {
21 Self::default()
22 }
23
24 pub fn standard() -> Self {
26 Self::default()
27 }
28
29 pub fn mysql() -> Self {
31 Self { case_sensitive: false, quoted_identifiers: true, backtick_identifiers: true, bracket_identifiers: false }
32 }
33
34 pub fn postgresql() -> Self {
36 Self { case_sensitive: false, quoted_identifiers: true, backtick_identifiers: false, bracket_identifiers: false }
37 }
38
39 pub fn sqlite() -> Self {
41 Self {
42 case_sensitive: false,
43 quoted_identifiers: true,
44 backtick_identifiers: true, bracket_identifiers: true, }
47 }
48
49 pub fn sqlserver() -> Self {
51 Self { case_sensitive: false, quoted_identifiers: true, backtick_identifiers: false, bracket_identifiers: true }
52 }
53}
54
55impl Default for SqlLanguage {
56 fn default() -> Self {
57 Self { case_sensitive: false, quoted_identifiers: true, backtick_identifiers: false, bracket_identifiers: false }
58 }
59}
60
61impl Language for SqlLanguage {
62 const NAME: &'static str = "sql";
63 const CATEGORY: LanguageCategory = LanguageCategory::Dsl;
64
65 type TokenType = crate::lexer::token_type::SqlTokenType;
66 type ElementType = crate::parser::element_type::SqlElementType;
67 type TypedRoot = crate::ast::SqlRoot;
68}