difftreelog
refactor(ir) flatten
in: master
11 files changed
crates/jrsonnet-ir-parser/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/src/lib.rs
+++ b/crates/jrsonnet-ir-parser/src/lib.rs
@@ -1,13 +1,11 @@
-use std::rc::Rc;
-
use jrsonnet_gcmodule::Acyclic;
use jrsonnet_ir::{
- ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BinaryOpType, BindSpec, CompSpec, Destruct, Expr,
- ExprParam, ExprParams, FieldMember, FieldName, ForSpecData, IStr, IfElse, IfSpecData,
- ImportKind, IndexPart, LiteralType, Member, NumValue, ObjBody, ObjComp, ObjMembers, Slice,
- SliceDesc, Source, Span, Spanned, UnaryOpType, Visibility, unescape,
+ unescape, ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BinaryOpType, BindSpec, CompSpec,
+ Destruct, Expr, ExprParam, ExprParams, FieldMember, FieldName, ForSpecData, IStr, IfElse,
+ IfSpecData, ImportKind, IndexPart, LiteralType, Member, NumValue, ObjBody, ObjComp, ObjMembers,
+ Slice, SliceDesc, Source, Span, Spanned, UnaryOpType, Visibility,
};
-use jrsonnet_lexer::{Lexeme, Lexer, Span as LexSpan, SyntaxKind, T, collect_lexed_str_block};
+use jrsonnet_lexer::{collect_lexed_str_block, Lexeme, Lexer, Span as LexSpan, SyntaxKind, T};
pub struct ParserSettings {
pub source: Source,
@@ -16,7 +14,7 @@
#[derive(Debug, Clone)]
pub struct ParseError {
pub message: String,
- pub location: LexSpan,
+ pub location: Span,
}
impl std::fmt::Display for ParseError {
@@ -128,12 +126,13 @@
if self.offset == self.lexemes.len() {
let pos = self.lexemes.last().map_or(0, |v| v.range.1);
return ParseError {
- location: LexSpan(pos, pos),
+ location: Span(self.source.clone(), pos, pos),
message,
};
}
+ let LexSpan(start, end) = self.lexemes[self.offset].range;
ParseError {
- location: self.lexemes[self.offset].range,
+ location: Span(self.source.clone(), start, end),
message,
}
}
@@ -293,7 +292,7 @@
fn destruct(p: &mut Parser<'_>) -> Result<Destruct> {
if p.at(SyntaxKind::IDENT) {
- return Ok(Destruct::Full(ident(p)?));
+ return Ok(Destruct::Full(spanned(p, ident)?));
}
#[cfg(not(feature = "exp-destruct"))]
return Err(p.error(format!("expected identifier, got {}", p.current_desc())));
@@ -407,7 +406,7 @@
loop {
let d = destruct(p)?;
let default = if p.try_eat(T![=]) {
- Some(Rc::new(expr(p)?))
+ Some(expr(p)?)
} else {
None
};
@@ -441,16 +440,15 @@
if is_named {
let name: IStr = ident(p)?;
p.eat(T![=])?;
- let value = Rc::new(expr(p)?);
names.push(name);
- values.push(value);
+ values.push(expr(p)?);
named_started = true;
} else {
if named_started {
return Err(p.error("positional argument after named argument".into()));
}
- unnamed.push(Rc::new(expr(p)?));
+ unnamed.push(expr(p)?);
}
if !p.try_eat(T![,]) {
break;
@@ -472,23 +470,21 @@
return Ok(BindSpec::Field { into: d, value });
}
}
- let name = ident(p)?;
+ let name_spanned = spanned(p, ident)?;
if p.try_eat(T!['(']) {
let ps = params(p)?;
p.eat(T![')'])?;
p.eat(T![=])?;
- let value = Rc::new(expr(p)?);
Ok(BindSpec::Function {
- name,
+ name: name_spanned.value,
params: ps,
- value,
+ value: expr(p)?,
})
} else {
p.eat(T![=])?;
- let value = Rc::new(expr(p)?);
Ok(BindSpec::Field {
- into: Destruct::Full(name),
- value,
+ into: Destruct::Full(name_spanned),
+ value: expr(p)?,
})
}
}
@@ -529,24 +525,22 @@
let ps = params(p)?;
p.eat(T![')'])?;
let vis = visibility(p)?;
- let value = Rc::new(expr(p)?);
Ok(FieldMember {
name,
plus: false,
params: Some(ps),
visibility: vis,
- value,
+ value: expr(p)?,
})
} else {
let plus = p.try_eat(T![+]);
let vis = visibility(p)?;
- let value = Rc::new(expr(p)?);
Ok(FieldMember {
name,
plus,
params: None,
visibility: vis,
- value,
+ value: expr(p)?,
})
}
}
@@ -589,8 +583,8 @@
fn objinside(p: &mut Parser<'_>) -> Result<ObjBody> {
if p.at(T!['}']) {
return Ok(ObjBody::MemberList(ObjMembers {
- locals: Rc::new(Vec::new()),
- asserts: Rc::new(Vec::new()),
+ locals: Vec::new(),
+ asserts: Vec::new(),
fields: Vec::new(),
}));
}
@@ -627,8 +621,8 @@
}
}
Ok(ObjBody::ObjComp(ObjComp {
- locals: Rc::new(locals),
- field: Rc::new(
+ locals,
+ field: Box::new(
field_member.ok_or_else(|| p.error("missing object comprehension field".into()))?,
),
compspecs: specs,
@@ -645,8 +639,8 @@
}
}
Ok(ObjBody::MemberList(ObjMembers {
- locals: Rc::new(locals),
- asserts: Rc::new(asserts),
+ locals,
+ asserts,
fields,
}))
}
@@ -678,13 +672,13 @@
p.eat(T!['['])?;
if p.at(T![']']) {
p.eat(T![']'])?;
- return Ok(Expr::Arr(Rc::new(Vec::new())));
+ return Ok(Expr::Arr(Vec::new()));
}
let first = expr(p)?;
if p.at(T![for]) {
let specs = compspecs(p)?;
p.eat(T![']'])?;
- Ok(Expr::ArrComp(Rc::new(first), specs))
+ Ok(Expr::ArrComp(Box::new(first), specs))
} else if p.at(T![,]) && {
let next = p.offset + 1;
next < p.lexemes.len() && p.lexemes[next].kind == T![for]
@@ -692,7 +686,7 @@
p.eat(T![,])?;
let specs = compspecs(p)?;
p.eat(T![']'])?;
- Ok(Expr::ArrComp(Rc::new(first), specs))
+ Ok(Expr::ArrComp(Box::new(first), specs))
} else {
let mut elems = vec![first];
while p.try_eat(T![,]) {
@@ -702,7 +696,7 @@
elems.push(expr(p)?);
}
p.eat(T![']'])?;
- Ok(Expr::Arr(Rc::new(elems)))
+ Ok(Expr::Arr(elems))
}
}
@@ -735,14 +729,14 @@
let ps = params(p)?;
p.eat(T![')'])?;
let body = expr(p)?;
- Ok(Expr::Function(ps, Rc::new(body)))
+ Ok(Expr::Function(ps, Box::new(body)))
}
T![assert] => {
let a = assert_stmt(p)?;
p.eat(T![;])?;
let rest = expr(p)?;
- Ok(Expr::AssertExpr(Rc::new(AssertExpr { assert: a, rest })))
+ Ok(Expr::AssertExpr(Box::new(AssertExpr { assert: a, rest })))
}
T![error] => {
@@ -891,7 +885,7 @@
p.eat(T!['{'])?;
let body = objinside(p)?;
p.eat(T!['}'])?;
- e = Expr::ObjExtend(Rc::new(e), body);
+ e = Expr::ObjExtend(Box::new(e), body);
} else {
break;
}
@@ -1007,7 +1001,7 @@
if let Some(desc) = lexeme.kind.error_description() {
return Err(ParseError {
message: desc.to_owned(),
- location: lexeme.range,
+ location: Span(p.source.clone(), lexeme.range.0, lexeme.range.1),
});
}
}
crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__array_comp.snapdiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__array_comp.snap
+++ b/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__array_comp.snap
@@ -10,7 +10,7 @@
ForSpec(
ForSpecData {
destruct: Full(
- "x",
+ "x" from virtual:<test>:7-8,
),
over: Var(
"arr" from virtual:<test>:12-15,
crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__function_and_call.snapdiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__function_and_call.snap
+++ b/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__function_and_call.snap
@@ -10,13 +10,13 @@
exprs: [
ExprParam {
destruct: Full(
- "x",
+ "x" from virtual:<test>:8-9,
),
default: None,
},
ExprParam {
destruct: Full(
- "y",
+ "y" from virtual:<test>:11-12,
),
default: Some(
Num(
crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@array_comp.jsonnet.snapdiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@array_comp.jsonnet.snap
+++ b/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@array_comp.jsonnet.snap
@@ -35,7 +35,7 @@
ForSpec(
ForSpecData {
destruct: Full(
- "x",
+ "x" from virtual:<test>:23-24,
),
over: Var(
"arr" from virtual:<test>:28-31,
@@ -52,7 +52,7 @@
ForSpec(
ForSpecData {
destruct: Full(
- "a",
+ "a" from virtual:<test>:41-42,
),
over: Var(
"b" from virtual:<test>:46-47,
@@ -70,7 +70,7 @@
ForSpec(
ForSpecData {
destruct: Full(
- "e",
+ "e" from virtual:<test>:57-58,
),
over: Var(
"f" from virtual:<test>:62-63,
crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@default_nondefault.jsonnet.snapdiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@default_nondefault.jsonnet.snap
+++ b/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@default_nondefault.jsonnet.snap
@@ -11,7 +11,7 @@
exprs: [
ExprParam {
destruct: Full(
- "foo",
+ "foo" from virtual:<test>:8-11,
),
default: Some(
Str(
@@ -21,7 +21,7 @@
},
ExprParam {
destruct: Full(
- "bar",
+ "bar" from virtual:<test>:21-24,
),
default: None,
},
crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@subexp.jsonnet.snapdiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@subexp.jsonnet.snap
+++ b/crates/jrsonnet-ir-parser/src/snapshots/jrsonnet_ir_parser__tests__peg_snapshots@subexp.jsonnet.snap
@@ -20,7 +20,7 @@
locals: [
Field {
into: Full(
- "x",
+ "x" from virtual:<test>:11-12,
),
value: Num(
1.0,
crates/jrsonnet-ir/src/expr.rsdiffbeforeafterboth1use std::{1use std::{2 fmt::{self, Debug, Display},2 fmt::{self, Debug, Display},3 ops::{Deref, RangeInclusive},3 ops::{Deref, RangeInclusive},4 rc::Rc,5};4};657use jrsonnet_gcmodule::Acyclic;6use jrsonnet_gcmodule::Acyclic;8use jrsonnet_interner::IStr;7use jrsonnet_interner::IStr;9810use crate::{9use crate::{11 NumValue,12 function::{FunctionSignature, ParamDefault, ParamName, ParamParse},10 function::{FunctionSignature, ParamDefault, ParamName, ParamParse},13 source::Source,11 source::Source,12 NumValue,14};13};151416#[derive(Debug, PartialEq, Acyclic)]15#[derive(Debug, PartialEq, Acyclic)]50 pub plus: bool,49 pub plus: bool,51 pub params: Option<ExprParams>,50 pub params: Option<ExprParams>,52 pub visibility: Visibility,51 pub visibility: Visibility,53 pub value: Rc<Expr>,52 pub value: Expr,54}53}555456#[derive(Debug, PartialEq, Acyclic)]55#[derive(Debug, PartialEq, Acyclic)]156#[derive(Debug, PartialEq, Acyclic)]155#[derive(Debug, PartialEq, Acyclic)]157pub struct ExprParam {156pub struct ExprParam {158 pub destruct: Destruct,157 pub destruct: Destruct,159 pub default: Option<Rc<Expr>>,158 pub default: Option<Expr>,160}159}161160162/// Defined function parameters161/// Defined function parameters163#[derive(Debug, Clone, PartialEq, Acyclic)]162#[derive(Debug, PartialEq, Acyclic)]164pub struct ExprParams {163pub struct ExprParams {165 pub exprs: Rc<Vec<ExprParam>>,164 pub exprs: Vec<ExprParam>,166 pub signature: FunctionSignature,165 pub signature: FunctionSignature,167 pub(crate) binds_len: usize,166 pub(crate) binds_len: usize,168}167}191 .collect(),190 .collect(),192 ),191 ),193 binds_len: exprs.iter().map(|v| v.destruct.binds_len()).sum(),192 binds_len: exprs.iter().map(|v| v.destruct.binds_len()).sum(),194 exprs: Rc::new(exprs),193 exprs,195 }194 }196 }195 }197}196}198197199#[derive(Debug, PartialEq, Acyclic)]198#[derive(Debug, PartialEq, Acyclic)]200pub struct ArgsDesc {199pub struct ArgsDesc {201 pub unnamed: Vec<Rc<Expr>>,200 pub unnamed: Vec<Expr>,202 pub names: Vec<IStr>,201 pub names: Vec<IStr>,203 pub values: Vec<Rc<Expr>>,202 pub values: Vec<Expr>,204}203}205impl ArgsDesc {204impl ArgsDesc {206 pub fn new(unnamed: Vec<Rc<Expr>>, names: Vec<IStr>, values: Vec<Rc<Expr>>) -> Self {205 pub fn new(unnamed: Vec<Expr>, names: Vec<IStr>, values: Vec<Expr>) -> Self {207 Self {206 Self {208 unnamed,207 unnamed,209 names,208 names,222221223#[derive(Debug, Clone, PartialEq, Acyclic)]222#[derive(Debug, Clone, PartialEq, Acyclic)]224pub enum Destruct {223pub enum Destruct {225 Full(IStr),224 Full(Spanned<IStr>),226 #[cfg(feature = "exp-destruct")]225 #[cfg(feature = "exp-destruct")]227 Skip,226 Skip,228 #[cfg(feature = "exp-destruct")]227 #[cfg(feature = "exp-destruct")]242 /// Name of destructure, used for function parameter names241 /// Name of destructure, used for function parameter names243 pub fn name(&self) -> ParamName {242 pub fn name(&self) -> ParamName {244 match self {243 match self {245 Self::Full(name) => ParamName::Named(name.clone()),244 Self::Full(name) => ParamName::Named(name.value.clone()),246 #[cfg(feature = "exp-destruct")]245 #[cfg(feature = "exp-destruct")]247 _ => ParamName::Unnamed,246 _ => ParamName::Unnamed,248 }247 }286pub enum BindSpec {285pub enum BindSpec {287 Field {286 Field {288 into: Destruct,287 into: Destruct,289 value: Rc<Expr>,288 value: Expr,290 },289 },291 Function {290 Function {292 name: IStr,291 name: IStr,293 params: ExprParams,292 params: ExprParams,294 value: Rc<Expr>,293 value: Expr,295 },294 },296}295}297impl BindSpec {296impl BindSpec {323322324#[derive(Debug, PartialEq, Acyclic)]323#[derive(Debug, PartialEq, Acyclic)]325pub struct ObjComp {324pub struct ObjComp {326 pub locals: Rc<Vec<BindSpec>>,325 pub locals: Vec<BindSpec>,327 pub field: Rc<FieldMember>,326 pub field: Box<FieldMember>,328 pub compspecs: Vec<CompSpec>,327 pub compspecs: Vec<CompSpec>,329}328}330329331#[derive(Debug, PartialEq, Acyclic)]330#[derive(Debug, PartialEq, Acyclic)]332pub struct ObjMembers {331pub struct ObjMembers {333 pub locals: Rc<Vec<BindSpec>>,332 pub locals: Vec<BindSpec>,334 pub asserts: Rc<Vec<AssertStmt>>,333 pub asserts: Vec<AssertStmt>,335 pub fields: Vec<FieldMember>,334 pub fields: Vec<FieldMember>,336}335}337336371 pub rhs: Expr,370 pub rhs: Expr,372}371}373372374#[derive(Debug, PartialEq, Acyclic)]373#[derive(Debug, PartialEq, Acyclic, Clone, Copy)]375pub enum ImportKind {374pub enum ImportKind {376 Normal,375 Normal,377 Str,376 Str,404 Var(Spanned<IStr>),403 Var(Spanned<IStr>),405404406 /// Array of expressions: [1, 2, "Hello"]405 /// Array of expressions: [1, 2, "Hello"]407 Arr(Rc<Vec<Expr>>),406 Arr(Vec<Expr>),408 /// Array comprehension:407 /// Array comprehension:409 /// ```jsonnet408 /// ```jsonnet410 /// ingredients: [409 /// ingredients: [416 /// ]415 /// ]417 /// ],416 /// ],418 /// ```417 /// ```419 ArrComp(Rc<Expr>, Vec<CompSpec>),418 ArrComp(Box<Expr>, Vec<CompSpec>),420419421 /// Object: {a: 2}420 /// Object: {a: 2}422 Obj(ObjBody),421 Obj(ObjBody),423 /// Object extension: var1 {b: 2}422 /// Object extension: var1 {b: 2}424 ObjExtend(Rc<Expr>, ObjBody),423 ObjExtend(Box<Expr>, ObjBody),425424426 /// -2425 /// -2427 UnaryOp(UnaryOpType, Box<Expr>),426 UnaryOp(UnaryOpType, Box<Expr>),428 /// 2 - 2427 /// 2 - 2429 BinaryOp(Box<BinaryOp>),428 BinaryOp(Box<BinaryOp>),430 /// assert 2 == 2 : "Math is broken"429 /// assert 2 == 2 : "Math is broken"431 AssertExpr(Rc<AssertExpr>),430 AssertExpr(Box<AssertExpr>),432 /// local a = 2; { b: a }431 /// local a = 2; { b: a }433 LocalExpr(Vec<BindSpec>, Box<Expr>),432 LocalExpr(Vec<BindSpec>, Box<Expr>),434433444 parts: Vec<IndexPart>,443 parts: Vec<IndexPart>,445 },444 },446 /// function(x) x445 /// function(x) x447 Function(ExprParams, Rc<Expr>),446 Function(ExprParams, Box<Expr>),448 /// if true == false then 1 else 2447 /// if true == false then 1 else 2449 IfElse(Box<IfElse>),448 IfElse(Box<IfElse>),450 Slice(Box<Slice>),449 Slice(Box<Slice>),crates/jrsonnet-peg-parser/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-peg-parser/src/lib.rs
+++ b/crates/jrsonnet-peg-parser/src/lib.rs
@@ -61,13 +61,13 @@
rule keyword(id: &'static str) -> ()
= #{|input, pos| input.parse_string_literal(pos, id)} end_of_ident()
- pub rule param(s: &ParserSettings) -> ExprParam = destruct:destruct(s) expr:(_ "=" _ expr:expr(s){expr})? { ExprParam { destruct, default: expr.map(Rc::new) } }
+ pub rule param(s: &ParserSettings) -> ExprParam = destruct:destruct(s) default:(_ "=" _ default:expr(s){default})? { ExprParam { destruct, default } }
pub rule params(s: &ParserSettings) -> ExprParams
= params:param(s) ** comma() comma()? { ExprParams::new(params) }
/ { ExprParams::new(Vec::new()) }
- pub rule arg(s: &ParserSettings) -> (Option<IStr>, Rc<Expr>)
- = name:(quiet! { (s:id() _ "=" !['='] _ {s})? } / expected!("<argument name>")) expr:expr(s) {(name, Rc::new(expr))}
+ pub rule arg(s: &ParserSettings) -> (Option<IStr>, Expr)
+ = name:(quiet! { (s:id() _ "=" !['='] _ {s})? } / expected!("<argument name>")) expr:expr(s) {(name, expr)}
pub rule args(s: &ParserSettings) -> ArgsDesc
= args:arg(s)**comma() comma()? {?
@@ -123,7 +123,7 @@
#[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
}
pub rule destruct(s: &ParserSettings) -> Destruct
- = v:id() {Destruct::Full(v)}
+ = v:spanned(<id()>, s) {Destruct::Full(v)}
/ "?" {?
#[cfg(feature = "exp-destruct")] return Ok(Destruct::Skip);
#[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
@@ -132,8 +132,8 @@
/ obj:destruct_object(s) {obj}
pub rule bind(s: &ParserSettings) -> BindSpec
- = into:destruct(s) _ "=" _ value:expr(s) {BindSpec::Field{into, value: Rc::new(value)}}
- / name:id() _ "(" _ params:params(s) _ ")" _ "=" _ value:expr(s) {BindSpec::Function{name, params, value: Rc::new(value)}}
+ = into:destruct(s) _ "=" _ value:expr(s) {BindSpec::Field{into, value}}
+ / name:id() _ "(" _ params:params(s) _ ")" _ "=" _ value:expr(s) {BindSpec::Function{name, params, value}}
pub rule assertion(s: &ParserSettings) -> AssertStmt
= keyword("assert") _ assertion:spanned(<expr(s)>, s) message:(_ ":" _ e:expr(s) {e})? { AssertStmt{assertion, message} }
@@ -187,14 +187,14 @@
plus: plus.is_some(),
params: None,
visibility,
- value: Rc::new(value),
+ value,
}}
/ name:spanned(<field_name(s)>, s) _ "(" _ params:params(s) _ ")" _ visibility:visibility() _ value:expr(s) {FieldMember{
name,
plus: false,
params: Some(params),
visibility,
- value: Rc::new(value),
+ value,
}}
pub rule obj_local(s: &ParserSettings) -> BindSpec
= keyword("local") _ bind:bind(s) {bind}
@@ -217,8 +217,8 @@
}
}
ObjBody::ObjComp(ObjComp {
- locals: Rc::new(locals),
- field: field.map(Rc::new).ok_or("<missing object comprehension field>")?,
+ locals,
+ field: Box::new(field.ok_or("<missing object comprehension field>")?),
compspecs
})
} else {
@@ -233,8 +233,8 @@
}
}
ObjBody::MemberList(ObjMembers {
- locals: Rc::new(locals),
- asserts: Rc::new(asserts),
+ locals,
+ asserts,
fields
})
})
@@ -259,10 +259,10 @@
pub rule obj_expr(s: &ParserSettings) -> Expr
= "{" _ body:objinside(s) _ "}" {Expr::Obj(body)}
pub rule array_expr(s: &ParserSettings) -> Expr
- = "[" _ elems:(expr(s) ** comma()) _ comma()? "]" {Expr::Arr(Rc::new(elems))}
+ = "[" _ elems:(expr(s) ** comma()) _ comma()? "]" {Expr::Arr(elems)}
pub rule array_comp_expr(s: &ParserSettings) -> Expr
= "[" _ expr:expr(s) _ comma()? _ specs:(r: compspecs(s) _ {r}) "]" {
- Expr::ArrComp(Rc::new(expr), specs)
+ Expr::ArrComp(Box::new(expr), specs)
}
pub rule number_expr(s: &ParserSettings) -> Expr
= n:number() {? if let Some(n) = NumValue::new(n) {
@@ -315,8 +315,8 @@
/ local_expr(s)
/ if_then_else_expr(s)
- / keyword("function") _ "(" _ params:params(s) _ ")" _ expr:expr(s) {Expr::Function(params, Rc::new(expr))}
- / assert:assertion(s) _ ";" _ rest:expr(s) { Expr::AssertExpr(Rc::new(AssertExpr{
+ / keyword("function") _ "(" _ params:params(s) _ ")" _ expr:expr(s) {Expr::Function(params, Box::new(expr))}
+ / assert:assertion(s) _ ";" _ rest:expr(s) { Expr::AssertExpr(Box::new(AssertExpr{
assert, rest
})) }
@@ -390,7 +390,7 @@
value:(@) _ "[" _ slice:slice_desc(s) _ "]" {Expr::Slice(Box::new(Slice{value, slice}))}
indexable:(@) _ parts:index_part(s)+ {Expr::Index{indexable: Box::new(indexable), parts}}
a:(@) _ args:spanned(<"(" _ a:args(s) _ ")" {a}>, s) ts:(_ keyword("tailstrict"))? {Expr::Apply(Box::new(a), args, ts.is_some())}
- a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(Rc::new(a), body)}
+ a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(Box::new(a), body)}
--
e:expr_basic(s) {e}
"(" _ e:expr(s) _ ")" {e}
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@array_comp.jsonnet.snapdiffbeforeafterboth--- a/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@array_comp.jsonnet.snap
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@array_comp.jsonnet.snap
@@ -35,7 +35,7 @@
ForSpec(
ForSpecData {
destruct: Full(
- "x",
+ "x" from virtual:<test>:23-24,
),
over: Var(
"arr" from virtual:<test>:28-31,
@@ -52,7 +52,7 @@
ForSpec(
ForSpecData {
destruct: Full(
- "a",
+ "a" from virtual:<test>:41-42,
),
over: Var(
"b" from virtual:<test>:46-47,
@@ -70,7 +70,7 @@
ForSpec(
ForSpecData {
destruct: Full(
- "e",
+ "e" from virtual:<test>:57-58,
),
over: Var(
"f" from virtual:<test>:62-63,
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@default_nondefault.jsonnet.snapdiffbeforeafterboth--- a/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@default_nondefault.jsonnet.snap
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@default_nondefault.jsonnet.snap
@@ -11,7 +11,7 @@
exprs: [
ExprParam {
destruct: Full(
- "foo",
+ "foo" from virtual:<test>:8-11,
),
default: Some(
Str(
@@ -21,7 +21,7 @@
},
ExprParam {
destruct: Full(
- "bar",
+ "bar" from virtual:<test>:21-24,
),
default: None,
},
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@subexp.jsonnet.snapdiffbeforeafterboth--- a/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@subexp.jsonnet.snap
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__snapshots@subexp.jsonnet.snap
@@ -20,7 +20,7 @@
locals: [
Field {
into: Full(
- "x",
+ "x" from virtual:<test>:11-12,
),
value: Num(
1.0,