Expand description
The recursive-descent statement parser.
Invariant: the parser performs no I/O and consults no catalog. It turns
bytes into an arena tree and nothing else, which is what lets a syntax error
be reported before a file is opened and lets the same parser run inside the
catalog loader on the CREATE text stored in sqlite_schema.
Depth is bounded before allocation rather than after: every recursive entry
charges the expression-depth limit, so an adversarial ((((((... fails with
a limit error at a known offset instead of growing the arena until something
else notices.
One call parses one statement and reports how many bytes it consumed, which is SQLite’s prepare contract: the caller gets a statement and the unused tail, and an empty statement succeeds with no program.
Structs§
- Parameter
Map - Where a statement’s parameters ended up.
- Parsed
Statement - One parsed statement and everything the caller needs to continue.
- Parser
- The parser: a lexer, a token buffer, an arena, and a depth charge.
Enums§
- Statement
Class - What a statement is, decided without a full parse.
Functions§
- classify_
statement - Classifies a statement from its leading keywords alone.
- parse_
expression - Parses a bare expression, which is what a CHECK constraint or a default
value is when it is re-read out of
sqlite_schema. - parse_
next_ statement - Parses the next statement beginning at
offset. - parse_
next_ statement_ into - Parses one statement into an arena the caller supplies.