pub struct Ast {
pub statements: Vec<Statement>,
pub queries: Vec<Query>,
pub selects: Vec<Select>,
pub exprs: Vec<Expr>,
pub sources: Vec<Source>,
pub strings: Vec<String>,
pub parts: Vec<StrRef>,
pub expr_lists: Vec<ExprRef>,
pub source_lists: Vec<SourceRef>,
pub targets: Vec<Target>,
pub order_items: Vec<OrderItem>,
pub case_arms: Vec<CaseArm>,
}Expand description
A parsed statement or script, with every arena it points into.
Cheap to clone, cheap to send, and self contained: no index in here refers to anything outside
it, and nothing in here borrows the query text. The text is copied into strings on the way in,
which costs one allocation per distinct identifier and buys an Ast that outlives the string it
came from.
Fields§
§statements: Vec<Statement>The statements in the script, in order.
queries: Vec<Query>The query arena.
selects: Vec<Select>The select arena.
exprs: Vec<Expr>The expression arena.
sources: Vec<Source>The from-item arena.
strings: Vec<String>Interned text. Identifiers keep the case they were written in, because DuckDB does not fold it at any point, including for quoted identifiers.
parts: Vec<StrRef>Backing store for every Slice of names.
expr_lists: Vec<ExprRef>Backing store for every Slice of expressions.
source_lists: Vec<SourceRef>Backing store for every Slice of from items.
targets: Vec<Target>Backing store for every Slice of target list entries.
order_items: Vec<OrderItem>Backing store for every Slice of order by entries.
case_arms: Vec<CaseArm>Backing store for every Slice of case arms.
Implementations§
Source§impl Ast
impl Ast
Sourcepub fn string(&self, index: StrRef) -> &str
pub fn string(&self, index: StrRef) -> &str
The text behind a StrRef, or the empty string for NONE.
Sourcepub fn name(&self, slice: Slice) -> impl Iterator<Item = &str>
pub fn name(&self, slice: Slice) -> impl Iterator<Item = &str>
The parts of a name, outermost first.
Sourcepub fn name_text(&self, slice: Slice) -> String
pub fn name_text(&self, slice: Slice) -> String
A name written back out with dots between the parts, for error messages and tests.
Sourcepub fn source_list(&self, slice: Slice) -> &[SourceRef] ⓘ
pub fn source_list(&self, slice: Slice) -> &[SourceRef] ⓘ
The from items of a list.
Sourcepub fn target_list(&self, slice: Slice) -> &[Target]
pub fn target_list(&self, slice: Slice) -> &[Target]
The entries of a target list.
Sourcepub fn order_list(&self, slice: Slice) -> &[OrderItem]
pub fn order_list(&self, slice: Slice) -> &[OrderItem]
The entries of an order by list.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
How many nodes the whole tree is, across every arena.
The number to watch when the transformer changes. A parse tree of five thousand nodes that becomes an AST of thirty is the twenty precedence levels being thrown away, which is the whole reason this module exists.