Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 55 variants Literal(Literal, Span), Identifier(String, Span), DataRef(DataRef, Span), DataDateTimeRef(DataDateTimeRef, Span), DataRelativeAccess { reference: Box<Expr>, index: DataIndex, span: Span, }, PropertyAccess { object: Box<Expr>, property: String, optional: bool, span: Span, }, IndexAccess { object: Box<Expr>, index: Box<Expr>, end_index: Option<Box<Expr>>, span: Span, }, BinaryOp { left: Box<Expr>, op: BinaryOp, right: Box<Expr>, span: Span, }, FuzzyComparison { left: Box<Expr>, op: FuzzyOp, right: Box<Expr>, tolerance: FuzzyTolerance, span: Span, }, UnaryOp { op: UnaryOp, operand: Box<Expr>, span: Span, }, FunctionCall { name: String, args: Vec<Expr>, named_args: Vec<(String, Expr)>, span: Span, }, QualifiedFunctionCall { namespace: String, function: String, args: Vec<Expr>, named_args: Vec<(String, Expr)>, span: Span, }, EnumConstructor { enum_name: TypePath, variant: String, payload: EnumConstructorPayload, span: Span, }, TimeRef(TimeReference, Span), DateTime(DateTimeExpr, Span), PatternRef(String, Span), Conditional { condition: Box<Expr>, then_expr: Box<Expr>, else_expr: Option<Box<Expr>>, span: Span, }, Object(Vec<ObjectEntry>, Span), Array(Vec<Expr>, Span), ListComprehension(Box<ListComprehension>, Span), Block(BlockExpr, Span), TypeAssertion { expr: Box<Expr>, type_annotation: TypeAnnotation, meta_param_overrides: Option<HashMap<String, Expr>>, span: Span, }, InstanceOf { expr: Box<Expr>, type_annotation: TypeAnnotation, span: Span, }, FunctionExpr { params: Vec<FunctionParameter>, return_type: Option<TypeAnnotation>, body: Vec<Statement>, span: Span, }, Duration(Duration, Span), Spread(Box<Expr>, Span), If(Box<IfExpr>, Span), While(Box<WhileExpr>, Span), For(Box<ForExpr>, Span), Loop(Box<LoopExpr>, Span), Let(Box<LetExpr>, Span), Assign(Box<AssignExpr>, Span), Break(Option<Box<Expr>>, Span), Continue(Span), Return(Option<Box<Expr>>, Span), MethodCall { receiver: Box<Expr>, method: String, args: Vec<Expr>, named_args: Vec<(String, Expr)>, optional: bool, span: Span, }, Match(Box<MatchExpr>, Span), Unit(Span), Range { start: Option<Box<Expr>>, end: Option<Box<Expr>>, kind: RangeKind, span: Span, }, TimeframeContext { timeframe: Timeframe, expr: Box<Expr>, span: Span, }, TryOperator(Box<Expr>, Span), UsingImpl { expr: Box<Expr>, impl_name: String, span: Span, }, SimulationCall { name: String, params: Vec<(String, Expr)>, span: Span, }, WindowExpr(Box<WindowExpr>, Span), FromQuery(Box<FromQueryExpr>, Span), StructLiteral { type_name: TypePath, fields: Vec<(String, Expr)>, span: Span, }, Await(Box<Expr>, Span), Join(Box<JoinExpr>, Span), Annotated { annotation: Annotation, target: Box<Expr>, span: Span, }, AsyncLet(Box<AsyncLetExpr>, Span), AsyncScope(Box<Expr>, Span), Comptime(Vec<Statement>, Span), ComptimeFor(Box<ComptimeForExpr>, Span), Reference { expr: Box<Expr>, is_mutable: bool, span: Span, }, TableRows(Vec<Vec<Expr>>, Span),
}

Variants§

§

Literal(Literal, Span)

Literal values

§

Identifier(String, Span)

Variable/identifier reference

§

DataRef(DataRef, Span)

Data reference: data[0], data[-1], data[1:5]

§

DataDateTimeRef(DataDateTimeRef, Span)

DateTime-based data reference: data[@“2024-01-15”]

§

DataRelativeAccess

Relative access from a reference: ref[0], ref[-1]

Fields

§reference: Box<Expr>
§span: Span
§

PropertyAccess

Property access: expr.property or expr?.property

Fields

§object: Box<Expr>
§property: String
§optional: bool
§span: Span
§

IndexAccess

Index access: expr[index] or expr[start:end]

Fields

§object: Box<Expr>
§index: Box<Expr>
§end_index: Option<Box<Expr>>
§span: Span
§

BinaryOp

Binary operations

Fields

§left: Box<Expr>
§right: Box<Expr>
§span: Span
§

FuzzyComparison

Fuzzy comparison with explicit tolerance: a ~= b within 0.02

Fields

§left: Box<Expr>
§right: Box<Expr>
§tolerance: FuzzyTolerance
§span: Span
§

UnaryOp

Unary operations

Fields

§operand: Box<Expr>
§span: Span
§

FunctionCall

Function calls: sma(20), rsi(14), momentum(period: 10, threshold: 0.01)

Fields

§name: String
§args: Vec<Expr>
§named_args: Vec<(String, Expr)>
§span: Span
§

QualifiedFunctionCall

Qualified namespace call: module::function(args)

Fields

§namespace: String
§function: String
§args: Vec<Expr>
§named_args: Vec<(String, Expr)>
§span: Span
§

EnumConstructor

Enum constructor: Enum::Variant, Enum::Variant(…), Enum::Variant { … }

Fields

§enum_name: TypePath
§variant: String
§span: Span
§

TimeRef(TimeReference, Span)

Time reference: @today, @“2024-01-15”

§

DateTime(DateTimeExpr, Span)

DateTime expression: @“2024-01-15”, @market_open, etc.

§

PatternRef(String, Span)

Pattern reference in expressions

§

Conditional

Conditional expression: if cond then expr else expr

Fields

§condition: Box<Expr>
§then_expr: Box<Expr>
§else_expr: Option<Box<Expr>>
§span: Span
§

Object(Vec<ObjectEntry>, Span)

Object literal: { field1: expr1, field2: expr2, …spread }

§

Array(Vec<Expr>, Span)

Array literal: [1, 2, 3]

§

ListComprehension(Box<ListComprehension>, Span)

List comprehension: [expr for var in iter if cond]

§

Block(BlockExpr, Span)

Block expression: { let x = 10; x + 5 }

§

TypeAssertion

Type assertion: expr as Type or expr as Type { param: value }

Fields

§expr: Box<Expr>
§type_annotation: TypeAnnotation
§meta_param_overrides: Option<HashMap<String, Expr>>

Meta parameter overrides: as Percent { decimals: 4 }

§span: Span
§

InstanceOf

Instance check: expr instanceof Type

Fields

§expr: Box<Expr>
§type_annotation: TypeAnnotation
§span: Span
§

FunctionExpr

Function expression: function(x, y) { return x + y }

Fields

§return_type: Option<TypeAnnotation>
§span: Span
§

Duration(Duration, Span)

Duration literal: 30d, 1h, 15m

§

Spread(Box<Expr>, Span)

Spread expression: …expr (used in arrays and objects)

§

If(Box<IfExpr>, Span)

If expression: if condition { expr } else { expr }

§

While(Box<WhileExpr>, Span)

While expression: while condition { expr }

§

For(Box<ForExpr>, Span)

For expression: for x in iter { expr }

§

Loop(Box<LoopExpr>, Span)

Loop expression: loop { expr }

§

Let(Box<LetExpr>, Span)

Let binding expression: let x = value; expr

§

Assign(Box<AssignExpr>, Span)

Assignment expression: x = value (returns value)

§

Break(Option<Box<Expr>>, Span)

Break with optional value

§

Continue(Span)

Continue

§

Return(Option<Box<Expr>>, Span)

Return with optional value

§

MethodCall

Method call: expr.method(args) or expr?.method(args)

Fields

§receiver: Box<Expr>
§method: String
§args: Vec<Expr>
§named_args: Vec<(String, Expr)>
§optional: bool

True when called via optional chaining: expr?.method(args)

§span: Span
§

Match(Box<MatchExpr>, Span)

Match expression

§

Unit(Span)

Unit value (void)

§

Range

Range expression with Rust-style syntax

Fields

§start: Option<Box<Expr>>
§span: Span
§

TimeframeContext

Timeframe context expression: on(1h) { expr }

Fields

§timeframe: Timeframe
§expr: Box<Expr>
§span: Span
§

TryOperator(Box<Expr>, Span)

Try operator for fallible propagation (Result/Option): expr?

§

UsingImpl

Named implementation selector: expr using ImplName

Fields

§expr: Box<Expr>
§impl_name: String
§span: Span
§

SimulationCall

Simulation call with inline parameters

Fields

§name: String
§params: Vec<(String, Expr)>
§span: Span
§

WindowExpr(Box<WindowExpr>, Span)

Window function expression: expr OVER (partition by … order by …)

§

FromQuery(Box<FromQueryExpr>, Span)

LINQ-style from query expression Syntax: from var in source [clauses…] select expr

§

StructLiteral

Struct literal: TypeName { field: value, … }

Fields

§type_name: TypePath
§fields: Vec<(String, Expr)>
§span: Span
§

Await(Box<Expr>, Span)

Await expression: await expr

§

Join(Box<JoinExpr>, Span)

Join expression: await join all|race|any|settle { branch, … }

§

Annotated

Annotated expression: @annotation expr Used for expression-level annotations like @timeout(5s) fetch() or @timed computation() Multiple annotations nest left-to-right: @retry(3) @timeout(5s) fetch() becomes Annotated { @retry(3), target: Annotated { @timeout(5s), target: fetch() } }

Fields

§annotation: Annotation
§target: Box<Expr>
§span: Span
§

AsyncLet(Box<AsyncLetExpr>, Span)

Async let expression: async let name = expr Spawns a task and binds a future handle to a local variable.

§

AsyncScope(Box<Expr>, Span)

Async scope expression: async scope { ... } Cancellation boundary — on scope exit, all pending tasks are cancelled in reverse order.

§

Comptime(Vec<Statement>, Span)

Compile-time block expression: comptime { stmts } Evaluated at compile time via the mini-VM. The result replaces this node with a literal.

§

ComptimeFor(Box<ComptimeForExpr>, Span)

Compile-time for loop: comptime for field in target.fields { ... } Unrolled at compile time. Each iteration is compiled with the loop variable bound to the concrete field descriptor. Used inside comptime annotation handlers.

§

Reference

Reference expression: &expr or &mut expr. Creates a shared or exclusive reference to a local variable.

Fields

§expr: Box<Expr>
§is_mutable: bool

True for &mut expr (exclusive/mutable reference).

§span: Span
§

TableRows(Vec<Vec<Expr>>, Span)

Table row literal: [a, b, c], [d, e, f] Used with let t: Table<T> = [row1], [row2], ... syntax. Each inner Vec is one row’s positional field values.

Implementations§

Source§

impl Expr

Source

pub fn to_json_value(&self) -> Value

Convert expression to a JSON value (for literals used in metadata)

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

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

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

impl<'de> Deserialize<'de> for Expr

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Expr

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Expr

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Spanned for Expr

Source§

fn span(&self) -> Span

Get the source span for this node
Source§

impl StructuralPartialEq for Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,