Skip to main content

RuchyNode

Enum RuchyNode 

Source
pub enum RuchyNode {
Show 34 variants Module(Vec<RuchyNode>), FnDef { name: String, params: Vec<(String, RuchyType)>, return_type: Option<RuchyType>, body: Vec<RuchyNode>, }, Let { name: String, ty: Option<RuchyType>, value: Box<RuchyNode>, mutable: bool, }, Assign { target: Box<RuchyNode>, value: Box<RuchyNode>, }, BinOp { left: Box<RuchyNode>, op: RuchyBinaryOp, right: Box<RuchyNode>, }, UnaryOp { op: RuchyUnaryOp, operand: Box<RuchyNode>, }, IntLit(i64), FloatLit(f64), StrLit(String), BoolLit(bool), Ident(String), If { cond: Box<RuchyNode>, then_body: Vec<RuchyNode>, else_body: Vec<RuchyNode>, }, Match { value: Box<RuchyNode>, arms: Vec<(RuchyNode, Vec<RuchyNode>)>, }, While { cond: Box<RuchyNode>, body: Vec<RuchyNode>, }, For { var: String, iter: Box<RuchyNode>, body: Vec<RuchyNode>, }, Return(Option<Box<RuchyNode>>), Break, Continue, Call { func: Box<RuchyNode>, args: Vec<RuchyNode>, }, MethodCall { receiver: Box<RuchyNode>, method: String, args: Vec<RuchyNode>, }, StructDef { name: String, fields: Vec<(String, RuchyType)>, }, StructInit { name: String, fields: Vec<(String, RuchyNode)>, }, FieldAccess { receiver: Box<RuchyNode>, field: String, }, OptionalChain { receiver: Box<RuchyNode>, field: String, }, Pipeline { left: Box<RuchyNode>, right: Box<RuchyNode>, }, Array(Vec<RuchyNode>), Range { start: Box<RuchyNode>, end: Box<RuchyNode>, inclusive: bool, }, Closure { params: Vec<String>, body: Box<RuchyNode>, }, Block(Vec<RuchyNode>), Spawn(Box<RuchyNode>), Send { target: Box<RuchyNode>, message: Box<RuchyNode>, }, Compare { left: Box<RuchyNode>, op: RuchyCompareOp, right: Box<RuchyNode>, }, NullCoalesce { value: Box<RuchyNode>, default: Box<RuchyNode>, }, Pattern(RuchyPattern),
}
Expand description

Ruchy AST node types for generation

Variants§

§

Module(Vec<RuchyNode>)

Module (root node)

§

FnDef

Function definition

Fields

§name: String

Function name

§params: Vec<(String, RuchyType)>

Parameters (name, type)

§return_type: Option<RuchyType>

Return type

§body: Vec<RuchyNode>

Function body

§

Let

Let binding

Fields

§name: String

Variable name

§ty: Option<RuchyType>

Optional type annotation

§value: Box<RuchyNode>

Value expression

§mutable: bool

Is mutable

§

Assign

Assignment

Fields

§target: Box<RuchyNode>

Target

§value: Box<RuchyNode>

Value

§

BinOp

Binary operation

Fields

§left: Box<RuchyNode>

Left operand

§op: RuchyBinaryOp

Operator

§right: Box<RuchyNode>

Right operand

§

UnaryOp

Unary operation

Fields

§op: RuchyUnaryOp

Operator

§operand: Box<RuchyNode>

Operand

§

IntLit(i64)

Integer literal

§

FloatLit(f64)

Float literal

§

StrLit(String)

String literal

§

BoolLit(bool)

Boolean literal

§

Ident(String)

Identifier

§

If

If expression

Fields

§cond: Box<RuchyNode>

Condition

§then_body: Vec<RuchyNode>

Then branch

§else_body: Vec<RuchyNode>

Else branch

§

Match

Match expression

Fields

§value: Box<RuchyNode>

Value being matched

§arms: Vec<(RuchyNode, Vec<RuchyNode>)>

Match arms (pattern, body)

§

While

While loop

Fields

§cond: Box<RuchyNode>

Condition

§body: Vec<RuchyNode>

Body

§

For

For loop (for x in iter)

Fields

§var: String

Variable name

§iter: Box<RuchyNode>

Iterator expression

§body: Vec<RuchyNode>

Body

§

Return(Option<Box<RuchyNode>>)

Return expression

§

Break

Break expression

§

Continue

Continue expression

§

Call

Function call

Fields

§func: Box<RuchyNode>

Function expression

§args: Vec<RuchyNode>

Arguments

§

MethodCall

Method call

Fields

§receiver: Box<RuchyNode>

Receiver

§method: String

Method name

§args: Vec<RuchyNode>

Arguments

§

StructDef

Struct definition

Fields

§name: String

Struct name

§fields: Vec<(String, RuchyType)>

Fields (name, type)

§

StructInit

Struct instantiation

Fields

§name: String

Struct name

§fields: Vec<(String, RuchyNode)>

Field initializers

§

FieldAccess

Field access

Fields

§receiver: Box<RuchyNode>

Receiver

§field: String

Field name

§

OptionalChain

Optional chaining (?.)

Fields

§receiver: Box<RuchyNode>

Receiver

§field: String

Field name

§

Pipeline

Pipeline operator (|>)

Fields

§left: Box<RuchyNode>

Left expression

§right: Box<RuchyNode>

Right function

§

Array(Vec<RuchyNode>)

Array literal

§

Range

Range (start..end)

Fields

§start: Box<RuchyNode>

Start

§end: Box<RuchyNode>

End

§inclusive: bool

Inclusive

§

Closure

Closure

Fields

§params: Vec<String>

Parameters

§body: Box<RuchyNode>

Body

§

Block(Vec<RuchyNode>)

Block expression

§

Spawn(Box<RuchyNode>)

Actor spawn

§

Send

Send message

Fields

§target: Box<RuchyNode>

Target actor

§message: Box<RuchyNode>

Message

§

Compare

Comparison

Fields

§left: Box<RuchyNode>

Left operand

§op: RuchyCompareOp

Operator

§right: Box<RuchyNode>

Right operand

§

NullCoalesce

Null coalescing (??)

Fields

§value: Box<RuchyNode>

Value

§default: Box<RuchyNode>

Default

§

Pattern(RuchyPattern)

Pattern for match

Implementations§

Source§

impl RuchyNode

Source

pub fn to_code(&self, indent: usize) -> String

Convert AST node to Ruchy code string

Source

pub fn depth(&self) -> usize

Calculate AST depth

Trait Implementations§

Source§

impl Clone for RuchyNode

Source§

fn clone(&self) -> RuchyNode

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 RuchyNode

Source§

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

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

impl PartialEq for RuchyNode

Source§

fn eq(&self, other: &RuchyNode) -> 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 StructuralPartialEq for RuchyNode

Auto Trait Implementations§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V