Add support for DuckDB's CREATE MACRO statements (#897)

This commit is contained in:
dawg 2023-06-21 21:12:58 +02:00 committed by GitHub
parent 2296de2bc4
commit 75f18ecfda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 208 additions and 0 deletions

View file

@ -114,6 +114,8 @@ pub enum Token {
Colon,
/// DoubleColon `::` (used for casting in postgresql)
DoubleColon,
/// Assignment `:=` (used for keyword argument in DuckDB macros)
DuckAssignment,
/// SemiColon `;` used as separator for COPY and payload
SemiColon,
/// Backslash `\` used in terminating the COPY payload with `\.`
@ -222,6 +224,7 @@ impl fmt::Display for Token {
Token::Period => f.write_str("."),
Token::Colon => f.write_str(":"),
Token::DoubleColon => f.write_str("::"),
Token::DuckAssignment => f.write_str(":="),
Token::SemiColon => f.write_str(";"),
Token::Backslash => f.write_str("\\"),
Token::LBracket => f.write_str("["),
@ -847,6 +850,7 @@ impl<'a> Tokenizer<'a> {
chars.next();
match chars.peek() {
Some(':') => self.consume_and_return(chars, Token::DoubleColon),
Some('=') => self.consume_and_return(chars, Token::DuckAssignment),
_ => Ok(Some(Token::Colon)),
}
}