hawdb_sql_syntax/lib.rs
1// Copyright 2026 Nowledge
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! In-progress HawDB-owned PostgreSQL SQL/PGQ syntax frontend.
16//!
17//! This crate owns tokens, byte spans, structured syntax errors, and syntax ASTs.
18//! Statement envelopes use a bounded token PEG with packrat memoization, composed
19//! SQL/PGQ rules, and transformation into the existing syntax AST. Native terminals
20//! retain the bounded Pratt expression and graph-pattern parsers.
21//! Semantic binding and logical-plan lowering belong to `hawdb-sql`.
22//!
23//! This frontend is not yet selected by `Database::query_sql*`; the existing
24//! relational execution path still uses upstream `sqlparser`. Syntax acceptance
25//! alone does not qualify a statement family for production execution.
26//!
27//! The [SQL/PGQ specification] defines the compatibility contract. The
28//! [implementation and routing checklist] tracks the remaining parser/binder
29//! differential coverage, catalog durability, and shared query-pipeline
30//! qualification required before enabling production routing. Parser selection
31//! must be explicit by statement family, never a retry after another parser fails.
32//!
33//! [SQL/PGQ specification]: https://github.com/nowledge-co/hawdb/blob/main/docs/specs/POSTGRES_SQL_PGQ_SPEC.md
34//! [implementation and routing checklist]: https://github.com/nowledge-co/hawdb/blob/main/TODO.md#p1-postgresql-sqlpgq-compatibility
35
36mod ast;
37mod error;
38mod lexer;
39mod parser;
40mod peg;
41mod span;
42mod token;
43
44pub use ast::*;
45pub use error::{SyntaxError, SyntaxErrorCode};
46pub use lexer::{tokenize, tokenize_with_config, LexerConfig};
47pub use parser::{
48 parse_graph_table, parse_pgq_statement, parse_postgres_select, parse_postgres_statement,
49};
50pub use span::Span;
51pub use token::{Token, TokenKind};