Add indexing expression parsing and tests
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ pub enum Expr {
|
||||
Bin(Box<BinExpr>),
|
||||
Un(Box<UnExpr>),
|
||||
FunCall(Box<FunCallExpr>),
|
||||
Index(Box<IndexExpr>),
|
||||
Base(BaseExpr),
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ impl Spanned for Expr {
|
||||
Expr::Bin(b) => b.span(),
|
||||
Expr::Un(u) => u.span(),
|
||||
Expr::FunCall(f) => f.span(),
|
||||
Expr::Index(i) => i.span(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,6 +105,21 @@ impl Spanned for FunCallExpr {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Derivative, Clone, PartialEq, Eq)]
|
||||
#[derivative(Debug)]
|
||||
pub struct IndexExpr {
|
||||
pub expr: Expr,
|
||||
pub index: Expr,
|
||||
#[derivative(Debug = "ignore")]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Spanned for IndexExpr {
|
||||
fn span(&self) -> Span {
|
||||
self.span
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum BaseExprKind {
|
||||
Ident,
|
||||
|
||||
Reference in New Issue
Block a user