pub struct SqlLanguage {
pub case_sensitive: bool,
pub quoted_identifiers: bool,
pub backtick_identifiers: bool,
pub bracket_identifiers: bool,
}Expand description
SQL language implementation.
Fields§
§case_sensitive: boolWhether it is case sensitive.
quoted_identifiers: boolWhether to allow double-quoted identifiers.
backtick_identifiers: boolWhether to allow backtick identifiers.
bracket_identifiers: boolWhether to allow bracket identifiers.
Implementations§
Source§impl SqlLanguage
impl SqlLanguage
Sourcepub fn postgresql() -> Self
pub fn postgresql() -> Self
Creates a PostgreSQL-style SQL language instance.
Trait Implementations§
Source§impl<'config> Builder<SqlLanguage> for SqlBuilder<'config>
impl<'config> Builder<SqlLanguage> for SqlBuilder<'config>
Source§fn build<'a, S: Source + ?Sized>(
&self,
source: &S,
edits: &[TextEdit],
cache: &'a mut impl BuilderCache<SqlLanguage>,
) -> BuildOutput<SqlLanguage>
fn build<'a, S: Source + ?Sized>( &self, source: &S, edits: &[TextEdit], cache: &'a mut impl BuilderCache<SqlLanguage>, ) -> BuildOutput<SqlLanguage>
Builds the SQL AST from the source text and edits.
This is the main entry point for the builder. It performs the following steps:
- Initializes a
SqlParserwith the current configuration. - Executes the parser to produce a
RedTree(Concrete Syntax Tree). - Converts the resulting green tree into a typed
SqlRootAST. - Handles incremental updates by passing
editsto the parser.
§Examples
use oak_core::{Builder, ParseSession, source::SourceText};
use oak_sql::{SqlBuilder, SqlLanguage};
let config = SqlLanguage::default();
let builder = SqlBuilder::new(&config);
let mut cache = ParseSession::default();
let source = "SELECT * FROM users";
let output = builder.build(&source, &[], &mut cache);
if let Ok(root) = output.result {
assert_eq!(root.statements.len(), 1);
}§Errors
Returns an error if parsing fails or if the CST cannot be lowered to a valid AST.
Source§impl Clone for SqlLanguage
impl Clone for SqlLanguage
Source§fn clone(&self) -> SqlLanguage
fn clone(&self) -> SqlLanguage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SqlLanguage
impl Debug for SqlLanguage
Source§impl Default for SqlLanguage
impl Default for SqlLanguage
Source§impl<'de> Deserialize<'de> for SqlLanguage
impl<'de> Deserialize<'de> for SqlLanguage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for SqlLanguage
impl Hash for SqlLanguage
Source§impl HoverProvider<SqlLanguage> for SqlHoverProvider
Available on crate feature lsp only.
impl HoverProvider<SqlLanguage> for SqlHoverProvider
Available on crate feature
lsp only.Source§impl Language for SqlLanguage
impl Language for SqlLanguage
Source§const CATEGORY: LanguageCategory = LanguageCategory::Dsl
const CATEGORY: LanguageCategory = LanguageCategory::Dsl
The category of the language.
Source§type TokenType = SqlTokenType
type TokenType = SqlTokenType
The token type used to represent different token and node types in the language. Read more
Source§type ElementType = SqlElementType
type ElementType = SqlElementType
The element type used to represent composite structures in the parsed tree. Read more
Source§impl<'config> Lexer<SqlLanguage> for SqlLexer<'config>
impl<'config> Lexer<SqlLanguage> for SqlLexer<'config>
Source§fn lex<'a, S: Source + ?Sized>(
&self,
text: &S,
_edits: &[TextEdit],
cache: &'a mut impl LexerCache<SqlLanguage>,
) -> LexOutput<SqlLanguage>
fn lex<'a, S: Source + ?Sized>( &self, text: &S, _edits: &[TextEdit], cache: &'a mut impl LexerCache<SqlLanguage>, ) -> LexOutput<SqlLanguage>
Tokenizes the given source text into a sequence of tokens. Read more
Source§impl<'config> Parser<SqlLanguage> for SqlParser<'config>
impl<'config> Parser<SqlLanguage> for SqlParser<'config>
Source§fn parse<'a, S: Source + ?Sized>(
&self,
text: &'a S,
edits: &[TextEdit],
cache: &'a mut impl ParseCache<SqlLanguage>,
) -> ParseOutput<'a, SqlLanguage>
fn parse<'a, S: Source + ?Sized>( &self, text: &'a S, edits: &[TextEdit], cache: &'a mut impl ParseCache<SqlLanguage>, ) -> ParseOutput<'a, SqlLanguage>
The core parsing entry point. Read more
Source§impl PartialEq for SqlLanguage
impl PartialEq for SqlLanguage
Source§impl<'config> Pratt<SqlLanguage> for SqlParser<'config>
impl<'config> Pratt<SqlLanguage> for SqlParser<'config>
Source§fn primary<'a, S: Source + ?Sized>(
&self,
state: &mut ParserState<'a, SqlLanguage, S>,
) -> &'a GreenNode<'a, SqlLanguage>
fn primary<'a, S: Source + ?Sized>( &self, state: &mut ParserState<'a, SqlLanguage, S>, ) -> &'a GreenNode<'a, SqlLanguage>
Parses a primary expression (e.g., literals, identifiers, group).
Source§fn prefix<'a, S: Source + ?Sized>(
&self,
state: &mut ParserState<'a, SqlLanguage, S>,
) -> &'a GreenNode<'a, SqlLanguage>
fn prefix<'a, S: Source + ?Sized>( &self, state: &mut ParserState<'a, SqlLanguage, S>, ) -> &'a GreenNode<'a, SqlLanguage>
Handles prefix operators and primary expressions. Read more
Source§fn infix<'a, S: Source + ?Sized>(
&self,
state: &mut ParserState<'a, SqlLanguage, S>,
left: &'a GreenNode<'a, SqlLanguage>,
min_precedence: u8,
) -> Option<&'a GreenNode<'a, SqlLanguage>>
fn infix<'a, S: Source + ?Sized>( &self, state: &mut ParserState<'a, SqlLanguage, S>, left: &'a GreenNode<'a, SqlLanguage>, min_precedence: u8, ) -> Option<&'a GreenNode<'a, SqlLanguage>>
Handles infix and postfix operators. Read more
Source§impl Serialize for SqlLanguage
impl Serialize for SqlLanguage
impl Copy for SqlLanguage
impl Eq for SqlLanguage
impl StructuralPartialEq for SqlLanguage
Auto Trait Implementations§
impl Freeze for SqlLanguage
impl RefUnwindSafe for SqlLanguage
impl Send for SqlLanguage
impl Sync for SqlLanguage
impl Unpin for SqlLanguage
impl UnsafeUnpin for SqlLanguage
impl UnwindSafe for SqlLanguage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more