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
impl Clone for ASTNodeType
Source§fn clone(&self) -> ASTNodeType
fn clone(&self) -> ASTNodeType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ASTNodeType
impl Debug for ASTNodeType
Source§impl<'de> Deserialize<'de> for ASTNodeType
impl<'de> Deserialize<'de> for ASTNodeType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
impl Display for ASTNodeType
Source§impl PartialEq for ASTNodeType
impl PartialEq for ASTNodeType
Source§impl Serialize for ASTNodeType
impl Serialize for ASTNodeType
impl StructuralPartialEq for ASTNodeType
Auto Trait Implementations§
impl Freeze for ASTNodeType
impl RefUnwindSafe for ASTNodeType
impl Send for ASTNodeType
impl Sync for ASTNodeType
impl Unpin for ASTNodeType
impl UnwindSafe for ASTNodeType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more