git.delta.rocks / jrsonnet / refs/commits / 44f6e2c9e550

difftreelog

refactor split peg parser and ir

kzvrllptYaroslav Bolyukin2026-03-22parent: #1ddb92c.patch.diff
in: master

109 files changed

modifiedCargo.lockdiffbeforeafterboth
609 "jrsonnet-cli",609 "jrsonnet-cli",
610 "jrsonnet-evaluator",610 "jrsonnet-evaluator",
611 "jrsonnet-gcmodule",611 "jrsonnet-gcmodule",
612 "jrsonnet-parser",612 "jrsonnet-ir",
613 "mimallocator",613 "mimallocator",
614 "serde",614 "serde",
615 "serde_json",615 "serde_json",
623 "clap",623 "clap",
624 "jrsonnet-evaluator",624 "jrsonnet-evaluator",
625 "jrsonnet-gcmodule",625 "jrsonnet-gcmodule",
626 "jrsonnet-parser",626 "jrsonnet-ir",
627 "jrsonnet-stdlib",627 "jrsonnet-stdlib",
628]628]
629629
637 "hi-doc",637 "hi-doc",
638 "jrsonnet-gcmodule",638 "jrsonnet-gcmodule",
639 "jrsonnet-interner",639 "jrsonnet-interner",
640 "jrsonnet-ir",
640 "jrsonnet-macros",641 "jrsonnet-macros",
641 "jrsonnet-parser",642 "jrsonnet-peg-parser",
642 "jrsonnet-types",643 "jrsonnet-types",
643 "num-bigint",644 "num-bigint",
644 "pathdiff",645 "pathdiff",
703 "rustc-hash 2.1.1",704 "rustc-hash 2.1.1",
704]705]
706
707[[package]]
708name = "jrsonnet-ir"
709version = "0.5.0-pre97"
710dependencies = [
711 "insta",
712 "jrsonnet-gcmodule",
713 "jrsonnet-interner",
714 "peg",
715 "static_assertions",
716]
705717
706[[package]]718[[package]]
707name = "jrsonnet-macros"719name = "jrsonnet-macros"
714]726]
715727
716[[package]]728[[package]]
717name = "jrsonnet-parser"729name = "jrsonnet-peg-parser"
718version = "0.5.0-pre97"730version = "0.5.0-pre97"
719dependencies = [731dependencies = [
720 "insta",732 "insta",
721 "jrsonnet-gcmodule",
722 "jrsonnet-interner",733 "jrsonnet-ir",
723 "peg",734 "peg",
724 "static_assertions",
725]735]
726736
727[[package]]737[[package]]
746 "base64",756 "base64",
747 "jrsonnet-evaluator",757 "jrsonnet-evaluator",
748 "jrsonnet-gcmodule",758 "jrsonnet-gcmodule",
759 "jrsonnet-ir",
749 "jrsonnet-macros",760 "jrsonnet-macros",
750 "jrsonnet-parser",
751 "lru",761 "lru",
752 "md5",762 "md5",
753 "num-bigint",763 "num-bigint",
812 "jrsonnet-evaluator",822 "jrsonnet-evaluator",
813 "jrsonnet-gcmodule",823 "jrsonnet-gcmodule",
814 "jrsonnet-interner",824 "jrsonnet-interner",
815 "jrsonnet-parser",825 "jrsonnet-ir",
816 "jrsonnet-stdlib",826 "jrsonnet-stdlib",
817]827]
818828
modifiedCargo.tomldiffbeforeafterboth
13[workspace.dependencies]13[workspace.dependencies]
14jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0-pre97" }14jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0-pre97" }
15jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0-pre97" }15jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0-pre97" }
16jrsonnet-ir = { path = "./crates/jrsonnet-ir", version = "0.5.0-pre97" }
16jrsonnet-parser = { path = "./crates/jrsonnet-parser", version = "0.5.0-pre97" }17jrsonnet-peg-parser = { path = "./crates/jrsonnet-peg-parser", version = "0.5.0-pre97" }
17jrsonnet-rowan-parser = { path = "./crates/jrsonnet-rowan-parser", version = "0.5.0-pre97" }18jrsonnet-rowan-parser = { path = "./crates/jrsonnet-rowan-parser", version = "0.5.0-pre97" }
18jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0-pre97" }19jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0-pre97" }
19jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", version = "0.5.0-pre97" }20jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", version = "0.5.0-pre97" }
modifiedbindings/jsonnet/Cargo.tomldiffbeforeafterboth
2020
21[dependencies]21[dependencies]
22jrsonnet-evaluator.workspace = true22jrsonnet-evaluator.workspace = true
23jrsonnet-parser.workspace = true23jrsonnet-ir.workspace = true
24jrsonnet-stdlib.workspace = true24jrsonnet-stdlib.workspace = true
25jrsonnet-gcmodule.workspace = true25jrsonnet-gcmodule.workspace = true
26jrsonnet-interner.workspace = true26jrsonnet-interner.workspace = true
modifiedbindings/jsonnet/src/import.rsdiffbeforeafterboth
17 AsPathLike, ImportResolver, ResolvePath,17 AsPathLike, ImportResolver, ResolvePath,
18};18};
19use jrsonnet_gcmodule::Acyclic;19use jrsonnet_gcmodule::Acyclic;
20use jrsonnet_parser::{SourceDirectory, SourceFile, SourcePath};20use jrsonnet_ir::{SourceDirectory, SourceFile, SourcePath};
2121
22use crate::VM;22use crate::VM;
2323
modifiedbindings/jsonnet/src/lib.rsdiffbeforeafterboth
31 AsPathLike, FileImportResolver, IStr, ImportResolver, Result, State, Val,31 AsPathLike, FileImportResolver, IStr, ImportResolver, Result, State, Val,
32};32};
33use jrsonnet_gcmodule::Acyclic;33use jrsonnet_gcmodule::Acyclic;
34use jrsonnet_parser::SourcePath;34use jrsonnet_ir::SourcePath;
35use jrsonnet_stdlib::ContextInitializer;35use jrsonnet_stdlib::ContextInitializer;
3636
37/// WASM stub37/// WASM stub
modifiedcmds/jrsonnet/Cargo.tomldiffbeforeafterboth
37# obj?.field, obj?.['field']37# obj?.field, obj?.['field']
38exp-null-coaelse = [38exp-null-coaelse = [
39 "jrsonnet-evaluator/exp-null-coaelse",39 "jrsonnet-evaluator/exp-null-coaelse",
40 "jrsonnet-parser/exp-null-coaelse",40 "jrsonnet-ir/exp-null-coaelse",
41 "jrsonnet-cli/exp-null-coaelse",41 "jrsonnet-cli/exp-null-coaelse",
42]42]
43# --exp-apply43# --exp-apply
44exp-apply = []44exp-apply = []
4545
46[dependencies]46[dependencies]
47jrsonnet-evaluator.workspace = true47jrsonnet-evaluator.workspace = true
48jrsonnet-parser.workspace = true48jrsonnet-ir.workspace = true
49jrsonnet-cli.workspace = true49jrsonnet-cli.workspace = true
50jrsonnet-gcmodule.workspace = true50jrsonnet-gcmodule.workspace = true
5151
modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
11 error::{Error as JrError, ErrorKind},11 error::{Error as JrError, ErrorKind},
12 ResultExt, State, Val,12 ResultExt, State, Val,
13};13};
14use jrsonnet_parser::{SourceDefaultIgnoreJpath, SourcePath};14use jrsonnet_ir::{SourceDefaultIgnoreJpath, SourcePath};
1515
16#[cfg(feature = "mimalloc")]16#[cfg(feature = "mimalloc")]
17#[global_allocator]17#[global_allocator]
modifiedcrates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth
2929
30[dependencies]30[dependencies]
31jrsonnet-evaluator = { workspace = true, features = ["explaining-traces"] }31jrsonnet-evaluator = { workspace = true, features = ["explaining-traces"] }
32jrsonnet-parser.workspace = true32jrsonnet-ir.workspace = true
33jrsonnet-stdlib.workspace = true33jrsonnet-stdlib.workspace = true
34jrsonnet-gcmodule.workspace = true34jrsonnet-gcmodule.workspace = true
3535
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
22# Allows to preserve field order in objects22# Allows to preserve field order in objects
23exp-preserve-order = []23exp-preserve-order = []
24# Implements field destructuring24# Implements field destructuring
25exp-destruct = ["jrsonnet-parser/exp-destruct"]25exp-destruct = ["jrsonnet-peg-parser/exp-destruct"]
26# Iteration over objects yields [key, value] elements26# Iteration over objects yields [key, value] elements
27exp-object-iteration = []27exp-object-iteration = []
28# Bigint type28# Bigint type
29exp-bigint = ["num-bigint", "jrsonnet-types/exp-bigint"]29exp-bigint = ["num-bigint", "jrsonnet-types/exp-bigint"]
30# obj?.field, obj?.['field']30# obj?.field, obj?.['field']
31exp-null-coaelse = ["jrsonnet-parser/exp-null-coaelse"]31exp-null-coaelse = ["jrsonnet-peg-parser/exp-null-coaelse"]
3232
33[dependencies]33[dependencies]
34jrsonnet-interner.workspace = true34jrsonnet-interner.workspace = true
35jrsonnet-parser.workspace = true35jrsonnet-ir.workspace = true
36jrsonnet-peg-parser.workspace = true
36jrsonnet-types.workspace = true37jrsonnet-types.workspace = true
37jrsonnet-macros.workspace = true38jrsonnet-macros.workspace = true
38jrsonnet-gcmodule.workspace = true39jrsonnet-gcmodule.workspace = true
modifiedcrates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth
77
8use jrsonnet_gcmodule::{cc_dyn, Cc};8use jrsonnet_gcmodule::{cc_dyn, Cc};
9use jrsonnet_interner::IBytes;9use jrsonnet_interner::IBytes;
10use jrsonnet_parser::{Expr, Spanned};10use jrsonnet_ir::{Expr, Spanned};
1111
12use crate::{function::NativeFn, Context, Result, Thunk, Val};12use crate::{function::NativeFn, Context, Result, Thunk, Val};
1313
8585
86 pub fn extended(a: Self, b: Self) -> Self {86 pub fn extended(a: Self, b: Self) -> Self {
87 // TODO: benchmark for an optimal value, currently just a arbitrary choice87 // TODO: benchmark for an optimal value, currently just a arbitrary choice
88 const ARR_EXTEND_THRESHOLD: usize = 100;88 const ARR_EXTEND_THRESHOLD: usize = 1000;
8989
90 if a.is_empty() {90 if a.is_empty() {
91 b91 b
modifiedcrates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth
33
4use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_gcmodule::{Cc, Trace};
5use jrsonnet_interner::{IBytes, IStr};5use jrsonnet_interner::{IBytes, IStr};
6use jrsonnet_parser::{Expr, Spanned};6use jrsonnet_ir::{Expr, Spanned};
77
8use super::ArrValue;8use super::ArrValue;
9use crate::function::NativeFn;9use crate::function::NativeFn;
modifiedcrates/jrsonnet-evaluator/src/async_import.rsdiffbeforeafterboth
2use std::{any::Any, cell::RefCell, future::Future};2use std::{any::Any, cell::RefCell, future::Future};
33
4use jrsonnet_gcmodule::Acyclic;4use jrsonnet_gcmodule::Acyclic;
5use jrsonnet_parser::{5use jrsonnet_ir::{
6 ArgsDesc, AssertExpr, AssertStmt, BindSpec, CompSpec, Destruct, Expr, ExprParam, ExprParams,6 ArgsDesc, AssertExpr, AssertStmt, BindSpec, CompSpec, Destruct, Expr, ExprParam, ExprParams,
7 FieldMember, FieldName, ForSpecData, IfElse, IfSpecData, ImportKind, ObjBody, ParserSettings,7 FieldMember, FieldName, ForSpecData, IfElse, IfSpecData, ImportKind, ObjBody, Slice, SliceDesc,
8 Slice, SliceDesc, Source, SourcePath, Spanned,8 Source, SourcePath, Spanned,
9};9};
10use jrsonnet_peg_parser::ParserSettings;
10use rustc_hash::FxHashMap;11use rustc_hash::FxHashMap;
1112
12use crate::{AsPathLike, FileData, ImportResolver, ResolvePathOwned, State};13use crate::{AsPathLike, FileData, ImportResolver, ResolvePathOwned, State};
322 };323 };
323 let source = Source::new(path.clone(), code.clone());324 let source = Source::new(path.clone(), code.clone());
324 // If failed - then skip import325 // If failed - then skip import
325 file.parsed = jrsonnet_parser::parse(&code, &ParserSettings { source })326 file.parsed = jrsonnet_peg_parser::parse(&code, &ParserSettings { source })
326 .map(Rc::new)327 .map(Rc::new)
327 .ok();328 .ok();
328 if let Some(parsed) = &file.parsed {329 if let Some(parsed) = &file.parsed {
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
22
3use jrsonnet_gcmodule::{Acyclic, Trace};3use jrsonnet_gcmodule::{Acyclic, Trace};
4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;
5use jrsonnet_parser::{BinaryOpType, Source, SourcePath, Span, Spanned, UnaryOpType};5use jrsonnet_ir::{BinaryOpType, Source, SourcePath, Span, Spanned, UnaryOpType};
6use jrsonnet_types::ValType;6use jrsonnet_types::ValType;
7use thiserror::Error;7use thiserror::Error;
88
169 ImportSyntaxError {169 ImportSyntaxError {
170 path: Source,170 path: Source,
171 #[trace(skip)]171 #[trace(skip)]
172 error: Box<jrsonnet_parser::ParseError>,172 error: Box<jrsonnet_peg_parser::ParseError>,
173 },173 },
174174
175 #[error("runtime error: {}", format_empty_str(.0))]175 #[error("runtime error: {}", format_empty_str(.0))]
modifiedcrates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth
1use std::{collections::HashMap, hash::BuildHasher};1use std::{collections::HashMap, hash::BuildHasher};
22
3use jrsonnet_interner::IStr;3use jrsonnet_interner::IStr;
4use jrsonnet_parser::{BindSpec, Destruct};4use jrsonnet_ir::{BindSpec, Destruct};
55
6use crate::{6use crate::{
7 bail,7 bail,
31 Destruct::Skip => {}31 Destruct::Skip => {}
32 #[cfg(feature = "exp-destruct")]32 #[cfg(feature = "exp-destruct")]
33 Destruct::Array { start, rest, end } => {33 Destruct::Array { start, rest, end } => {
34 use jrsonnet_parser::DestructRest;34 use jrsonnet_ir::DestructRest;
3535
36 let min_len = start.len() + end.len();36 let min_len = start.len() + end.len();
37 let has_rest = rest.is_some();37 let has_rest = rest.is_some();
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
22
3use jrsonnet_gcmodule::{Cc, Trace};3use jrsonnet_gcmodule::{Cc, Trace};
4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;
5use jrsonnet_parser::{5use jrsonnet_ir::{
6 function::ParamName, ArgsDesc, AssertStmt, BinaryOpType, BindSpec, CompSpec, Expr, ExprParams,6 function::ParamName, ArgsDesc, AssertStmt, BinaryOpType, BindSpec, CompSpec, Expr, ExprParams,
7 FieldMember, FieldName, ForSpecData, IfSpecData, ImportKind, LiteralType, ObjBody, ObjMembers,7 FieldMember, FieldName, ForSpecData, IfSpecData, ImportKind, LiteralType, ObjBody, ObjMembers,
8 Spanned,8 Spanned,
47 stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)47 stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)
48}48}
4949
50pub fn evaluate_trivial(expr: &Spanned<Expr>) -> Option<Val> {50pub fn evaluate_trivial(expr: &Expr) -> Option<Val> {
51 fn is_trivial(expr: &Spanned<Expr>) -> bool {51 fn is_trivial(expr: &Expr) -> bool {
52 match &**expr {52 match &*expr {
53 Expr::Str(_)53 Expr::Str(_)
54 | Expr::Num(_)54 | Expr::Num(_)
55 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,55 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,
56 Expr::Arr(a) => a.iter().all(is_trivial),56 Expr::Arr(a) => a.iter().all(|e| is_trivial(&**e)),
57 _ => false,57 _ => false,
58 }58 }
59 }59 }
60 Some(match &**expr {60 Some(match &*expr {
61 Expr::Str(s) => Val::string(s.clone()),61 Expr::Str(s) => Val::string(s.clone()),
62 Expr::Num(n) => {62 Expr::Num(n) => {
63 Val::Num(NumValue::new(*n).expect("parser will not allow non-finite values"))63 Val::Num(NumValue::new(*n).expect("parser will not allow non-finite values"))
71 }71 }
72 Val::Arr(ArrValue::eager(72 Val::Arr(ArrValue::eager(
73 n.iter()73 n.iter()
74 .map(evaluate_trivial)74 .map(|e| evaluate_trivial(&**e))
75 .map(|e| e.expect("checked trivial"))75 .map(|e| e.expect("checked trivial"))
76 .collect(),76 .collect(),
77 ))77 ))
395}395}
396396
397#[allow(clippy::too_many_lines)]397#[allow(clippy::too_many_lines)]
398pub fn evaluate(ctx: Context, expr: &Spanned<Expr>) -> Result<Val> {398pub fn evaluate(ctx: Context, expr: &Expr) -> Result<Val> {
399 use Expr::*;399 use Expr::*;
400400
401 if let Some(trivial) = evaluate_trivial(expr) {401 if let Some(trivial) = evaluate_trivial(expr) {
402 return Ok(trivial);402 return Ok(trivial);
403 }403 }
404 let loc = expr.span();
405 Ok(match &**expr {404 Ok(match expr {
406 Literal(LiteralType::This) => Val::Obj(ctx.try_this()?),405 Literal(LiteralType::This) => Val::Obj(ctx.try_this()?),
407 Literal(LiteralType::Super) => Val::Obj(ctx.try_sup_this()?.standalone_super()?),406 Literal(LiteralType::Super) => Val::Obj(ctx.try_sup_this()?.standalone_super()?),
408 Literal(LiteralType::Dollar) => Val::Obj(ctx.try_dollar()?),407 Literal(LiteralType::Dollar) => Val::Obj(ctx.try_dollar()?),
433 BinaryOp(bin) => evaluate_binary_op_special(ctx, &bin.lhs, bin.op, &bin.rhs)?,432 BinaryOp(bin) => evaluate_binary_op_special(ctx, &bin.lhs, bin.op, &bin.rhs)?,
434 UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(ctx, v)?)?,433 UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(ctx, v)?)?,
435 Var(name) => in_frame(434 Var(name) => in_frame(
436 CallLocation::new(&loc),435 CallLocation::new(&name.span()),
437 || format!("local <{name}> access"),436 || format!("local <{name}> access"),
438 || ctx.binding(name.clone())?.evaluate(),437 || ctx.binding((**name).clone())?.evaluate(),
439 )?,438 )?,
440 Index { indexable, parts } => ensure_sufficient_stack(|| {439 Index { indexable, parts } => ensure_sufficient_stack(|| {
441 let mut parts = parts.iter();440 let mut parts = parts.iter();
591 &Val::Obj(evaluate_object(ctx, b)?),590 &Val::Obj(evaluate_object(ctx, b)?),
592 )?,591 )?,
593 Apply(value, args, tailstrict) => ensure_sufficient_stack(|| {592 Apply(value, args, tailstrict) => ensure_sufficient_stack(|| {
594 evaluate_apply(ctx, value, args, CallLocation::new(&loc), *tailstrict)593 evaluate_apply(
594 ctx,
595 value,
596 args,
597 CallLocation::new(&args.span()),
598 *tailstrict,
599 )
595 })?,600 })?,
601 evaluate(ctx, &assert.rest)?606 evaluate(ctx, &assert.rest)?
602 }607 }
603 ErrorStmt(e) => in_frame(608 ErrorStmt(e) => in_frame(
604 CallLocation::new(&loc),609 CallLocation::new(&e.span()),
605 || "error statement".to_owned(),610 || "error statement".to_owned(),
606 || bail!(RuntimeError(evaluate(ctx, e)?.to_string()?,)),611 || bail!(RuntimeError(evaluate(ctx, e)?.to_string()?,)),
607 )?,612 )?,
608 IfElse(if_else) => {613 IfElse(if_else) => {
609 if in_frame(614 if in_frame(
610 CallLocation::new(&loc),615 CallLocation::new(&if_else.cond.0.span()),
611 || "if condition".to_owned(),616 || "if condition".to_owned(),
612 || bool::from_untyped(evaluate(ctx.clone(), &if_else.cond.0)?),617 || bool::from_untyped(evaluate(ctx.clone(), &if_else.cond.0)?),
613 )? {618 )? {
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
1use std::cmp::Ordering;1use std::cmp::Ordering;
22
3use jrsonnet_parser::{BinaryOpType, Expr, Spanned, UnaryOpType};3use jrsonnet_ir::{BinaryOpType, Expr, Spanned, UnaryOpType};
44
5use crate::{5use crate::{
6 arr::ArrValue,6 arr::ArrValue,
modifiedcrates/jrsonnet-evaluator/src/function/builtin.rsdiffbeforeafterboth
1use std::any::Any;1use std::any::Any;
22
3use jrsonnet_gcmodule::{cc_dyn, Trace, TraceBox};3use jrsonnet_gcmodule::{cc_dyn, Trace, TraceBox};
4use jrsonnet_parser::function::{FunctionSignature, ParamDefault, ParamName, ParamParse};4use jrsonnet_ir::function::{FunctionSignature, ParamDefault, ParamName, ParamParse};
55
6use super::CallLocation;6use super::CallLocation;
7use crate::{Result, Thunk, Val};7use crate::{Result, Thunk, Val};
modifiedcrates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth
4use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_gcmodule::{Cc, Trace};
5use jrsonnet_interner::IStr;5use jrsonnet_interner::IStr;
6pub use jrsonnet_macros::builtin;6pub use jrsonnet_macros::builtin;
7use jrsonnet_parser::{ArgsDesc, Destruct, Expr, ExprParams, Span, Spanned};7use jrsonnet_ir::{ArgsDesc, Destruct, Expr, ExprParams, Span, Spanned};
88
9use self::{9use self::{
10 builtin::{Builtin, StaticBuiltin},10 builtin::{Builtin, StaticBuiltin},
24pub use native::NativeFn;24pub use native::NativeFn;
25pub use prepared::PreparedFuncVal;25pub use prepared::PreparedFuncVal;
2626
27pub use jrsonnet_parser::function::*;27pub use jrsonnet_ir::function::*;
2828
29/// Function callsite location.29/// Function callsite location.
30/// Either from other jsonnet code, specified by expression location, or from native (without location).30/// Either from other jsonnet code, specified by expression location, or from native (without location).
modifiedcrates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth
1use std::rc::Rc;1use std::rc::Rc;
22
3use jrsonnet_parser::{3use jrsonnet_ir::{
4 function::{FunctionSignature, ParamName},4 function::{FunctionSignature, ParamName},
5 ArgsDesc, Expr, ExprParams, Spanned,5 ArgsDesc, Expr, ExprParams, Spanned,
6};6};
modifiedcrates/jrsonnet-evaluator/src/function/prepared.rsdiffbeforeafterboth
1use std::rc::Rc;1use std::rc::Rc;
22
3use jrsonnet_gcmodule::{Acyclic, Trace};3use jrsonnet_gcmodule::{Acyclic, Trace};
4use jrsonnet_parser::function::FunctionSignature;4use jrsonnet_ir::function::FunctionSignature;
5use jrsonnet_parser::{ExprParams, IStr};5use jrsonnet_ir::{ExprParams, IStr};
6use rustc_hash::{FxHashMap, FxHashSet};6use rustc_hash::{FxHashMap, FxHashSet};
77
8use crate::destructure::destruct;8use crate::destructure::destruct;
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
10use fs::File;10use fs::File;
11use jrsonnet_gcmodule::Acyclic;11use jrsonnet_gcmodule::Acyclic;
12use jrsonnet_interner::IBytes;12use jrsonnet_interner::IBytes;
13use jrsonnet_parser::{13use jrsonnet_ir::{
14 IStr, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,14 IStr, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,
15};15};
1616
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
44pub use jrsonnet_interner::{IBytes, IStr};44pub use jrsonnet_interner::{IBytes, IStr};
45#[doc(hidden)]45#[doc(hidden)]
46pub use jrsonnet_macros;46pub use jrsonnet_macros;
47pub use jrsonnet_parser as parser;47pub use jrsonnet_ir as parser;
48use jrsonnet_parser::{Expr, ParserSettings, Source, SourcePath, Spanned};48use jrsonnet_ir::{Expr, Source, SourcePath, Spanned};
49use jrsonnet_peg_parser::ParserSettings;
49pub use obj::*;50pub use obj::*;
50pub use rustc_hash;51pub use rustc_hash;
51use rustc_hash::FxHashMap;52use rustc_hash::FxHashMap;
344 let file_name = Source::new(path.clone(), code.clone());345 let file_name = Source::new(path.clone(), code.clone());
345 if file.parsed.is_none() {346 if file.parsed.is_none() {
346 file.parsed = Some(347 file.parsed = Some(
347 jrsonnet_parser::parse(348 jrsonnet_peg_parser::parse(
348 &code,349 &code,
349 &ParserSettings {350 &ParserSettings {
350 source: file_name.clone(),351 source: file_name.clone(),
460 pub fn evaluate_snippet(&self, name: impl Into<IStr>, code: impl Into<IStr>) -> Result<Val> {461 pub fn evaluate_snippet(&self, name: impl Into<IStr>, code: impl Into<IStr>) -> Result<Val> {
461 let code = code.into();462 let code = code.into();
462 let source = Source::new_virtual(name.into(), code.clone());463 let source = Source::new_virtual(name.into(), code.clone());
463 let parsed = jrsonnet_parser::parse(464 let parsed = jrsonnet_peg_parser::parse(
464 &code,465 &code,
465 &ParserSettings {466 &ParserSettings {
466 source: source.clone(),467 source: source.clone(),
481 ) -> Result<Val> {482 ) -> Result<Val> {
482 let code = code.into();483 let code = code.into();
483 let source = Source::new_virtual(name.into(), code.clone());484 let source = Source::new_virtual(name.into(), code.clone());
484 let parsed = jrsonnet_parser::parse(485 let parsed = jrsonnet_peg_parser::parse(
485 &code,486 &code,
486 &ParserSettings {487 &ParserSettings {
487 source: source.clone(),488 source: source.clone(),
modifiedcrates/jrsonnet-evaluator/src/obj/mod.rsdiffbeforeafterboth
5use educe::Educe;5use educe::Educe;
6use jrsonnet_gcmodule::{cc_dyn, Acyclic, Cc, Trace, Weak};6use jrsonnet_gcmodule::{cc_dyn, Acyclic, Cc, Trace, Weak};
7use jrsonnet_interner::IStr;7use jrsonnet_interner::IStr;
8use jrsonnet_parser::Span;8use jrsonnet_ir::Span;
9use rustc_hash::{FxHashMap, FxHashSet};9use rustc_hash::{FxHashMap, FxHashSet};
1010
11mod oop;11mod oop;
1212
13pub use jrsonnet_parser::Visibility;13pub use jrsonnet_ir::Visibility;
14pub use oop::ObjValueBuilder;14pub use oop::ObjValueBuilder;
1515
16use crate::{16use crate::{
modifiedcrates/jrsonnet-evaluator/src/obj/oop.rsdiffbeforeafterboth
8 bail, error::ErrorKind::*, in_frame, CcUnbound, MaybeUnbound, Result, Thunk, Unbound, Val,8 bail, error::ErrorKind::*, in_frame, CcUnbound, MaybeUnbound, Result, Thunk, Unbound, Val,
9};9};
10use jrsonnet_gcmodule::{Cc, Trace};10use jrsonnet_gcmodule::{Cc, Trace};
11use jrsonnet_parser::IStr;11use jrsonnet_ir::IStr;
12use rustc_hash::{FxHashMap, FxHashSet};12use rustc_hash::{FxHashMap, FxHashSet};
1313
14use super::ordering::{FieldIndex, SuperDepth};14use super::ordering::{FieldIndex, SuperDepth};
modifiedcrates/jrsonnet-evaluator/src/tla.rsdiffbeforeafterboth
22
3use jrsonnet_gcmodule::Trace;3use jrsonnet_gcmodule::Trace;
4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;
5use jrsonnet_parser::{SourceFifo, SourcePath};5use jrsonnet_ir::{SourceFifo, SourcePath};
66
7use crate::{7use crate::{
8 function::{CallLocation, PreparedFuncVal},8 function::{CallLocation, PreparedFuncVal},
modifiedcrates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth
6};6};
77
8use jrsonnet_gcmodule::Trace;8use jrsonnet_gcmodule::Trace;
9use jrsonnet_parser::CodeLocation;9use jrsonnet_ir::CodeLocation;
10#[cfg(feature = "explaining-traces")]10#[cfg(feature = "explaining-traces")]
11use jrsonnet_parser::Span;11use jrsonnet_ir::Span;
1212
13use crate::{error::ErrorKind, Error};13use crate::{error::ErrorKind, Error};
1414
modifiedcrates/jrsonnet-formatter/src/lib.rsdiffbeforeafterboth
855}855}
856856
857pub struct FormatOptions {857pub struct FormatOptions {
858 // 0 for hard tabs858 // 0 for hard tabs, otherwise number of spaces
859 pub indent: u8,859 pub indent: u8,
860}860}
861861
addedcrates/jrsonnet-ir/Cargo.tomldiffbeforeafterboth

no changes

addedcrates/jrsonnet-ir/README.adocdiffbeforeafterboth

no changes

addedcrates/jrsonnet-ir/src/expr.rsdiffbeforeafterboth

no changes

addedcrates/jrsonnet-ir/src/function.rsdiffbeforeafterboth

no changes

addedcrates/jrsonnet-ir/src/lib.rsdiffbeforeafterboth

no changes

addedcrates/jrsonnet-ir/src/location.rsdiffbeforeafterboth

no changes

addedcrates/jrsonnet-ir/src/source.rsdiffbeforeafterboth

no changes

addedcrates/jrsonnet-ir/src/unescape.rsdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/README.adocdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/function.rsdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/location.rsdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__add_location_info_to_all_sub_expressions.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_comp.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_test_error.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-3.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-4.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__default_param_before_nondefault.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__double_negation.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__empty_object.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-3.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__missing_newline_between_comment_and_eof.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-3.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-4.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiple_args_buf.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-3.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-4.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-5.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-3.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_unescaping.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_verbantim.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-2.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-3.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-4.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix.snapdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/source.rsdiffbeforeafterboth

no changes

deletedcrates/jrsonnet-parser/src/unescape.rsdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/Cargo.tomldiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/lib.rsdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__add_location_info_to_all_sub_expressions.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_comp.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_test_error.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__basic_math.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__default_param_before_nondefault.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__double_negation.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__empty_object.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__imports.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__infix_precedence.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__missing_newline_between_comment_and_eof.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiline_string.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiple_args_buf.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__reserved.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__slice.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_escaping.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_unescaping.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_verbantim.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__suffix.snapdiffbeforeafterboth

no changes

modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
16# Bigint type16# Bigint type
17exp-bigint = ["dep:num-bigint", "jrsonnet-evaluator/exp-bigint"]17exp-bigint = ["dep:num-bigint", "jrsonnet-evaluator/exp-bigint"]
1818
19exp-null-coaelse = ["jrsonnet-parser/exp-null-coaelse", "jrsonnet-evaluator/exp-null-coaelse"]19exp-null-coaelse = [
20 "jrsonnet-ir/exp-null-coaelse",
21 "jrsonnet-evaluator/exp-null-coaelse",
22]
20# std.regexMatch and other helpers23# std.regexMatch and other helpers
21exp-regex = ["dep:regex", "dep:lru", "dep:rustc-hash"]24exp-regex = ["dep:regex", "dep:lru", "dep:rustc-hash"]
2225
23[dependencies]26[dependencies]
24jrsonnet-evaluator.workspace = true27jrsonnet-evaluator.workspace = true
25jrsonnet-macros.workspace = true28jrsonnet-macros.workspace = true
26jrsonnet-parser.workspace = true29jrsonnet-ir.workspace = true
27jrsonnet-gcmodule.workspace = true30jrsonnet-gcmodule.workspace = true
2831
29# Used for std.parseJson/std.parseYaml32# Used for std.parseJson/std.parseYaml
51lru = { workspace = true, optional = true }54lru = { workspace = true, optional = true }
52rustc-hash = { workspace = true, optional = true }55rustc-hash = { workspace = true, optional = true }
53
54[build-dependencies]
55jrsonnet-parser.workspace = true
5656
addedcrates/jrsonnet-stdlib/resultdiffbeforeafterboth

no changes

modifiedcrates/jrsonnet-stdlib/src/compat.rsdiffbeforeafterboth
8#[allow(non_snake_case)]8#[allow(non_snake_case)]
9pub fn builtin___compare(v1: Val, v2: Val) -> Result<i32> {9pub fn builtin___compare(v1: Val, v2: Val) -> Result<i32> {
10 Ok(10 Ok(
11 match evaluate_compare_op(&v1, &v2, jrsonnet_parser::BinaryOpType::Lt)? {11 match evaluate_compare_op(&v1, &v2, jrsonnet_ir::BinaryOpType::Lt)? {
12 Ordering::Less => -1,12 Ordering::Less => -1,
13 Ordering::Equal => 0,13 Ordering::Equal => 0,
14 Ordering::Greater => 1,14 Ordering::Greater => 1,
30 let ordering = evaluate_compare_op(30 let ordering = evaluate_compare_op(
31 &Val::Arr(arr1),31 &Val::Arr(arr1),
32 &Val::Arr(arr2),32 &Val::Arr(arr2),
33 jrsonnet_parser::BinaryOpType::Lt,33 jrsonnet_ir::BinaryOpType::Lt,
34 )?;34 )?;
35 Ok($operator.contains(&ordering))35 Ok($operator.contains(&ordering))
36 }36 }
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
20 ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,20 ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,
21};21};
22use jrsonnet_gcmodule::{Acyclic, Cc, Trace};22use jrsonnet_gcmodule::{Acyclic, Cc, Trace};
23use jrsonnet_parser::Source;23use jrsonnet_ir::Source;
24pub use manifest::*;24pub use manifest::*;
25pub use math::*;25pub use math::*;
26pub use misc::*;26pub use misc::*;
modifiedcrates/jrsonnet-stdlib/src/manifest/ini.rsdiffbeforeafterboth
4 manifest::{ManifestFormat, ToStringFormat},4 manifest::{ManifestFormat, ToStringFormat},
5 typed::{FromUntyped, Typed},5 typed::{FromUntyped, Typed},
6 ObjValue, Result, ResultExt, Val,6 ObjValue, Result, ResultExt, Val,
7 IStr,
7};8};
8use jrsonnet_parser::IStr;
99
10pub struct IniFormat {10pub struct IniFormat {
11 #[cfg(feature = "exp-preserve-order")]11 #[cfg(feature = "exp-preserve-order")]
modifiedcrates/jrsonnet-stdlib/src/sets.rsdiffbeforeafterboth
3use jrsonnet_evaluator::{3use jrsonnet_evaluator::{
4 function::builtin, operator::evaluate_compare_op, val::ArrValue, Result, Thunk, Val,4 function::builtin, operator::evaluate_compare_op, val::ArrValue, Result, Thunk, Val,
5};5};
6use jrsonnet_parser::BinaryOpType;6use jrsonnet_ir::BinaryOpType;
77
8use crate::keyf::KeyF;8use crate::keyf::KeyF;
99
modifiedcrates/jrsonnet-stdlib/src/sort.rsdiffbeforeafterboth
9 val::{equals, ArrValue},9 val::{equals, ArrValue},
10 Result, Thunk, Val,10 Result, Thunk, Val,
11};11};
12use jrsonnet_parser::BinaryOpType;12use jrsonnet_ir::BinaryOpType;
1313
14use crate::{eval_on_empty, keyf::KeyF};14use crate::{eval_on_empty, keyf::KeyF};
1515
modifiedflake.nixdiffbeforeafterboth
160 ]160 ]
161 ++ lib.optionals (!stdenv.isDarwin) [161 ++ lib.optionals (!stdenv.isDarwin) [
162 valgrind162 valgrind
163 kdePackages.kcachegrind
163 ];164 ];
164 };165 };
165 };166 };
modifiedxtask/src/main.rsdiffbeforeafterboth
52 } => {52 } => {
53 let out = sh.create_temp_dir()?;53 let out = sh.create_temp_dir()?;
5454
55 // build-std
56 cmd!(55 cmd!(
57 sh,56 sh,
58 "cargo build -Zbuild-std --target={target} --profile releasedebug"57 "cargo build --target={target} --profile releasedebug"
59 )58 )
60 .run()?;59 .run()?;
61 let built = format!("./target/{target}/releasedebug/jrsonnet");60 let built = format!("./target/{target}/releasedebug/jrsonnet");