feat: 添加数组字面量和索引访问功能,更新解析器和解释器以支持数组操作
This commit is contained in:
@@ -32,6 +32,24 @@ pub enum Expr {
|
||||
properties: Vec<(String, Expr)>,
|
||||
},
|
||||
|
||||
/// 数组字面量:[ expr, expr, ... ]
|
||||
ArrayLiteral {
|
||||
elements: Vec<Expr>,
|
||||
},
|
||||
|
||||
/// 索引访问:expr[index]
|
||||
IndexGet {
|
||||
array: Box<Expr>,
|
||||
index: Box<Expr>,
|
||||
},
|
||||
|
||||
/// 索引赋值:expr[index] = value
|
||||
IndexSet {
|
||||
array: Box<Expr>,
|
||||
index: Box<Expr>,
|
||||
value: Box<Expr>,
|
||||
},
|
||||
|
||||
/// 一元运算:!expr / -expr
|
||||
Unary {
|
||||
op: UnaryOp,
|
||||
|
||||
Reference in New Issue
Block a user