git.delta.rocks / jrsonnet / refs/commits / d512ff65b472

difftreelog

feat plus in object comprehensions

Yaroslav Bolyukin2021-08-20parent: #a6c5806.patch.diff
in: master
Fixes #60

3 files changed

modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
431 builder431 builder
432 .member(n)432 .member(n)
433 .with_location(obj.value.1.clone())433 .with_location(obj.value.1.clone())
434 .with_add(obj.plus)
434 .bindable(Box::new(ObjCompBinding {435 .bindable(Box::new(ObjCompBinding {
435 context: ctx,436 context: ctx,
436 value: obj.value.clone(),437 value: obj.value.clone(),
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -247,6 +247,7 @@
 pub struct ObjComp {
 	pub pre_locals: Vec<BindSpec>,
 	pub key: LocExpr,
+	pub plus: bool,
 	pub value: LocExpr,
 	pub post_locals: Vec<BindSpec>,
 	pub compspecs: Vec<CompSpec>,
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/lib.rs
+++ b/crates/jrsonnet-parser/src/lib.rs
@@ -136,12 +136,13 @@
 			/ assertion:assertion(s) {expr::Member::AssertStmt(assertion)}
 			/ field:field(s) {expr::Member::Field(field)}
 		pub rule objinside(s: &ParserSettings) -> expr::ObjBody
-			= pre_locals:(b: obj_local(s) comma() {b})* "[" _ key:expr(s) _ "]" _ ":" _ value:expr(s) post_locals:(comma() b:obj_local(s) {b})* _ forspec:forspec(s) others:(_ rest:compspec(s) {rest})? {
+			= pre_locals:(b: obj_local(s) comma() {b})* "[" _ key:expr(s) _ "]" _ plus:"+"? _ ":" _ value:expr(s) post_locals:(comma() b:obj_local(s) {b})* _ forspec:forspec(s) others:(_ rest:compspec(s) {rest})? {
 				let mut compspecs = vec![CompSpec::ForSpec(forspec)];
 				compspecs.extend(others.unwrap_or_default());
 				expr::ObjBody::ObjComp(expr::ObjComp{
 					pre_locals,
 					key,
+					plus: plus.is_some(),
 					value,
 					post_locals,
 					compspecs,