Expr

Enum Expr 

Source
pub enum Expr {
Show 22 variants Literal(LiteralType), Str(IStr), Num(f64), Var(IStr), Arr(Vec<LocExpr>), ArrComp(LocExpr, Vec<CompSpec>), Obj(ObjBody), ObjExtend(LocExpr, ObjBody), Parened(LocExpr), UnaryOp(UnaryOpType, LocExpr), BinaryOp(LocExpr, BinaryOpType, LocExpr), AssertExpr(AssertStmt, LocExpr), LocalExpr(Vec<BindSpec>, LocExpr), Import(PathBuf), ImportStr(PathBuf), ErrorStmt(LocExpr), Apply(LocExpr, ArgsDesc, bool), Index(LocExpr, LocExpr), Function(ParamsDesc, LocExpr), Intrinsic(IStr), IfElse { cond: IfSpecData, cond_then: LocExpr, cond_else: Option<LocExpr>, }, Slice(LocExpr, SliceDesc),
}
Expand description

Syntax base

Variants§

§

Literal(LiteralType)

§

Str(IStr)

String value: “hello”

§

Num(f64)

Number: 1, 2.0, 2e+20

§

Var(IStr)

Variable name: test

§

Arr(Vec<LocExpr>)

Array of expressions: [1, 2, “Hello”]

§

ArrComp(LocExpr, Vec<CompSpec>)

Array comprehension:

 ingredients: [
   { kind: kind, qty: 4 / 3 }
   for kind in [
     'Honey Syrup',
     'Lemon Juice',
     'Farmers Gin',
   ]
 ],
§

Obj(ObjBody)

Object: {a: 2}

§

ObjExtend(LocExpr, ObjBody)

Object extension: var1 {b: 2}

§

Parened(LocExpr)

(obj)

§

UnaryOp(UnaryOpType, LocExpr)

-2

§

BinaryOp(LocExpr, BinaryOpType, LocExpr)

2 - 2

§

AssertExpr(AssertStmt, LocExpr)

assert 2 == 2 : “Math is broken”

§

LocalExpr(Vec<BindSpec>, LocExpr)

local a = 2; { b: a }

§

Import(PathBuf)

import “hello”

§

ImportStr(PathBuf)

importStr “file.txt”

§

ErrorStmt(LocExpr)

error “I’m broken”

§

Apply(LocExpr, ArgsDesc, bool)

a(b, c)

§

Index(LocExpr, LocExpr)

a[b]

§

Function(ParamsDesc, LocExpr)

function(x) x

§

Intrinsic(IStr)

std.primitiveEquals

§

IfElse

if true == false then 1 else 2

Fields

§cond_then: LocExpr
§cond_else: Option<LocExpr>
§

Slice(LocExpr, SliceDesc)

Trait Implementations§

Source§

impl Debug for Expr

Source§

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

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

impl Finalize for Expr

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 Trace for Expr

Source§

unsafe fn trace(&self)

Marks all contained Gcs.
Source§

unsafe fn root(&self)

Increments the root-count of all contained Gcs.
Source§

unsafe fn unroot(&self)

Decrements the root-count of all contained Gcs.
Source§

fn finalize_glue(&self)

Runs Finalize::finalize() on this object and all contained subobjects
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 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> 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, 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.