sql_ast/
lib.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5// http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12
13//! SQL Parser for Rust
14//!
15//! Example code:
16//!
17//! This crate provides an ANSI:SQL 2011 lexer and parser that can parse SQL
18//! into an Abstract Syntax Tree (AST).
19//!
20//! ```
21//! use sql_ast::dialect::GenericDialect;
22//! use sql_ast::parser::Parser;
23//!
24//! let dialect = GenericDialect {}; // or AnsiDialect
25//!
26//! let sql = "SELECT a, b, 123, myfunc(b) \
27//!            FROM table_1 \
28//!            WHERE a > b AND b < 100 \
29//!            ORDER BY a DESC, b";
30//!
31//! let ast = Parser::parse_sql(&dialect, sql.to_string()).unwrap();
32//!
33//! println!("AST: {:?}", ast);
34//! ```
35#![warn(clippy::all)]
36#![deny(warnings)]
37
38pub mod ast;
39pub mod dialect;
40pub mod parser;
41pub mod tokenizer;
42pub use ast::Value;
43
44#[doc(hidden)]
45// This is required to make utilities accessible by both the crate-internal
46// unit-tests and by the integration tests <https://stackoverflow.com/a/44541071/1026>
47pub mod test_utils;