summaryrefslogtreecommitdiffstats
path: root/crates/rebel-parse/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rebel-parse/src/ast.rs')
-rw-r--r--crates/rebel-parse/src/ast.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/crates/rebel-parse/src/ast.rs b/crates/rebel-parse/src/ast.rs
index e3b93ba..88853d7 100644
--- a/crates/rebel-parse/src/ast.rs
+++ b/crates/rebel-parse/src/ast.rs
@@ -55,14 +55,21 @@ pub enum BodyStmt<'a> {
}
impl<'a> BodyStmt<'a> {
- pub(crate) fn assign(dest: TypedExpr<'a>, op: Option<OpBinary>, expr: Expr<'a>) -> Self {
+ pub(crate) fn assign(
+ dest: TypedExpr<'a>,
+ op: Option<OpBinary>,
+ swapped: bool,
+ expr: Expr<'a>,
+ ) -> Self {
match op {
Some(op) => {
let dest_expr = dest.expr.clone();
- BodyStmt::Assign {
- dest,
- expr: Expr::binary(dest_expr, op, expr),
- }
+ let expr = if swapped {
+ Expr::binary(expr, op, dest_expr)
+ } else {
+ Expr::binary(dest_expr, op, expr)
+ };
+ BodyStmt::Assign { dest, expr }
}
None => BodyStmt::Assign { dest, expr },
}