risingwave_sqlparser/
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 risingwave_sqlparser::parser::Parser;
22//!
23//! let sql = "SELECT a, b, 123, myfunc(b) \
24//!            FROM table_1 \
25//!            WHERE a > b AND b < 100 \
26//!            ORDER BY a DESC, b";
27//!
28//! let ast = Parser::parse_sql(sql).unwrap();
29//!
30//! println!("AST: {:?}", ast);
31//! ```
32
33#![cfg_attr(not(feature = "std"), no_std)]
34#![expect(clippy::doc_markdown)]
35#![expect(clippy::upper_case_acronyms)]
36#![feature(register_tool)]
37#![register_tool(rw)]
38#![allow(rw::format_error)] // external crate
39
40#[cfg(not(feature = "std"))]
41extern crate alloc;
42
43pub mod ast;
44pub mod keywords;
45pub mod parser;
46pub mod parser_v2;
47pub mod tokenizer;
48
49#[doc(hidden)]
50// This is required to make utilities accessible by both the crate-internal
51// unit-tests and by the integration tests <https://stackoverflow.com/a/44541071/1026>
52// External users are not supposed to rely on this module.
53pub mod test_utils;