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
impl Card
pub fn name(&self) -> &str
pub fn as_composite_card(&self) -> Option<&CompositeCard>
pub fn as_composite_card_mut(&mut self) -> Option<&mut CompositeCard>
pub fn composite_card(ty: impl Into<String>, cards: Vec<Card>) -> Self
pub fn repeat(n: Card, i: Option<String>, body: Card) -> Self
pub fn set_var(s: impl Into<String>, value: Card) -> Self
pub fn call_native( s: impl Into<InputString>, args: impl Into<Arguments>, ) -> Self
pub fn read_var(s: impl Into<String>) -> Self
pub fn set_global_var(s: impl Into<String>, value: Card) -> Self
pub fn scalar_int(i: i64) -> Self
pub fn string_card(s: impl Into<String>) -> Self
pub fn call_function(s: impl Into<String>, args: impl Into<Arguments>) -> Self
pub fn function_value(s: impl Into<String>) -> Self
pub fn num_children(&self) -> u32
pub fn iter_children_mut<'a>( &'a mut self, ) -> Box<dyn Iterator<Item = &'a mut Card> + 'a>
pub fn iter_children<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Card> + 'a>
pub fn get_child_mut(&mut self, i: usize) -> Option<&mut Card>
pub fn get_child(&self, i: usize) -> Option<&Card>
pub fn remove_child(&mut self, i: usize) -> Option<Card>
Sourcepub fn insert_child(&mut self, i: usize, card: Self) -> Result<(), Self>
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
Sourcepub fn replace_child(&mut self, i: usize, card: Self) -> Result<Self, Self>
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