mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 15:04:04 +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 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.
|
||||
|
|
|
@ -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
|
|
@ -42,6 +42,7 @@ extern crate alloc;
|
|||
pub mod ast;
|
||||
#[macro_use]
|
||||
pub mod dialect;
|
||||
pub mod keywords;
|
||||
pub mod parser;
|
||||
pub mod tokenizer;
|
||||
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue