Add function expression parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -26,17 +26,19 @@ pub enum Expr {
|
||||
Un(Box<UnExpr>),
|
||||
FunCall(Box<FunCallExpr>),
|
||||
Index(Box<IndexExpr>),
|
||||
Fun(Box<FunExpr>),
|
||||
Base(BaseExpr),
|
||||
}
|
||||
|
||||
impl Spanned for Expr {
|
||||
fn span(&self) -> Span {
|
||||
match self {
|
||||
Expr::Base(b) => b.span(),
|
||||
Expr::Bin(b) => b.span(),
|
||||
Expr::Un(u) => u.span(),
|
||||
Expr::FunCall(f) => f.span(),
|
||||
Expr::Index(i) => i.span(),
|
||||
Expr::Fun(f) => f.span(),
|
||||
Expr::Base(b) => b.span(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,6 +122,21 @@ impl Spanned for IndexExpr {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Derivative, Clone, PartialEq, Eq)]
|
||||
#[derivative(Debug)]
|
||||
pub struct FunExpr {
|
||||
pub params: Vec<String>,
|
||||
pub expr: Expr,
|
||||
#[derivative(Debug = "ignore")]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Spanned for FunExpr {
|
||||
fn span(&self) -> Span {
|
||||
self.span
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum BaseExprKind {
|
||||
Ident,
|
||||
|
||||
Reference in New Issue
Block a user