summaryrefslogtreecommitdiff
path: root/src/syntax/expr.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-26 18:07:05 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-26 18:07:05 +0200
commit422b8e640f00977177a5a7250a3c56009eed10c4 (patch)
treeb1a21718e9511d776a6de47b713e3308bb1baaad /src/syntax/expr.rs
parentd53c933e4d56e6c0484d81814779ddb1597ee032 (diff)
With expressions
Diffstat (limited to 'src/syntax/expr.rs')
-rw-r--r--src/syntax/expr.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/syntax/expr.rs b/src/syntax/expr.rs
index 24850d65..62f02399 100644
--- a/src/syntax/expr.rs
+++ b/src/syntax/expr.rs
@@ -52,6 +52,8 @@ pub enum Expr {
Call(CallExpr),
/// A closure expression: `(x, y) => z`.
Closure(ClosureExpr),
+ /// A with expression: `f with (x, y: 1)`.
+ With(WithExpr),
/// A let expression: `let x = 1`.
Let(LetExpr),
/// An if-else expression: `if x { y } else { z }`.
@@ -91,6 +93,7 @@ impl Expr {
Self::Binary(ref v) => v.span,
Self::Call(ref v) => v.span,
Self::Closure(ref v) => v.span,
+ Self::With(ref v) => v.span,
Self::Let(ref v) => v.span,
Self::If(ref v) => v.span,
Self::While(ref v) => v.span,
@@ -383,7 +386,7 @@ pub enum Associativity {
pub struct CallExpr {
/// The source code location.
pub span: Span,
- /// The callee of the function.
+ /// The function to call.
pub callee: Box<Expr>,
/// The arguments to the function.
pub args: CallArgs,
@@ -435,6 +438,19 @@ pub struct ClosureExpr {
pub body: Rc<Expr>,
}
+/// A with expression: `f with (x, y: 1)`.
+///
+/// Applies arguments to a function.
+#[derive(Debug, Clone, PartialEq)]
+pub struct WithExpr {
+ /// The source code location.
+ pub span: Span,
+ /// The function to apply the arguments to.
+ pub callee: Box<Expr>,
+ /// The arguments to apply to the function.
+ pub args: CallArgs,
+}
+
/// A let expression: `let x = 1`.
#[derive(Debug, Clone, PartialEq)]
pub struct LetExpr {