diff --git a/src/dialect/mod.rs b/src/dialect/mod.rs index ba6819017..a1087c02b 100644 --- a/src/dialect/mod.rs +++ b/src/dialect/mod.rs @@ -13,7 +13,6 @@ mod ansi; mod generic; mod hive; -pub mod keywords; mod mssql; mod mysql; mod postgresql; @@ -31,6 +30,7 @@ pub use self::mysql::MySqlDialect; pub use self::postgresql::PostgreSqlDialect; pub use self::snowflake::SnowflakeDialect; pub use self::sqlite::SQLiteDialect; +pub use crate::keywords; /// `dialect_of!(parser is SQLiteDialect | GenericDialect)` evaluates /// to `true` iff `parser.dialect` is one of the `Dialect`s specified. diff --git a/src/dialect/keywords.rs b/src/keywords.rs similarity index 94% rename from src/dialect/keywords.rs rename to src/keywords.rs index b89e68f97..8f73836c4 100644 --- a/src/dialect/keywords.rs +++ b/src/keywords.rs @@ -10,19 +10,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -/// This module defines -/// 1) a list of constants for every keyword that -/// can appear in [Word::keyword]: -/// pub const KEYWORD = "KEYWORD" -/// 2) an `ALL_KEYWORDS` array with every keyword in it -/// This is not a list of *reserved* keywords: some of these can be -/// parsed as identifiers if the parser decides so. This means that -/// 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 -/// and could be removed. -/// 3) a `RESERVED_FOR_TABLE_ALIAS` array with keywords reserved in a -/// "table alias" context. +//! This module defines +//! 1) a list of constants for every keyword that +//! can appear in [Word::keyword]: +//! pub const KEYWORD = "KEYWORD" +//! 2) an `ALL_KEYWORDS` array with every keyword in it +//! This is not a list of *reserved* keywords: some of these can be +//! parsed as identifiers if the parser decides so. This means that +//! 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 +//! and could be removed. +//! 3) a `RESERVED_FOR_TABLE_ALIAS` array with keywords reserved in a +//! "table alias" context. + #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -59,9 +60,7 @@ macro_rules! define_keywords { pub const ALL_KEYWORDS: &[&str] = &[ $($ident),* ]; - }; - } // The following keywords should be sorted to be able to match using binary search diff --git a/src/lib.rs b/src/lib.rs index ace6d363b..f04ae07a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,6 +42,7 @@ extern crate alloc; pub mod ast; #[macro_use] pub mod dialect; +pub mod keywords; pub mod parser; pub mod tokenizer; diff --git a/src/parser.rs b/src/parser.rs index 312a3379f..f6017579f 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -25,8 +25,8 @@ use core::fmt; use log::debug; use crate::ast::*; -use crate::dialect::keywords::Keyword; use crate::dialect::*; +use crate::keywords::{self, Keyword}; use crate::tokenizer::*; #[derive(Debug, Clone, PartialEq)] diff --git a/src/tokenizer.rs b/src/tokenizer.rs index aab1e75db..7fc441946 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -31,9 +31,9 @@ use core::str::Chars; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use crate::dialect::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX}; use crate::dialect::Dialect; use crate::dialect::SnowflakeDialect; +use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX}; /// SQL Token enumeration #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index 6ace8e81b..5cc9261f6 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -24,7 +24,8 @@ use test_utils::{all_dialects, expr_from_projection, join, number, only, table, use matches::assert_matches; 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}; #[test]