Skip to main content

Ast

Struct Ast 

Source
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

Source

pub fn string(&self, index: StrRef) -> &str

The text behind a StrRef, or the empty string for NONE.

Source

pub fn name(&self, slice: Slice) -> impl Iterator<Item = &str>

The parts of a name, outermost first.

Source

pub fn name_text(&self, slice: Slice) -> String

A name written back out with dots between the parts, for error messages and tests.

Source

pub fn expr(&self, index: ExprRef) -> Expr

One expression.

Source

pub fn source(&self, index: SourceRef) -> Source

One from item.

Source

pub fn query(&self, index: QueryRef) -> Query

One query.

Source

pub fn select(&self, index: SelectRef) -> Select

One select block.

Source

pub fn expr_list(&self, slice: Slice) -> &[ExprRef]

The expressions of a list.

Source

pub fn source_list(&self, slice: Slice) -> &[SourceRef]

The from items of a list.

Source

pub fn target_list(&self, slice: Slice) -> &[Target]

The entries of a target list.

Source

pub fn order_list(&self, slice: Slice) -> &[OrderItem]

The entries of an order by list.

Source

pub fn arm_list(&self, slice: Slice) -> &[CaseArm]

The arms of a case.

Source

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.

Trait Implementations§

Source§

impl Clone for Ast

Source§

fn clone(&self) -> Ast

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ast

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Ast

Source§

fn default() -> Ast

Returns the “default value” for a type. Read more
Source§

impl Eq for Ast

Source§

impl PartialEq for Ast

Source§

fn eq(&self, other: &Ast) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Ast

Auto Trait Implementations§

§

impl Freeze for Ast

§

impl RefUnwindSafe for Ast

§

impl Send for Ast

§

impl Sync for Ast

§

impl Unpin for Ast

§

impl UnsafeUnpin for Ast

§

impl UnwindSafe for Ast

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.