Expand description
Recursive Descent Parser for SQL Expression Grammar
This module implements a parser that follows the EBNF grammar specification. It uses recursive descent parsing with proper operator precedence to build an Abstract Syntax Tree (AST) from the input SQL expression string. The input string is first tokenized by the lexer module and then parsed into the AST defined in the ast module. The parser ensures that all top-level expressions evaluate to boolean values, while arithmetic and value expressions can only appear as operands to relational operators.
The parser also performs as much type checking at parse time as possible. Additional runtime type checking is necessary during evaluation after variable values are known.
The parser also supports pretty-printing of the AST when the SQLEXPR_PRETTY environment variable is set to “true”.
Structs§
- Parse
Error - Parse error type that defines specific error messages.
- Parser
- Parser struct used to track parsing state and options.
Functions§
- parse
- Public API function to parse a SQL boolean expression string.