Expand description
Parser infrastructure for the query language.
§Architecture
This parser produces a lossless concrete syntax tree (CST) via Rowan’s green tree builder. Key design decisions borrowed from rust-analyzer, rnix-parser, and taplo:
- Zero-copy parsing: tokens carry spans, text sliced only when building tree nodes
- Trivia buffering: whitespace/comments collected, then attached as leading trivia
- Checkpoint-based wrapping: retroactively wrap nodes for quantifiers
*+? - Explicit recovery sets: per-production sets determine when to bail vs consume diagnostics
§Recovery Strategy
The parser is resilient—it always produces a tree. Recovery follows these rules:
- Unknown tokens get wrapped in
SyntaxKind::Errornodes and consumed - Missing expected tokens emit a diagnostic but don’t consume (parent may handle)
- Recovery sets define “synchronization points” per production
- On recursion limit, remaining input goes into single Error node
However, fuel exhaustion (exec_fuel, recursion_fuel) returns an actual error immediately.
Re-exports§
pub use cst::SyntaxKind;pub use cst::SyntaxNode;pub use cst::SyntaxToken;pub use ast::AltExpr;pub use ast::AltKind;pub use ast::Anchor;pub use ast::AnonymousNode;pub use ast::Branch;pub use ast::CapturedExpr;pub use ast::Def;pub use ast::Expr;pub use ast::FieldExpr;pub use ast::NamedNode;pub use ast::NegatedField;pub use ast::QuantifiedExpr;pub use ast::Ref;pub use ast::Root;pub use ast::SeqExpr;pub use ast::SeqItem;pub use ast::Type;pub use ast::token_src;
Modules§
- ast
- Typed AST wrappers over CST nodes.
- cst
- Syntax kinds for the query language.
- lexer
- Lexer for the query language.
Structs§
- Parse
Result - Parser
- Trivia tokens are buffered and flushed when starting a new node.