Enum ASTNodeType

Source
pub enum ASTNodeType {
Show 35 variants Null, Undefined, String(String), Boolean(bool), Number(String), Base64(String), Variable(String), Required(String), Let(String), Frame, Assign, LambdaDef(bool, HashSet<String>), Expressions, Apply, Operation(ASTNodeOperation), Tuple, AssumeTuple, Pair, GetAttr, Return, If, While, Modifier(ASTNodeModifier), Break, Continue, Range, In, Namespace(String), LazySet, Map, Is, Raise, Dynamic, Static, Comptime,
}
Expand description

AST 节点类型枚举。

定义了 Onion 语言中所有可能的 AST 节点类型,对应不同的语法结构。

§语法结构说明

§字面量类型

  • Null:空值 null
  • Undefined:未定义值 undefined
  • String(String):字符串字面量 "text"
  • Boolean(bool):布尔值 true/false
  • Number(String):数值字面量 42, 3.14, 0xFF
  • Base64(String):Base64 编码数据

§变量与标识符

  • Variable(String):变量引用 variable_name
  • Required(String):必需变量占位符 @required "var"

§变量操作

  • Let(String):变量绑定 x := value
  • Assign:变量赋值 x = value

§函数与应用

  • LambdaDef(bool, HashSet<String>):Lambda 定义 params -> body
    • 第一个参数:是否为动态函数 (dyn)
    • 第二个参数:捕获的变量集合 (& captured_vars)
  • Apply:函数应用 func args

§数据结构

  • Tuple:元组 x, y, z
  • Pair:键值对 key: value
  • AssumeTuple:假设元组 ...value

§控制流

  • If:条件分支 if condition body [else else_body]
  • While:循环 while condition body
  • Break:跳出循环 break value
  • Continue:继续循环 continue value
  • Return:函数返回 return value
  • Raise:抛出异常 raise error

§运算符

  • Operation(ASTNodeOperation):各种运算 +, -, *, /, ==, 等

§高级特性

  • Range:范围 start..end
  • In:包含检查 element in container
  • Is:同一性检查 x is y
  • GetAttr:成员访问 object.member
  • Set:集合过滤 collection | filter
  • Map:集合映射 collection |> map
  • Namespace(String):命名空间 Type::value

§修饰符与元操作

  • Modifier(ASTNodeModifier):修饰符 mut, const, typeof, 等
  • Frame:作用域块 {...}
  • Expressions:表达式序列 expr1; expr2; ...

§编译时特性

  • Dynamic:动态模式 dynamic expression
  • Static:静态模式 static expression
  • Comptime:编译时求值 @ expression

Variants§

§

Null

§

Undefined

§

String(String)

§

Boolean(bool)

§

Number(String)

§

Base64(String)

§

Variable(String)

§

Required(String)

§

Let(String)

§

Frame

§

Assign

§

LambdaDef(bool, HashSet<String>)

§

Expressions

§

Apply

§

Operation(ASTNodeOperation)

§

Tuple

§

AssumeTuple

§

Pair

§

GetAttr

§

Return

§

If

§

While

§

Modifier(ASTNodeModifier)

§

Break

§

Continue

§

Range

§

In

§

Namespace(String)

§

LazySet

§

Map

§

Is

§

Raise

§

Dynamic

§

Static

§

Comptime

Trait Implementations§

Source§

impl Clone for ASTNodeType

Source§

fn clone(&self) -> ASTNodeType

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 ASTNodeType

Source§

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

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

impl<'de> Deserialize<'de> for ASTNodeType

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 Display for ASTNodeType

Source§

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

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

impl PartialEq for ASTNodeType

Source§

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

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 StructuralPartialEq for ASTNodeType

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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>,