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