Skip to main content

Module parser

Module parser 

Source
Expand description

Recursive-descent parser with a Pratt (precedence-climbing) sub-parser for expressions.

Precedence (lowest → highest binding): OR (1) < AND (2) < NOT unary (3) < comparisons = <> < <= > >= (4) < + - (5) < * / (6) < unary - (7) < parens / atom.

This matches PG’s behaviour for the operators we support — e.g. NOT a = b parses as NOT (a = b) and -a * b as (-a) * b.

Structs§

ParseError

Functions§

parse_expression
v7.9.30 — parse a single expression (no trailing junk). Used by the engine to re-hydrate stored partial-index / unique-index predicates from their canonical Display form. The same Pratt parser the statement path uses; this entry point just skips the statement dispatch.
parse_interval_text
Parse the text inside INTERVAL '...' into (months, micros). Accepts one or more <n> <unit> pairs separated by whitespace. <n> may be negative. Returns None if any pair fails to parse or no pair is found.
parse_statement
Parse exactly one statement, swallow an optional trailing ;, and require the token stream to end there.