sqlx_models_parser/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 sqlparser::dialect::GenericDialect;
22//! use sqlparser::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).unwrap();
32//!
33//! println!("AST: {:?}", ast);
34//! ```
35
36#![cfg_attr(not(feature = "std"), no_std)]
37#![allow(clippy::upper_case_acronyms)]
38
39#[cfg(not(feature = "std"))]
40extern crate alloc;
41
42pub mod ast;
43#[macro_use]
44pub mod dialect;
45pub mod parser;
46pub mod tokenizer;
47
48#[doc(hidden)]
49// This is required to make utilities accessible by both the crate-internal
50// unit-tests and by the integration tests <https://stackoverflow.com/a/44541071/1026>
51// External users are not supposed to rely on this module.
52pub mod test_utils;