git.delta.rocks / jrsonnet / refs/commits / 15dca76ce252

difftreelog

refactor(ir) drop Parened expr

ksrxlvqlYaroslav Bolyukin2026-03-19parent: #7681558.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/src/async_import.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/async_import.rs
+++ b/crates/jrsonnet-evaluator/src/async_import.rs
@@ -211,7 +211,7 @@
 				find_imports(expr, out);
 			}
 		}
-		Expr::Parened(expr) | Expr::UnaryOp(_, expr) | Expr::ErrorStmt(expr) => {
+		Expr::UnaryOp(_, expr) | Expr::ErrorStmt(expr) => {
 			find_imports(expr, out);
 		}
 	}
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
53 | Expr::Num(_)53 | Expr::Num(_)
54 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,54 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,
55 Expr::Arr(a) => a.iter().all(is_trivial),55 Expr::Arr(a) => a.iter().all(is_trivial),
56 Expr::Parened(e) => is_trivial(e),
57 _ => false,56 _ => false,
58 }57 }
59 }58 }
76 .collect(),75 .collect(),
77 ))76 ))
78 }77 }
79 Expr::Parened(e) => evaluate_trivial(e)?,
80 _ => return None,78 _ => return None,
81 })79 })
82}80}
414 Literal(LiteralType::True) => Val::Bool(true),412 Literal(LiteralType::True) => Val::Bool(true),
415 Literal(LiteralType::False) => Val::Bool(false),413 Literal(LiteralType::False) => Val::Bool(false),
416 Literal(LiteralType::Null) => Val::Null,414 Literal(LiteralType::Null) => Val::Null,
417 Parened(e) => evaluate(ctx, e)?,
418 Str(v) => Val::string(v.clone()),415 Str(v) => Val::string(v.clone()),
419 Num(v) => Val::try_num(*v)?,416 Num(v) => Val::try_num(*v)?,
420 // I have tried to remove special behavior from super by implementing standalone-super417 // I have tried to remove special behavior from super by implementing standalone-super
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -336,9 +336,6 @@
 	/// Object extension: var1 {b: 2}
 	ObjExtend(LocExpr, ObjBody),
 
-	/// (obj)
-	Parened(LocExpr),
-
 	/// -2
 	UnaryOp(UnaryOpType, LocExpr),
 	/// 2 - 2
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/lib.rs
+++ b/crates/jrsonnet-parser/src/lib.rs
@@ -313,6 +313,7 @@
 		use UnaryOpType::*;
 		rule expr(s: &ParserSettings) -> LocExpr
 			= precedence! {
+				"(" _ e:expr(s) _ ")" {e}
 				start:position!() v:@ end:position!() { LocExpr::new(v, Span(s.source.clone(), start as u32, end as u32)) }
 				--
 				a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)}
@@ -359,7 +360,6 @@
 				a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(a, body)}
 				--
 				e:expr_basic(s) {e}
-				"(" _ e:expr(s) _ ")" {Expr::Parened(e)}
 			}
 		pub rule index_part(s: &ParserSettings) -> IndexPart
 		= n:("?" _ ensure_null_coaelse())? "." _ value:id_loc(s) {IndexPart {
@@ -559,25 +559,21 @@
 					el!(Expr::Num(2.0), 0, 1),
 					Add,
 					el!(
-						Expr::Parened(el!(
-							Expr::BinaryOp(
-								el!(Expr::Num(2.0), 3, 4),
-								Add,
-								el!(
-									Expr::BinaryOp(
-										el!(Expr::Num(2.0), 5, 6),
-										Mul,
-										el!(Expr::Num(2.0), 7, 8),
-									),
-									5,
-									8
+						Expr::BinaryOp(
+							el!(Expr::Num(2.0), 3, 4),
+							Add,
+							el!(
+								Expr::BinaryOp(
+									el!(Expr::Num(2.0), 5, 6),
+									Mul,
+									el!(Expr::Num(2.0), 7, 8),
 								),
+								5,
+								8
 							),
-							3,
-							8
-						)),
-						2,
-						9
+						),
+						3,
+						8
 					),
 				),
 				0,