From 8ee318f26b106ad08a9d706adb139599611c99a4 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 28 Mar 2024 16:34:24 -0500 Subject: [PATCH] cl-ast: Move ExprKind::Assign outside the box, to be more consistent with other uses of `Expr` --- cl-ast/src/lib.rs | 4 ++-- cl-parser/src/parser.rs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cl-ast/src/lib.rs b/cl-ast/src/lib.rs index 0005c9a..700e669 100644 --- a/cl-ast/src/lib.rs +++ b/cl-ast/src/lib.rs @@ -292,7 +292,7 @@ pub struct Expr { #[derive(Clone, Debug, PartialEq, Eq)] pub enum ExprKind { /// An [Assign]ment expression: [`Expr`] ([`AssignKind`] [`Expr`])\+ - Assign(Box), + Assign(Assign), /// A [Binary] expression: [`Expr`] ([`BinaryKind`] [`Expr`])\+ Binary(Binary), /// A [Unary] expression: [`UnaryKind`]\* [`Expr`] @@ -338,7 +338,7 @@ pub enum ExprKind { #[derive(Clone, Debug, PartialEq, Eq)] pub struct Assign { - pub head: Expr, + pub head: Box, pub op: AssignKind, pub tail: Box, } diff --git a/cl-parser/src/parser.rs b/cl-parser/src/parser.rs index 9508598..f66407c 100644 --- a/cl-parser/src/parser.rs +++ b/cl-parser/src/parser.rs @@ -675,7 +675,14 @@ impl<'t> Parser<'t> { let Ok(op) = self.assign_op() else { return Ok(head.kind); }; - Ok(Assign { head, op, tail: self.expr_from(Self::exprkind_assign)?.into() }.into()) + Ok( + Assign { + head: Box::new(head), + op, + tail: self.expr_from(Self::exprkind_assign)?.into(), + } + .into(), + ) } // TODO: use a pratt parser for binary expressions, to simplify this binary! {