mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-26 15:39:12 +00:00
Move the keywords
module (#352)
* Move the keywords mod from dialect mod into the root of library Signed-off-by: koushiro <koushiro.cqx@gmail.com> * re-export keywords from dialect for backwards compatiblity Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
parent
3dd89ac44d
commit
c9f8a44b55
6 changed files with 20 additions and 19 deletions
|
@ -13,7 +13,6 @@
|
||||||
mod ansi;
|
mod ansi;
|
||||||
mod generic;
|
mod generic;
|
||||||
mod hive;
|
mod hive;
|
||||||
pub mod keywords;
|
|
||||||
mod mssql;
|
mod mssql;
|
||||||
mod mysql;
|
mod mysql;
|
||||||
mod postgresql;
|
mod postgresql;
|
||||||
|
@ -31,6 +30,7 @@ pub use self::mysql::MySqlDialect;
|
||||||
pub use self::postgresql::PostgreSqlDialect;
|
pub use self::postgresql::PostgreSqlDialect;
|
||||||
pub use self::snowflake::SnowflakeDialect;
|
pub use self::snowflake::SnowflakeDialect;
|
||||||
pub use self::sqlite::SQLiteDialect;
|
pub use self::sqlite::SQLiteDialect;
|
||||||
|
pub use crate::keywords;
|
||||||
|
|
||||||
/// `dialect_of!(parser is SQLiteDialect | GenericDialect)` evaluates
|
/// `dialect_of!(parser is SQLiteDialect | GenericDialect)` evaluates
|
||||||
/// to `true` iff `parser.dialect` is one of the `Dialect`s specified.
|
/// to `true` iff `parser.dialect` is one of the `Dialect`s specified.
|
||||||
|
|
|
@ -10,19 +10,20 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
/// This module defines
|
//! This module defines
|
||||||
/// 1) a list of constants for every keyword that
|
//! 1) a list of constants for every keyword that
|
||||||
/// can appear in [Word::keyword]:
|
//! can appear in [Word::keyword]:
|
||||||
/// pub const KEYWORD = "KEYWORD"
|
//! pub const KEYWORD = "KEYWORD"
|
||||||
/// 2) an `ALL_KEYWORDS` array with every keyword in it
|
//! 2) an `ALL_KEYWORDS` array with every keyword in it
|
||||||
/// This is not a list of *reserved* keywords: some of these can be
|
//! This is not a list of *reserved* keywords: some of these can be
|
||||||
/// parsed as identifiers if the parser decides so. This means that
|
//! parsed as identifiers if the parser decides so. This means that
|
||||||
/// new keywords can be added here without affecting the parse result.
|
//! new keywords can be added here without affecting the parse result.
|
||||||
///
|
//!
|
||||||
/// As a matter of fact, most of these keywords are not used at all
|
//! As a matter of fact, most of these keywords are not used at all
|
||||||
/// and could be removed.
|
//! and could be removed.
|
||||||
/// 3) a `RESERVED_FOR_TABLE_ALIAS` array with keywords reserved in a
|
//! 3) a `RESERVED_FOR_TABLE_ALIAS` array with keywords reserved in a
|
||||||
/// "table alias" context.
|
//! "table alias" context.
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -59,9 +60,7 @@ macro_rules! define_keywords {
|
||||||
pub const ALL_KEYWORDS: &[&str] = &[
|
pub const ALL_KEYWORDS: &[&str] = &[
|
||||||
$($ident),*
|
$($ident),*
|
||||||
];
|
];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following keywords should be sorted to be able to match using binary search
|
// The following keywords should be sorted to be able to match using binary search
|
|
@ -42,6 +42,7 @@ extern crate alloc;
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod dialect;
|
pub mod dialect;
|
||||||
|
pub mod keywords;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
pub mod tokenizer;
|
pub mod tokenizer;
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ use core::fmt;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::dialect::keywords::Keyword;
|
|
||||||
use crate::dialect::*;
|
use crate::dialect::*;
|
||||||
|
use crate::keywords::{self, Keyword};
|
||||||
use crate::tokenizer::*;
|
use crate::tokenizer::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|
|
@ -31,9 +31,9 @@ use core::str::Chars;
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::dialect::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
|
|
||||||
use crate::dialect::Dialect;
|
use crate::dialect::Dialect;
|
||||||
use crate::dialect::SnowflakeDialect;
|
use crate::dialect::SnowflakeDialect;
|
||||||
|
use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
|
||||||
|
|
||||||
/// SQL Token enumeration
|
/// SQL Token enumeration
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -24,7 +24,8 @@ use test_utils::{all_dialects, expr_from_projection, join, number, only, table,
|
||||||
|
|
||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
use sqlparser::ast::*;
|
use sqlparser::ast::*;
|
||||||
use sqlparser::dialect::{keywords::ALL_KEYWORDS, GenericDialect, SQLiteDialect};
|
use sqlparser::dialect::{GenericDialect, SQLiteDialect};
|
||||||
|
use sqlparser::keywords::ALL_KEYWORDS;
|
||||||
use sqlparser::parser::{Parser, ParserError};
|
use sqlparser::parser::{Parser, ParserError};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue