Skip to content

Commit 93480ac

Browse files
stuff
1 parent 1843d4a commit 93480ac

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

crates/pg_lexer/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# pg_lexer
2+
3+
The `pg_lexer` crate exposes the `lex` method, which turns an SQL query text into a `Vec<Token>>`: the base for the `pg_parser` and most of pgtools's operations.
4+
5+
A token is always of a certain `SyntaxKind` kind. That `SyntaxKind` enum is derived from `libpg_query`'s protobuf file.
6+
7+
The SQL query text is mostly lexed using the `pg_query::scan` method (`pg_query` is just a Rust wrapper around `libpg_query`).
8+
However, that method does not parse required whitespace tokens, so the `lex` method takes care of parsing those and merging them into the result.

crates/pg_lexer_codegen/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# pg_lexer_codegen
2+
3+
This crate is responsible for reading `libpg_query`'s protobuf file and turning it into the Rust enum `SyntaxKind`.
4+
5+
It does so by reading the file from the installed git submodule, parsing it with a protobuf parser, and using a procedural macro to generate the enum.
6+
7+
Rust requires procedural macros to be defined in a different crate than where they're used, hence this \_codegen crate.

0 commit comments

Comments
 (0)