limbo/vendored/sqlite3-parser
Jussi Saurio 022f679fab chore: make every CREATE TABLE stmt in entire repo have 1 space after tbl name
`BTreeTable::to_sql` makes us incompatible with SQLite by losing e.g. the original whitespace provided during the CREATE TABLE command.

For now let's fix our tests by regex-replacing every CREATE TABLE in
the entire repo to have exactly 1 space after the table name in the
CREATE TABLE statement.
2025-07-22 11:35:21 +03:00
..
.github vendor sqlite3-parser (lemon-rs) 2024-11-16 20:08:59 +02:00
benches Rename limbo_sqlite3_parser crate to turso_sqlite3_parser 2025-06-29 12:34:46 +03:00
examples Rename limbo_sqlite3_parser crate to turso_sqlite3_parser 2025-06-29 12:34:46 +03:00
sqlparser_bench parser: replace KEYWORDS with matching 2025-07-03 20:43:33 +07:00
src chore: make every CREATE TABLE stmt in entire repo have 1 space after tbl name 2025-07-22 11:35:21 +03:00
third_party/lemon parser: use YYSTACKDEPTH 2025-07-08 14:58:33 +07:00
.gitignore vendor sqlite3-parser (lemon-rs) 2024-11-16 20:08:59 +02:00
build.rs Another post-rebase clippy round with 1.88.0 2025-07-12 19:10:56 +03:00
Cargo.toml parser: use YYSTACKDEPTH 2025-07-08 14:58:33 +07:00
checks.md vendor sqlite3-parser (lemon-rs) 2024-11-16 20:08:59 +02:00
CMakeLists.txt vendor sqlite3-parser (lemon-rs) 2024-11-16 20:08:59 +02:00
LICENSE vendor sqlite3-parser (lemon-rs) 2024-11-16 20:08:59 +02:00
README.md vendor sqlite3-parser (lemon-rs) 2024-11-16 20:08:59 +02:00
Sync.md vendor sqlite3-parser (lemon-rs) 2024-11-16 20:08:59 +02:00

Build Status Latest Version Docs dependency status

LEMON parser generator modified to generate Rust code.

Lemon source and SQLite3 grammar were last synced as of July 2024.

Unsupported

Unsupported Grammar syntax

  • %token_destructor: Code to execute to destroy token data
  • %default_destructor: Code for the default non-terminal destructor
  • %destructor: Code which executes whenever this symbol is popped from the stack during error processing

https://www.codeproject.com/Articles/1056460/Generating-a-High-Speed-Parser-Part-Lemon https://www.sqlite.org/lemon.html

SQLite

SQLite lexer and SQLite parser have been ported from C to Rust. The parser generates an AST.

Lexer/Parser:

  • Keep track of position (line, column).
  • Streamable (stop at the end of statement).
  • Resumable (restart after the end of statement).

Lexer and parser have been tested with the following scripts:

TODO:

Unsupported by Rust

  • #line directive

API change

  • No ParseAlloc/ParseFree anymore

Features not tested

  • NDEBUG
  • YYNOERRORRECOVERY
  • YYERRORSYMBOL

To be fixed

  • RHS are moved. Maybe it is not a problem if they are always used once. Just add a check in lemon...
  • %extra_argument is not supported.
  • Terminal symbols generated by lemon should be dumped in a specified file.

Raison d'être

  • lemon_rust does the same thing but with an old version of lemon. And it seems not possible to use yystack as a stack because items may be access randomly and the top+1 item can be used.

  • lalrpop would be the perfect alternative but it does not support fallback/streaming (see this issue) and compilation/generation is slow.

Minimum supported Rust version (MSRV)

Latest stable Rust version at the time of release. It might compile with older versions.