Enum Card

Source
pub enum Card {
Show 43 variants Add(BinaryExpression), Sub(BinaryExpression), Mul(BinaryExpression), Div(BinaryExpression), Less(BinaryExpression), LessOrEq(BinaryExpression), Equals(BinaryExpression), NotEquals(BinaryExpression), And(BinaryExpression), Or(BinaryExpression), Xor(BinaryExpression), Not(UnaryExpression), Return(UnaryExpression), ScalarNil, CreateTable, Abort, Len(UnaryExpression), SetProperty(Box<[Card; 3]>), GetProperty(BinaryExpression), ScalarInt(i64), ScalarFloat(f64), StringLiteral(String), CallNative(Box<CallNode>), IfTrue(BinaryExpression), IfFalse(BinaryExpression), IfElse(Box<[Card; 3]>), Call(Box<StaticJump>), Function(String), NativeFunction(String), SetGlobalVar(Box<SetVar>), SetVar(Box<SetVar>), ReadVar(VarName), Repeat(Box<Repeat>), While(Box<[Card; 2]>), ForEach(Box<ForEach>), CompositeCard(Box<CompositeCard>), DynamicCall(Box<DynamicJump>), Get(BinaryExpression), AppendTable(BinaryExpression), PopTable(UnaryExpression), Array(Vec<Card>), Closure(Box<Function>), Comment(String),
}
Expand description

Cao-Lang AST

Variants§

§

Add(BinaryExpression)

§

Sub(BinaryExpression)

§

Mul(BinaryExpression)

§

Div(BinaryExpression)

§

Less(BinaryExpression)

§

LessOrEq(BinaryExpression)

§

Equals(BinaryExpression)

§

NotEquals(BinaryExpression)

§

And(BinaryExpression)

§

Or(BinaryExpression)

§

Xor(BinaryExpression)

§

Not(UnaryExpression)

§

Return(UnaryExpression)

§

ScalarNil

§

CreateTable

§

Abort

§

Len(UnaryExpression)

§

SetProperty(Box<[Card; 3]>)

Insert value at key into the table [Value, Table, Key]

§

GetProperty(BinaryExpression)

[Table, Key]

§

ScalarInt(i64)

§

ScalarFloat(f64)

§

StringLiteral(String)

§

CallNative(Box<CallNode>)

§

IfTrue(BinaryExpression)

Children = [condition, then]

§

IfFalse(BinaryExpression)

Children = [condition, else]

§

IfElse(Box<[Card; 3]>)

Children = [condition, then, else]

§

Call(Box<StaticJump>)

Function name

§

Function(String)

Function name

Creates a pointer to the given cao-lang function

§

NativeFunction(String)

Function name

Creates a pointer to the given native function

§

SetGlobalVar(Box<SetVar>)

§

SetVar(Box<SetVar>)

§

ReadVar(VarName)

§

Repeat(Box<Repeat>)

repeats the body N times

§

While(Box<[Card; 2]>)

Children = [condition, body]

§

ForEach(Box<ForEach>)

§

CompositeCard(Box<CompositeCard>)

Single card that decomposes into multiple cards

§

DynamicCall(Box<DynamicJump>)

Jump to the function that’s on the top of the stack

§

Get(BinaryExpression)

Get the given integer row of a table [Table, Index]

§

AppendTable(BinaryExpression)

[Value, Table]

§

PopTable(UnaryExpression)

§

Array(Vec<Card>)

Create a Table from the results of the provided cards

§

Closure(Box<Function>)

§

Comment(String)

Implementations§

Source§

impl Card

Source

pub fn name(&self) -> &str

Source

pub fn as_composite_card(&self) -> Option<&CompositeCard>

Source

pub fn as_composite_card_mut(&mut self) -> Option<&mut CompositeCard>

Source

pub fn composite_card(ty: impl Into<String>, cards: Vec<Card>) -> Self

Source

pub fn repeat(n: Card, i: Option<String>, body: Card) -> Self

Source

pub fn set_var(s: impl Into<String>, value: Card) -> Self

Source

pub fn call_native( s: impl Into<InputString>, args: impl Into<Arguments>, ) -> Self

Source

pub fn read_var(s: impl Into<String>) -> Self

Source

pub fn set_global_var(s: impl Into<String>, value: Card) -> Self

Source

pub fn scalar_int(i: i64) -> Self

Source

pub fn string_card(s: impl Into<String>) -> Self

Source

pub fn call_function(s: impl Into<String>, args: impl Into<Arguments>) -> Self

Source

pub fn function_value(s: impl Into<String>) -> Self

Source

pub fn num_children(&self) -> u32

Source

pub fn iter_children_mut<'a>( &'a mut self, ) -> Box<dyn Iterator<Item = &'a mut Card> + 'a>

Source

pub fn iter_children<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Card> + 'a>

Source

pub fn get_child_mut(&mut self, i: usize) -> Option<&mut Card>

Source

pub fn get_child(&self, i: usize) -> Option<&Card>

Source

pub fn remove_child(&mut self, i: usize) -> Option<Card>

Source

pub fn insert_child(&mut self, i: usize, card: Self) -> Result<(), Self>

insert a child at the specified index, if the Card is a list, or replace the child at the index if not

returns the inserted card on failure

Source

pub fn replace_child(&mut self, i: usize, card: Self) -> Result<Self, Self>

Return Ok(old card) on success, return the input card in fail

Source

pub fn return_card(c: Self) -> Self

Source

pub fn set_property(value: Self, table: Self, key: Self) -> Self

Source

pub fn get_property(table: Self, key: Self) -> Self

Source

pub fn dynamic_call(function: Card, args: impl Into<Arguments>) -> Self

Trait Implementations§

Source§

impl Clone for Card

Source§

fn clone(&self) -> Card

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 Card

Source§

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

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

impl Default for Card

Source§

fn default() -> Card

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

impl<'de> Deserialize<'de> for Card

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 From<CompositeCard> for Card

Source§

fn from(value: CompositeCard) -> Self

Converts to this type from the input type.
Source§

impl From<ForEach> for Card

Source§

fn from(value: ForEach) -> Self

Converts to this type from the input type.
Source§

impl Serialize for Card

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

Auto Trait Implementations§

§

impl Freeze for Card

§

impl RefUnwindSafe for Card

§

impl Send for Card

§

impl Sync for Card

§

impl Unpin for Card

§

impl UnwindSafe for Card

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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