difftreelog
refactor split peg parser and ir
in: master
109 files changed
Cargo.lockdiffbeforeafterboth192 packageslockfile v4
Might be heavy and slow!
ahash
0.8.12crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75used byaho-corasick
1.1.4crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301depends onaliasable
0.1.3crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fdused byallocator-api2
0.2.21crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923annotate-snippets
0.12.11crates.io↘ 2↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum16e4850548ff4a25a77ce3bda7241874e17fb702ea551f0cc62a2dbe052f1272depends onannotated-string
0.3.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum298ed730801db3c02f2edba003c9420a0f57ea48d37fdc5601c536113668c059used byanstream
0.6.21crates.io↘ 7↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4adepends onused byanstyle
1.0.13crates.io↘ 0↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78anstyle-parse
0.2.7crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2depends onused byanstyle-query
1.1.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadcdepends onused byanstyle-wincon
3.0.11crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747dused byanyhow
1.0.101crates.io↘ 0↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75eaar_archive_writer
0.5.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7eb93bbb63b9c227414f6eb3a0adfddca591a8ce1e9b60661bb08969b87e340bdepends onused byarraydeque
0.5.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236used byautocfg
1.5.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8used bybase64
0.22.1crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6bitflags
2.10.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3used byblock-buffer
0.10.4crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71depends onused bybstr
1.12.1crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cabdepends onused bybumpalo
3.19.1crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510depends oncc
1.2.55crates.io↘ 2↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum47b26a0954ae34af09b50f0de26458fa95369a0d478d8236d3f93082b219bd29depends oncfg-if
1.0.4crates.io↘ 0↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801clap
4.5.57crates.io↘ 2↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6899ea499e3fb9305a65d5ebf6e3d2248c5fab291f300ad0a704fbe142eae31adepends onclap_builder
4.5.57crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7b12c8b680195a62a8364d16b8447b01b6c2c8f9aaf68bee653be34d4245e238used byclap_complete
4.5.65crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum430b4dc2b5e3861848de79627b2bedc9f3342c7da5173a14eaa5d0f8dc18ae5ddepends onused byclap_derive
4.5.55crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5used byclap_lex
0.7.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32used bycolorchoice
1.0.4crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75used byconsole
0.15.11crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8used bycountme
3.0.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636used bycpufeatures
0.2.17crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280depends oncrypto-common
0.1.7crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60adepends onused bydifflib
0.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8used bydigest
0.10.7crates.io↘ 2↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292depends ondprint-core
0.67.4crates.io↘ 7↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2c1d827947704a9495f705d6aeed270fa21a67f825f22902c28f38dc3af7a9aedepends ondrop_bomb
0.1.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1educe
0.6.0crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417either
1.15.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719used byencode_unicode
1.0.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0used byencoding_rs
0.8.35crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3depends onused byencoding_rs_io
0.1.7crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83depends onused byenum-ordinalize
4.3.2crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4a1091a7bb1f8f2c4b28f1fe2cef4980ca2d410a3d727d67ecc3178c9b0800f0depends onused byenum-ordinalize-derive
4.3.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631depends onused byequivalent
1.0.2crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0ferrno
0.3.14crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efebdepends onused byextension-trait
1.0.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdd65f1b59dd22d680c7a626cc4a000c1e03d241c51c3e034d2bc9f1e90734f9bdepends onused byfastrand
2.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411beused byfind-msvc-tools
0.1.9crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582used byfnv
1.0.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1used byfoldhash
0.1.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2used byfoldhash
0.2.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdbused bygeneric-array
0.14.7crates.io↘ 2↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9adepends ongetrandom
0.3.4crates.io↘ 6↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fdglobset
0.4.18crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3used byhashbrown
0.14.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1used byhashbrown
0.15.5crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1used byhashbrown
0.16.1crates.io↘ 3↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100heck
0.4.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8used byheck
0.5.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55eaused byhi-doc
0.3.0crates.io↘ 10↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf70fb920ba34768415fb239d7d607486083bfc38ad35e3f1d558697f9f646f11depends onhi-doc-jumprope
1.2.1crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum236c25809a9c0a0249b3488feb57744e12aa64e4f3db851980eab303719c7bdddepends onused byindexmap
2.13.0crates.io↘ 4↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017indoc
2.0.7crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706depends oninsta
1.46.3crates.io↘ 6↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume82db8c87c7f1ccecb34ce0c24399b8a73081427f3c7c50a5d597925356115e4is_terminal_polyfill
1.70.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695used byitertools
0.14.0crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285depends onitoa
1.0.17crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2used byjrsonnet-cli
0.5.0-pre97workspace↘ 5↖ 1jrsonnet-evaluator
0.5.0-pre97workspace↘ 18↖ 5depends on- annotate-snippets
0.12.11 - anyhow
1.0.101 - educe
0.6.0 - hi-doc
0.3.0 - jrsonnet-gcmodule
0.4.2 - jrsonnet-interner
0.5.0-pre97 - jrsonnet-macros
0.5.0-pre97 - jrsonnet-parser
0.5.0-pre97 - jrsonnet-types
0.5.0-pre97 - num-bigint
0.4.6 - pathdiff
0.2.3 - rustc-hash
2.1.1 - rustversion
1.0.22 - serde
1.0.228 - stacker
0.1.23 - static_assertions
1.1.0 - strsim
0.11.1 - thiserror
2.0.18
- annotate-snippets
jrsonnet-fmt
0.5.0-pre97workspace↘ 6↖ 0jrsonnet-formatter
0.5.0-pre97workspace↘ 5↖ 1jrsonnet-gcmodule
0.4.2crates.io↘ 1↖ 9sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf95b976a79e4000bb9e07ff0709dca0ea27bcf1952d4c17d91fb7364d6145683depends onjrsonnet-gcmodule-derive
0.4.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum51d928626220a310ff0cec815e80cf7fe104697184352ca21c40534e0b0d72d9depends onused byjrsonnet-interner
0.5.0-pre97workspace↘ 3↖ 3jrsonnet-macros
0.5.0-pre97workspace↘ 4↖ 2jrsonnet-parser
0.5.0-pre97workspace↘ 5↖ 5jrsonnet-rowan-parser
0.5.0-pre97workspace↘ 9↖ 1jrsonnet-stdlib
0.5.0-pre97workspace↘ 16↖ 3depends onjrsonnet-types
0.5.0-pre97workspace↘ 2↖ 1depends onjs-sys
0.3.85crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3depends onused byjson-structural-diff
0.2.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume878e36a8a44c158505c2c818abdc1350413ad83dcb774a0459f6a7ef2b65cbfdepends onused bykeccak
0.1.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654depends onused bylibc
0.2.180crates.io↘ 0↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fclibjsonnet
0.5.0-pre97workspace↘ 5↖ 0linux-raw-sys
0.11.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdf1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039used bylog
0.4.29crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897used bylogos
0.16.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumeb2c55a318a87600ea870ff8c2012148b44bf18b74fad48d0f835c38c7d07c5fdepends onlogos-codegen
0.16.1crates.io↘ 6↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum58b3ffaa284e1350d017a57d04ada118c4583cf260c8fb01e0fe28a2e9cf8970used bylogos-derive
0.16.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum52d3a9855747c17eaf4383823f135220716ab49bea5fbea7dd42cc9a92f8aa31depends onused bylru
0.16.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma1dc47f592c06f33f8e3aea9591776ec7c9f9e4124778ff8a3c3b87159f7e593depends onused bymd5
0.8.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumae960838283323069879657ca3de837e9f7bbb4c7bf6ea7f1b290d5e9476d2e0used bymemchr
2.8.0crates.io↘ 0↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79mimalloc-sys
0.1.6crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4aa3cefb626f6ae3d0b2f71c5378c89d2b1d4d7bc246b0ca9a7ee61a4daad291depends onused bymimallocator
0.1.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2d44fe4ebf6b538fcf39d9975c2b90bb3232d1ba8e8bffeacd004f27b20c577adepends onused bynohash-hasher
0.2.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451used bynum-bigint
0.4.6crates.io↘ 3↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9num-integer
0.1.46crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858fdepends onused bynum-traits
0.2.19crates.io↘ 1↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841depends onobject
0.37.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fedepends onused byonce_cell
1.21.3crates.io↘ 0↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2donce_cell_polyfill
1.70.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4feused byouroboros
0.18.5crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1e0f050db9c44b97a94723127e6be766ac5c340c48f2c4bb3ffa11713744be59used byouroboros_macro
0.18.5crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0used bypathdiff
0.2.3crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdf94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3peg
0.8.5crates.io↘ 2↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9928cfca101b36ec5163e70049ee5368a8a1c3c6efc9ca9c5f9cc2f816152477depends onpeg-macros
0.8.5crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6298ab04c202fa5b5d52ba03269fb7b74550b150323038878fe6c372d8280f71used bypeg-runtime
0.8.5crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum132dca9b868d927b35b5dd728167b2dee150eb1ad686008fc71ccb298b776fcaused byppv-lite86
0.2.21crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9depends onused byproc-macro2
1.0.106crates.io↘ 1↖ 18sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934depends onused by- clap_derive
4.5.55 - educe
0.6.0 - enum-ordinalize-derive
4.3.2 - extension-trait
1.0.2 - jrsonnet-gcmodule-derive
0.4.2 - jrsonnet-macros
0.5.0-pre97 - logos-codegen
0.16.1 - ouroboros_macro
0.18.5 - peg-macros
0.8.5 - proc-macro2-diagnostics
0.10.1 - quote
1.0.44 - serde_derive
1.0.228 - syn
2.0.114 - syn-dissect-closure
0.1.0 - thiserror-impl
2.0.18 - wasm-bindgen-macro-support
0.2.108 - xtask
0.1.0 - zerocopy-derive
0.8.39
- clap_derive
proc-macro2-diagnostics
0.10.1crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumaf066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8used bypsm
0.1.30crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3852766467df634d74f0b2d7819bf8dc483a0eb2e3b0f50f756f9cfe8b0d18d8depends onused byquote
1.0.44crates.io↘ 1↖ 18sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4depends onused by- clap_derive
4.5.55 - educe
0.6.0 - enum-ordinalize-derive
4.3.2 - extension-trait
1.0.2 - jrsonnet-gcmodule-derive
0.4.2 - jrsonnet-macros
0.5.0-pre97 - logos-codegen
0.16.1 - ouroboros_macro
0.18.5 - peg-macros
0.8.5 - proc-macro2-diagnostics
0.10.1 - serde_derive
1.0.228 - syn
2.0.114 - syn-dissect-closure
0.1.0 - thiserror-impl
2.0.18 - wasm-bindgen-macro
0.2.108 - wasm-bindgen-macro-support
0.2.108 - xtask
0.1.0 - zerocopy-derive
0.8.39
- clap_derive
r-efi
5.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0fused byrand
0.9.2crates.io↘ 2↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1depends onrand_chacha
0.9.0crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cbdepends onused byrand_core
0.9.5crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83cdepends onused byrandom_color
1.1.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd635c5e80ae160390ac62ca027d2d06c94c1dc69e5c0a12f1e3a53664dc84966depends onused byrange-map
0.2.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum12a5a2d6c7039059af621472a4389be1215a816df61aa4d531cfe85264aee95fdepends onused byregex
1.12.3crates.io↘ 4↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276regex-automata
0.4.14crates.io↘ 3↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8fregex-syntax
0.8.9crates.io↘ 0↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4crowan
0.16.1crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum417a3a9f582e349834051b8a10c8d71ca88da4211e4093528e36b9845f6b5f21rustc-hash
1.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2used byrustc-hash
2.1.1crates.io↘ 0↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0drustix
1.1.3crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34used byrustversion
1.0.22crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46dsame-file
1.0.6crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502depends onused bysaphyr-parser-bw
0.0.607crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2f9bae8d059bf1ca32753cf3cdafbf5d391502de2fc2ca54510811fe9c100d90used byserde
1.0.228crates.io↘ 2↖ 10sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9edepends onserde_core
1.0.228crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67addepends onserde_derive
1.0.228crates.io↘ 3↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79depends onserde_json
1.0.149crates.io↘ 6↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86serde-saphyr
0.0.17crates.io↘ 13↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbc14a55107113a16346915d7e3d78acc539a923458385db89670e22cac106d7adepends onused bysha1
0.10.6crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6badepends onused bysha2
0.10.9crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283depends onused bysha3
0.10.8crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60depends onused bysimilar
2.7.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daaused bysmallvec
1.15.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03used bysmallvec
2.0.0-alpha.12crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumef784004ca8777809dcdad6ac37629f0a97caee4c685fcea805278d81dd8b857stacker
0.1.23crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum08d74a23609d509411d10e2176dc2a4346e3b4aea2e7b1869f19fdedbc71c013static_assertions
1.1.0crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543fstr_indices
0.4.4crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd08889ec5408683408db66ad89e0e1f93dff55c73a4ccc71c427d5b277ee47e6used bystreaming-iterator
0.1.9crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520strip-ansi-escapes
0.2.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025depends onstrsim
0.11.1crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4fsyn
2.0.114crates.io↘ 3↖ 14sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2aused by- clap_derive
4.5.55 - educe
0.6.0 - enum-ordinalize-derive
4.3.2 - extension-trait
1.0.2 - jrsonnet-gcmodule-derive
0.4.2 - jrsonnet-macros
0.5.0-pre97 - logos-codegen
0.16.1 - ouroboros_macro
0.18.5 - proc-macro2-diagnostics
0.10.1 - serde_derive
1.0.228 - syn-dissect-closure
0.1.0 - thiserror-impl
2.0.18 - wasm-bindgen-macro-support
0.2.108 - zerocopy-derive
0.8.39
- clap_derive
syn-dissect-closure
0.1.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum343bae741672e4b94421cbe93f9794ba9a061434272f7e3a29ff43be26be3ac9depends onused bytempfile
3.24.0crates.io↘ 5↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9ctext-size
1.1.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233used bythiserror
2.0.18crates.io↘ 1↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4depends onthiserror-impl
2.0.18crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5depends onused bytree-sitter
0.26.5crates.io↘ 6↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum12987371f54efc9b9306a20dc87ed5aaee9f320c8a8b115e28515c412b2efe39depends onused bytree-sitter-highlight
0.26.5crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2b688407049ea1b55a7e872f138947d22389118b9c4d09b459cb34ca205e41c0used bytree-sitter-language
0.1.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum009994f150cc0cd50ff54917d5bc8bffe8cad10ca10d81c34da2ec421ae61782used bytypenum
1.19.0crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bbungrammar
1.16.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma3e5df347f0bf3ec1d670aad6ca5c6a1859cd9ea61d2113125794654ccced68fused byunicode-box-drawing
0.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2a1f97719cf40224391201fc11e7f5b0cc0ba21416367cfc914e2d45af4e42efused byunicode-ident
1.0.22crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5unicode-width
0.2.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254utf8parse
0.2.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821version_check
0.9.5crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105avte
0.14.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077depends onused bywalkdir
2.5.0crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4bdepends onused bywasip2
1.0.2+wasi-0.2.9crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5depends onused bywasm-bindgen
0.2.108crates.io↘ 5↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566depends onused bywasm-bindgen-macro
0.2.108crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608used bywasm-bindgen-macro-support
0.2.108crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55used bywinapi-util
0.1.11crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22depends onused bywindows_aarch64_gnullvm
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3used bywindows_aarch64_msvc
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469used bywindows_i686_gnu
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0bused bywindows_i686_gnullvm
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66used bywindows_i686_msvc
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66used bywindows_x86_64_gnu
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78used bywindows_x86_64_gnullvm
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0dused bywindows_x86_64_msvc
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ecused bywindows-link
0.2.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5used bywindows-sys
0.59.0crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853bdepends onused bywindows-sys
0.61.2crates.io↘ 1↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fcdepends onwindows-targets
0.52.6crates.io↘ 8↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973depends onused bywit-bindgen
0.51.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5used byxshell
0.2.7crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373ddepends onused byxshell-macros
0.2.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547used byxtask
0.1.0workspace↘ 8↖ 0yansi
1.0.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049zerocopy
0.8.39crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdb6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4adepends onused byzerocopy-derive
0.8.39crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517depends onused byzmij
1.0.19crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3ff05f8caa9038894637571ae6b9e29466c1f4f829d26c9b28f869a29cbe3445
193 packageslockfile v4
Might be heavy and slow!
ahash
0.8.12crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75used byaho-corasick
1.1.4crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301depends onaliasable
0.1.3crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fdused byallocator-api2
0.2.21crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923annotate-snippets
0.12.11crates.io↘ 2↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum16e4850548ff4a25a77ce3bda7241874e17fb702ea551f0cc62a2dbe052f1272depends onannotated-string
0.3.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum298ed730801db3c02f2edba003c9420a0f57ea48d37fdc5601c536113668c059used byanstream
0.6.21crates.io↘ 7↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4adepends onused byanstyle
1.0.13crates.io↘ 0↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78anstyle-parse
0.2.7crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2depends onused byanstyle-query
1.1.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadcdepends onused byanstyle-wincon
3.0.11crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747dused byanyhow
1.0.101crates.io↘ 0↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75eaar_archive_writer
0.5.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7eb93bbb63b9c227414f6eb3a0adfddca591a8ce1e9b60661bb08969b87e340bdepends onused byarraydeque
0.5.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236used byautocfg
1.5.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8used bybase64
0.22.1crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6bitflags
2.10.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3used byblock-buffer
0.10.4crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71depends onused bybstr
1.12.1crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cabdepends onused bybumpalo
3.19.1crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510depends oncc
1.2.55crates.io↘ 2↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum47b26a0954ae34af09b50f0de26458fa95369a0d478d8236d3f93082b219bd29depends oncfg-if
1.0.4crates.io↘ 0↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801clap
4.5.57crates.io↘ 2↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6899ea499e3fb9305a65d5ebf6e3d2248c5fab291f300ad0a704fbe142eae31adepends onclap_builder
4.5.57crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7b12c8b680195a62a8364d16b8447b01b6c2c8f9aaf68bee653be34d4245e238used byclap_complete
4.5.65crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum430b4dc2b5e3861848de79627b2bedc9f3342c7da5173a14eaa5d0f8dc18ae5ddepends onused byclap_derive
4.5.55crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5used byclap_lex
0.7.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32used bycolorchoice
1.0.4crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75used byconsole
0.15.11crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8used bycountme
3.0.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636used bycpufeatures
0.2.17crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280depends oncrypto-common
0.1.7crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60adepends onused bydifflib
0.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8used bydigest
0.10.7crates.io↘ 2↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292depends ondprint-core
0.67.4crates.io↘ 7↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2c1d827947704a9495f705d6aeed270fa21a67f825f22902c28f38dc3af7a9aedepends ondrop_bomb
0.1.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1educe
0.6.0crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417either
1.15.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719used byencode_unicode
1.0.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0used byencoding_rs
0.8.35crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3depends onused byencoding_rs_io
0.1.7crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83depends onused byenum-ordinalize
4.3.2crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4a1091a7bb1f8f2c4b28f1fe2cef4980ca2d410a3d727d67ecc3178c9b0800f0depends onused byenum-ordinalize-derive
4.3.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631depends onused byequivalent
1.0.2crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0ferrno
0.3.14crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efebdepends onused byextension-trait
1.0.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdd65f1b59dd22d680c7a626cc4a000c1e03d241c51c3e034d2bc9f1e90734f9bdepends onused byfastrand
2.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411beused byfind-msvc-tools
0.1.9crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582used byfnv
1.0.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1used byfoldhash
0.1.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2used byfoldhash
0.2.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdbused bygeneric-array
0.14.7crates.io↘ 2↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9adepends ongetrandom
0.3.4crates.io↘ 6↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fdglobset
0.4.18crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3used byhashbrown
0.14.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1used byhashbrown
0.15.5crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1used byhashbrown
0.16.1crates.io↘ 3↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100heck
0.4.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8used byheck
0.5.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55eaused byhi-doc
0.3.0crates.io↘ 10↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf70fb920ba34768415fb239d7d607486083bfc38ad35e3f1d558697f9f646f11depends onhi-doc-jumprope
1.2.1crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum236c25809a9c0a0249b3488feb57744e12aa64e4f3db851980eab303719c7bdddepends onused byindexmap
2.13.0crates.io↘ 4↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017indoc
2.0.7crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706depends oninsta
1.46.3crates.io↘ 6↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume82db8c87c7f1ccecb34ce0c24399b8a73081427f3c7c50a5d597925356115e4is_terminal_polyfill
1.70.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695used byitertools
0.14.0crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285depends onitoa
1.0.17crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2used byjrsonnet-cli
0.5.0-pre97workspace↘ 5↖ 1jrsonnet-evaluator
0.5.0-pre97workspace↘ 19↖ 5depends on- annotate-snippets
0.12.11 - anyhow
1.0.101 - educe
0.6.0 - hi-doc
0.3.0 - jrsonnet-gcmodule
0.4.2 - jrsonnet-interner
0.5.0-pre97 - jrsonnet-ir
0.5.0-pre97 - jrsonnet-macros
0.5.0-pre97 - jrsonnet-peg-parser
0.5.0-pre97 - jrsonnet-types
0.5.0-pre97 - num-bigint
0.4.6 - pathdiff
0.2.3 - rustc-hash
2.1.1 - rustversion
1.0.22 - serde
1.0.228 - stacker
0.1.23 - static_assertions
1.1.0 - strsim
0.11.1 - thiserror
2.0.18
- annotate-snippets
jrsonnet-fmt
0.5.0-pre97workspace↘ 6↖ 0jrsonnet-formatter
0.5.0-pre97workspace↘ 5↖ 1jrsonnet-gcmodule
0.4.2crates.io↘ 1↖ 9sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf95b976a79e4000bb9e07ff0709dca0ea27bcf1952d4c17d91fb7364d6145683depends onjrsonnet-gcmodule-derive
0.4.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum51d928626220a310ff0cec815e80cf7fe104697184352ca21c40534e0b0d72d9depends onused byjrsonnet-interner
0.5.0-pre97workspace↘ 3↖ 3jrsonnet-macros
0.5.0-pre97workspace↘ 4↖ 2jrsonnet-peg-parser
0.5.0-pre97workspace↘ 3↖ 1jrsonnet-rowan-parser
0.5.0-pre97workspace↘ 9↖ 1jrsonnet-stdlib
0.5.0-pre97workspace↘ 16↖ 3depends onjrsonnet-types
0.5.0-pre97workspace↘ 2↖ 1depends onjs-sys
0.3.85crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3depends onused byjson-structural-diff
0.2.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume878e36a8a44c158505c2c818abdc1350413ad83dcb774a0459f6a7ef2b65cbfdepends onused bykeccak
0.1.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654depends onused bylibc
0.2.180crates.io↘ 0↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fclibjsonnet
0.5.0-pre97workspace↘ 5↖ 0linux-raw-sys
0.11.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdf1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039used bylog
0.4.29crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897used bylogos
0.16.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumeb2c55a318a87600ea870ff8c2012148b44bf18b74fad48d0f835c38c7d07c5fdepends onlogos-codegen
0.16.1crates.io↘ 6↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum58b3ffaa284e1350d017a57d04ada118c4583cf260c8fb01e0fe28a2e9cf8970used bylogos-derive
0.16.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum52d3a9855747c17eaf4383823f135220716ab49bea5fbea7dd42cc9a92f8aa31depends onused bylru
0.16.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma1dc47f592c06f33f8e3aea9591776ec7c9f9e4124778ff8a3c3b87159f7e593depends onused bymd5
0.8.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumae960838283323069879657ca3de837e9f7bbb4c7bf6ea7f1b290d5e9476d2e0used bymemchr
2.8.0crates.io↘ 0↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79mimalloc-sys
0.1.6crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4aa3cefb626f6ae3d0b2f71c5378c89d2b1d4d7bc246b0ca9a7ee61a4daad291depends onused bymimallocator
0.1.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2d44fe4ebf6b538fcf39d9975c2b90bb3232d1ba8e8bffeacd004f27b20c577adepends onused bynohash-hasher
0.2.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451used bynum-bigint
0.4.6crates.io↘ 3↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9num-integer
0.1.46crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858fdepends onused bynum-traits
0.2.19crates.io↘ 1↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841depends onobject
0.37.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fedepends onused byonce_cell
1.21.3crates.io↘ 0↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2donce_cell_polyfill
1.70.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4feused byouroboros
0.18.5crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1e0f050db9c44b97a94723127e6be766ac5c340c48f2c4bb3ffa11713744be59used byouroboros_macro
0.18.5crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0used bypathdiff
0.2.3crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdf94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3peg
0.8.5crates.io↘ 2↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9928cfca101b36ec5163e70049ee5368a8a1c3c6efc9ca9c5f9cc2f816152477depends onpeg-macros
0.8.5crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6298ab04c202fa5b5d52ba03269fb7b74550b150323038878fe6c372d8280f71used bypeg-runtime
0.8.5crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum132dca9b868d927b35b5dd728167b2dee150eb1ad686008fc71ccb298b776fcaused byppv-lite86
0.2.21crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9depends onused byproc-macro2
1.0.106crates.io↘ 1↖ 18sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934depends onused by- clap_derive
4.5.55 - educe
0.6.0 - enum-ordinalize-derive
4.3.2 - extension-trait
1.0.2 - jrsonnet-gcmodule-derive
0.4.2 - jrsonnet-macros
0.5.0-pre97 - logos-codegen
0.16.1 - ouroboros_macro
0.18.5 - peg-macros
0.8.5 - proc-macro2-diagnostics
0.10.1 - quote
1.0.44 - serde_derive
1.0.228 - syn
2.0.114 - syn-dissect-closure
0.1.0 - thiserror-impl
2.0.18 - wasm-bindgen-macro-support
0.2.108 - xtask
0.1.0 - zerocopy-derive
0.8.39
- clap_derive
proc-macro2-diagnostics
0.10.1crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumaf066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8used bypsm
0.1.30crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3852766467df634d74f0b2d7819bf8dc483a0eb2e3b0f50f756f9cfe8b0d18d8depends onused byquote
1.0.44crates.io↘ 1↖ 18sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4depends onused by- clap_derive
4.5.55 - educe
0.6.0 - enum-ordinalize-derive
4.3.2 - extension-trait
1.0.2 - jrsonnet-gcmodule-derive
0.4.2 - jrsonnet-macros
0.5.0-pre97 - logos-codegen
0.16.1 - ouroboros_macro
0.18.5 - peg-macros
0.8.5 - proc-macro2-diagnostics
0.10.1 - serde_derive
1.0.228 - syn
2.0.114 - syn-dissect-closure
0.1.0 - thiserror-impl
2.0.18 - wasm-bindgen-macro
0.2.108 - wasm-bindgen-macro-support
0.2.108 - xtask
0.1.0 - zerocopy-derive
0.8.39
- clap_derive
r-efi
5.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0fused byrand
0.9.2crates.io↘ 2↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1depends onrand_chacha
0.9.0crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cbdepends onused byrand_core
0.9.5crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83cdepends onused byrandom_color
1.1.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd635c5e80ae160390ac62ca027d2d06c94c1dc69e5c0a12f1e3a53664dc84966depends onused byrange-map
0.2.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum12a5a2d6c7039059af621472a4389be1215a816df61aa4d531cfe85264aee95fdepends onused byregex
1.12.3crates.io↘ 4↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276regex-automata
0.4.14crates.io↘ 3↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8fregex-syntax
0.8.9crates.io↘ 0↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4crowan
0.16.1crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum417a3a9f582e349834051b8a10c8d71ca88da4211e4093528e36b9845f6b5f21rustc-hash
1.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2used byrustc-hash
2.1.1crates.io↘ 0↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0drustix
1.1.3crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34used byrustversion
1.0.22crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46dsame-file
1.0.6crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502depends onused bysaphyr-parser-bw
0.0.607crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2f9bae8d059bf1ca32753cf3cdafbf5d391502de2fc2ca54510811fe9c100d90used byserde
1.0.228crates.io↘ 2↖ 10sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9edepends onserde_core
1.0.228crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67addepends onserde_derive
1.0.228crates.io↘ 3↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79depends onserde_json
1.0.149crates.io↘ 6↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86serde-saphyr
0.0.17crates.io↘ 13↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbc14a55107113a16346915d7e3d78acc539a923458385db89670e22cac106d7adepends onused bysha1
0.10.6crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6badepends onused bysha2
0.10.9crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283depends onused bysha3
0.10.8crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60depends onused bysimilar
2.7.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daaused bysmallvec
1.15.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03used bysmallvec
2.0.0-alpha.12crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumef784004ca8777809dcdad6ac37629f0a97caee4c685fcea805278d81dd8b857stacker
0.1.23crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum08d74a23609d509411d10e2176dc2a4346e3b4aea2e7b1869f19fdedbc71c013static_assertions
1.1.0crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543fstr_indices
0.4.4crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd08889ec5408683408db66ad89e0e1f93dff55c73a4ccc71c427d5b277ee47e6used bystreaming-iterator
0.1.9crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520strip-ansi-escapes
0.2.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025depends onstrsim
0.11.1crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4fsyn
2.0.114crates.io↘ 3↖ 14sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2aused by- clap_derive
4.5.55 - educe
0.6.0 - enum-ordinalize-derive
4.3.2 - extension-trait
1.0.2 - jrsonnet-gcmodule-derive
0.4.2 - jrsonnet-macros
0.5.0-pre97 - logos-codegen
0.16.1 - ouroboros_macro
0.18.5 - proc-macro2-diagnostics
0.10.1 - serde_derive
1.0.228 - syn-dissect-closure
0.1.0 - thiserror-impl
2.0.18 - wasm-bindgen-macro-support
0.2.108 - zerocopy-derive
0.8.39
- clap_derive
syn-dissect-closure
0.1.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum343bae741672e4b94421cbe93f9794ba9a061434272f7e3a29ff43be26be3ac9depends onused bytempfile
3.24.0crates.io↘ 5↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9ctext-size
1.1.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233used bythiserror
2.0.18crates.io↘ 1↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4depends onthiserror-impl
2.0.18crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5depends onused bytree-sitter
0.26.5crates.io↘ 6↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum12987371f54efc9b9306a20dc87ed5aaee9f320c8a8b115e28515c412b2efe39depends onused bytree-sitter-highlight
0.26.5crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2b688407049ea1b55a7e872f138947d22389118b9c4d09b459cb34ca205e41c0used bytree-sitter-language
0.1.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum009994f150cc0cd50ff54917d5bc8bffe8cad10ca10d81c34da2ec421ae61782used bytypenum
1.19.0crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bbungrammar
1.16.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma3e5df347f0bf3ec1d670aad6ca5c6a1859cd9ea61d2113125794654ccced68fused byunicode-box-drawing
0.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2a1f97719cf40224391201fc11e7f5b0cc0ba21416367cfc914e2d45af4e42efused byunicode-ident
1.0.22crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5unicode-width
0.2.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254utf8parse
0.2.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821version_check
0.9.5crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105avte
0.14.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077depends onused bywalkdir
2.5.0crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4bdepends onused bywasip2
1.0.2+wasi-0.2.9crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5depends onused bywasm-bindgen
0.2.108crates.io↘ 5↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566depends onused bywasm-bindgen-macro
0.2.108crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608used bywasm-bindgen-macro-support
0.2.108crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55used bywinapi-util
0.1.11crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22depends onused bywindows_aarch64_gnullvm
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3used bywindows_aarch64_msvc
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469used bywindows_i686_gnu
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0bused bywindows_i686_gnullvm
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66used bywindows_i686_msvc
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66used bywindows_x86_64_gnu
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78used bywindows_x86_64_gnullvm
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0dused bywindows_x86_64_msvc
0.52.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ecused bywindows-link
0.2.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5used bywindows-sys
0.59.0crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853bdepends onused bywindows-sys
0.61.2crates.io↘ 1↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fcdepends onwindows-targets
0.52.6crates.io↘ 8↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973depends onused bywit-bindgen
0.51.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5used byxshell
0.2.7crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373ddepends onused byxshell-macros
0.2.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547used byxtask
0.1.0workspace↘ 8↖ 0yansi
1.0.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049zerocopy
0.8.39crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdb6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4adepends onused byzerocopy-derive
0.8.39crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517depends onused byzmij
1.0.19crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3ff05f8caa9038894637571ae6b9e29466c1f4f829d26c9b28f869a29cbe3445
Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,8 @@
[workspace.dependencies]
jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0-pre97" }
jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0-pre97" }
-jrsonnet-parser = { path = "./crates/jrsonnet-parser", version = "0.5.0-pre97" }
+jrsonnet-ir = { path = "./crates/jrsonnet-ir", version = "0.5.0-pre97" }
+jrsonnet-peg-parser = { path = "./crates/jrsonnet-peg-parser", version = "0.5.0-pre97" }
jrsonnet-rowan-parser = { path = "./crates/jrsonnet-rowan-parser", version = "0.5.0-pre97" }
jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0-pre97" }
jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", version = "0.5.0-pre97" }
bindings/jsonnet/Cargo.tomldiffbeforeafterboth--- a/bindings/jsonnet/Cargo.toml
+++ b/bindings/jsonnet/Cargo.toml
@@ -20,7 +20,7 @@
[dependencies]
jrsonnet-evaluator.workspace = true
-jrsonnet-parser.workspace = true
+jrsonnet-ir.workspace = true
jrsonnet-stdlib.workspace = true
jrsonnet-gcmodule.workspace = true
jrsonnet-interner.workspace = true
bindings/jsonnet/src/import.rsdiffbeforeafterboth--- a/bindings/jsonnet/src/import.rs
+++ b/bindings/jsonnet/src/import.rs
@@ -17,7 +17,7 @@
AsPathLike, ImportResolver, ResolvePath,
};
use jrsonnet_gcmodule::Acyclic;
-use jrsonnet_parser::{SourceDirectory, SourceFile, SourcePath};
+use jrsonnet_ir::{SourceDirectory, SourceFile, SourcePath};
use crate::VM;
bindings/jsonnet/src/lib.rsdiffbeforeafterboth--- a/bindings/jsonnet/src/lib.rs
+++ b/bindings/jsonnet/src/lib.rs
@@ -31,7 +31,7 @@
AsPathLike, FileImportResolver, IStr, ImportResolver, Result, State, Val,
};
use jrsonnet_gcmodule::Acyclic;
-use jrsonnet_parser::SourcePath;
+use jrsonnet_ir::SourcePath;
use jrsonnet_stdlib::ContextInitializer;
/// WASM stub
cmds/jrsonnet/Cargo.tomldiffbeforeafterboth--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -37,7 +37,7 @@
# obj?.field, obj?.['field']
exp-null-coaelse = [
"jrsonnet-evaluator/exp-null-coaelse",
- "jrsonnet-parser/exp-null-coaelse",
+ "jrsonnet-ir/exp-null-coaelse",
"jrsonnet-cli/exp-null-coaelse",
]
# --exp-apply
@@ -45,7 +45,7 @@
[dependencies]
jrsonnet-evaluator.workspace = true
-jrsonnet-parser.workspace = true
+jrsonnet-ir.workspace = true
jrsonnet-cli.workspace = true
jrsonnet-gcmodule.workspace = true
cmds/jrsonnet/src/main.rsdiffbeforeafterboth--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -11,7 +11,7 @@
error::{Error as JrError, ErrorKind},
ResultExt, State, Val,
};
-use jrsonnet_parser::{SourceDefaultIgnoreJpath, SourcePath};
+use jrsonnet_ir::{SourceDefaultIgnoreJpath, SourcePath};
#[cfg(feature = "mimalloc")]
#[global_allocator]
crates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -29,7 +29,7 @@
[dependencies]
jrsonnet-evaluator = { workspace = true, features = ["explaining-traces"] }
-jrsonnet-parser.workspace = true
+jrsonnet-ir.workspace = true
jrsonnet-stdlib.workspace = true
jrsonnet-gcmodule.workspace = true
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -22,17 +22,18 @@
# Allows to preserve field order in objects
exp-preserve-order = []
# Implements field destructuring
-exp-destruct = ["jrsonnet-parser/exp-destruct"]
+exp-destruct = ["jrsonnet-peg-parser/exp-destruct"]
# Iteration over objects yields [key, value] elements
exp-object-iteration = []
# Bigint type
exp-bigint = ["num-bigint", "jrsonnet-types/exp-bigint"]
# obj?.field, obj?.['field']
-exp-null-coaelse = ["jrsonnet-parser/exp-null-coaelse"]
+exp-null-coaelse = ["jrsonnet-peg-parser/exp-null-coaelse"]
[dependencies]
jrsonnet-interner.workspace = true
-jrsonnet-parser.workspace = true
+jrsonnet-ir.workspace = true
+jrsonnet-peg-parser.workspace = true
jrsonnet-types.workspace = true
jrsonnet-macros.workspace = true
jrsonnet-gcmodule.workspace = true
crates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/arr/mod.rs
+++ b/crates/jrsonnet-evaluator/src/arr/mod.rs
@@ -7,7 +7,7 @@
use jrsonnet_gcmodule::{cc_dyn, Cc};
use jrsonnet_interner::IBytes;
-use jrsonnet_parser::{Expr, Spanned};
+use jrsonnet_ir::{Expr, Spanned};
use crate::{function::NativeFn, Context, Result, Thunk, Val};
@@ -85,7 +85,7 @@
pub fn extended(a: Self, b: Self) -> Self {
// TODO: benchmark for an optimal value, currently just a arbitrary choice
- const ARR_EXTEND_THRESHOLD: usize = 100;
+ const ARR_EXTEND_THRESHOLD: usize = 1000;
if a.is_empty() {
b
crates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/arr/spec.rs
+++ b/crates/jrsonnet-evaluator/src/arr/spec.rs
@@ -3,7 +3,7 @@
use jrsonnet_gcmodule::{Cc, Trace};
use jrsonnet_interner::{IBytes, IStr};
-use jrsonnet_parser::{Expr, Spanned};
+use jrsonnet_ir::{Expr, Spanned};
use super::ArrValue;
use crate::function::NativeFn;
crates/jrsonnet-evaluator/src/async_import.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/async_import.rs
+++ b/crates/jrsonnet-evaluator/src/async_import.rs
@@ -2,11 +2,12 @@
use std::{any::Any, cell::RefCell, future::Future};
use jrsonnet_gcmodule::Acyclic;
-use jrsonnet_parser::{
+use jrsonnet_ir::{
ArgsDesc, AssertExpr, AssertStmt, BindSpec, CompSpec, Destruct, Expr, ExprParam, ExprParams,
- FieldMember, FieldName, ForSpecData, IfElse, IfSpecData, ImportKind, ObjBody, ParserSettings,
- Slice, SliceDesc, Source, SourcePath, Spanned,
+ FieldMember, FieldName, ForSpecData, IfElse, IfSpecData, ImportKind, ObjBody, Slice, SliceDesc,
+ Source, SourcePath, Spanned,
};
+use jrsonnet_peg_parser::ParserSettings;
use rustc_hash::FxHashMap;
use crate::{AsPathLike, FileData, ImportResolver, ResolvePathOwned, State};
@@ -322,7 +323,7 @@
};
let source = Source::new(path.clone(), code.clone());
// If failed - then skip import
- file.parsed = jrsonnet_parser::parse(&code, &ParserSettings { source })
+ file.parsed = jrsonnet_peg_parser::parse(&code, &ParserSettings { source })
.map(Rc::new)
.ok();
if let Some(parsed) = &file.parsed {
crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -2,7 +2,7 @@
use jrsonnet_gcmodule::{Acyclic, Trace};
use jrsonnet_interner::IStr;
-use jrsonnet_parser::{BinaryOpType, Source, SourcePath, Span, Spanned, UnaryOpType};
+use jrsonnet_ir::{BinaryOpType, Source, SourcePath, Span, Spanned, UnaryOpType};
use jrsonnet_types::ValType;
use thiserror::Error;
@@ -169,7 +169,7 @@
ImportSyntaxError {
path: Source,
#[trace(skip)]
- error: Box<jrsonnet_parser::ParseError>,
+ error: Box<jrsonnet_peg_parser::ParseError>,
},
#[error("runtime error: {}", format_empty_str(.0))]
crates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
@@ -1,7 +1,7 @@
use std::{collections::HashMap, hash::BuildHasher};
use jrsonnet_interner::IStr;
-use jrsonnet_parser::{BindSpec, Destruct};
+use jrsonnet_ir::{BindSpec, Destruct};
use crate::{
bail,
@@ -31,7 +31,7 @@
Destruct::Skip => {}
#[cfg(feature = "exp-destruct")]
Destruct::Array { start, rest, end } => {
- use jrsonnet_parser::DestructRest;
+ use jrsonnet_ir::DestructRest;
let min_len = start.len() + end.len();
let has_rest = rest.is_some();
crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -2,7 +2,7 @@
use jrsonnet_gcmodule::{Cc, Trace};
use jrsonnet_interner::IStr;
-use jrsonnet_parser::{
+use jrsonnet_ir::{
function::ParamName, ArgsDesc, AssertStmt, BinaryOpType, BindSpec, CompSpec, Expr, ExprParams,
FieldMember, FieldName, ForSpecData, IfSpecData, ImportKind, LiteralType, ObjBody, ObjMembers,
Spanned,
@@ -47,17 +47,17 @@
stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)
}
-pub fn evaluate_trivial(expr: &Spanned<Expr>) -> Option<Val> {
- fn is_trivial(expr: &Spanned<Expr>) -> bool {
- match &**expr {
+pub fn evaluate_trivial(expr: &Expr) -> Option<Val> {
+ fn is_trivial(expr: &Expr) -> bool {
+ match &*expr {
Expr::Str(_)
| Expr::Num(_)
| Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,
- Expr::Arr(a) => a.iter().all(is_trivial),
+ Expr::Arr(a) => a.iter().all(|e| is_trivial(&**e)),
_ => false,
}
}
- Some(match &**expr {
+ Some(match &*expr {
Expr::Str(s) => Val::string(s.clone()),
Expr::Num(n) => {
Val::Num(NumValue::new(*n).expect("parser will not allow non-finite values"))
@@ -71,7 +71,7 @@
}
Val::Arr(ArrValue::eager(
n.iter()
- .map(evaluate_trivial)
+ .map(|e| evaluate_trivial(&**e))
.map(|e| e.expect("checked trivial"))
.collect(),
))
@@ -395,14 +395,13 @@
}
#[allow(clippy::too_many_lines)]
-pub fn evaluate(ctx: Context, expr: &Spanned<Expr>) -> Result<Val> {
+pub fn evaluate(ctx: Context, expr: &Expr) -> Result<Val> {
use Expr::*;
if let Some(trivial) = evaluate_trivial(expr) {
return Ok(trivial);
}
- let loc = expr.span();
- Ok(match &**expr {
+ Ok(match expr {
Literal(LiteralType::This) => Val::Obj(ctx.try_this()?),
Literal(LiteralType::Super) => Val::Obj(ctx.try_sup_this()?.standalone_super()?),
Literal(LiteralType::Dollar) => Val::Obj(ctx.try_dollar()?),
@@ -433,9 +432,9 @@
BinaryOp(bin) => evaluate_binary_op_special(ctx, &bin.lhs, bin.op, &bin.rhs)?,
UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(ctx, v)?)?,
Var(name) => in_frame(
- CallLocation::new(&loc),
+ CallLocation::new(&name.span()),
|| format!("local <{name}> access"),
- || ctx.binding(name.clone())?.evaluate(),
+ || ctx.binding((**name).clone())?.evaluate(),
)?,
Index { indexable, parts } => ensure_sufficient_stack(|| {
let mut parts = parts.iter();
@@ -591,7 +590,13 @@
&Val::Obj(evaluate_object(ctx, b)?),
)?,
Apply(value, args, tailstrict) => ensure_sufficient_stack(|| {
- evaluate_apply(ctx, value, args, CallLocation::new(&loc), *tailstrict)
+ evaluate_apply(
+ ctx,
+ value,
+ args,
+ CallLocation::new(&args.span()),
+ *tailstrict,
+ )
})?,
Function(params, body) => {
evaluate_method(ctx, "anonymous".into(), params.clone(), body.clone())
@@ -601,13 +606,13 @@
evaluate(ctx, &assert.rest)?
}
ErrorStmt(e) => in_frame(
- CallLocation::new(&loc),
+ CallLocation::new(&e.span()),
|| "error statement".to_owned(),
|| bail!(RuntimeError(evaluate(ctx, e)?.to_string()?,)),
)?,
IfElse(if_else) => {
if in_frame(
- CallLocation::new(&loc),
+ CallLocation::new(&if_else.cond.0.span()),
|| "if condition".to_owned(),
|| bool::from_untyped(evaluate(ctx.clone(), &if_else.cond.0)?),
)? {
crates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs
@@ -1,6 +1,6 @@
use std::cmp::Ordering;
-use jrsonnet_parser::{BinaryOpType, Expr, Spanned, UnaryOpType};
+use jrsonnet_ir::{BinaryOpType, Expr, Spanned, UnaryOpType};
use crate::{
arr::ArrValue,
crates/jrsonnet-evaluator/src/function/builtin.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/builtin.rs
+++ b/crates/jrsonnet-evaluator/src/function/builtin.rs
@@ -1,7 +1,7 @@
use std::any::Any;
use jrsonnet_gcmodule::{cc_dyn, Trace, TraceBox};
-use jrsonnet_parser::function::{FunctionSignature, ParamDefault, ParamName, ParamParse};
+use jrsonnet_ir::function::{FunctionSignature, ParamDefault, ParamName, ParamParse};
use super::CallLocation;
use crate::{Result, Thunk, Val};
crates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/mod.rs
+++ b/crates/jrsonnet-evaluator/src/function/mod.rs
@@ -4,7 +4,7 @@
use jrsonnet_gcmodule::{Cc, Trace};
use jrsonnet_interner::IStr;
pub use jrsonnet_macros::builtin;
-use jrsonnet_parser::{ArgsDesc, Destruct, Expr, ExprParams, Span, Spanned};
+use jrsonnet_ir::{ArgsDesc, Destruct, Expr, ExprParams, Span, Spanned};
use self::{
builtin::{Builtin, StaticBuiltin},
@@ -24,7 +24,7 @@
pub use native::NativeFn;
pub use prepared::PreparedFuncVal;
-pub use jrsonnet_parser::function::*;
+pub use jrsonnet_ir::function::*;
/// Function callsite location.
/// Either from other jsonnet code, specified by expression location, or from native (without location).
crates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/parse.rs
+++ b/crates/jrsonnet-evaluator/src/function/parse.rs
@@ -1,6 +1,6 @@
use std::rc::Rc;
-use jrsonnet_parser::{
+use jrsonnet_ir::{
function::{FunctionSignature, ParamName},
ArgsDesc, Expr, ExprParams, Spanned,
};
crates/jrsonnet-evaluator/src/function/prepared.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/prepared.rs
+++ b/crates/jrsonnet-evaluator/src/function/prepared.rs
@@ -1,8 +1,8 @@
use std::rc::Rc;
use jrsonnet_gcmodule::{Acyclic, Trace};
-use jrsonnet_parser::function::FunctionSignature;
-use jrsonnet_parser::{ExprParams, IStr};
+use jrsonnet_ir::function::FunctionSignature;
+use jrsonnet_ir::{ExprParams, IStr};
use rustc_hash::{FxHashMap, FxHashSet};
use crate::destructure::destruct;
crates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/import.rs
+++ b/crates/jrsonnet-evaluator/src/import.rs
@@ -10,7 +10,7 @@
use fs::File;
use jrsonnet_gcmodule::Acyclic;
use jrsonnet_interner::IBytes;
-use jrsonnet_parser::{
+use jrsonnet_ir::{
IStr, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,
};
crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -44,8 +44,9 @@
pub use jrsonnet_interner::{IBytes, IStr};
#[doc(hidden)]
pub use jrsonnet_macros;
-pub use jrsonnet_parser as parser;
-use jrsonnet_parser::{Expr, ParserSettings, Source, SourcePath, Spanned};
+pub use jrsonnet_ir as parser;
+use jrsonnet_ir::{Expr, Source, SourcePath, Spanned};
+use jrsonnet_peg_parser::ParserSettings;
pub use obj::*;
pub use rustc_hash;
use rustc_hash::FxHashMap;
@@ -344,7 +345,7 @@
let file_name = Source::new(path.clone(), code.clone());
if file.parsed.is_none() {
file.parsed = Some(
- jrsonnet_parser::parse(
+ jrsonnet_peg_parser::parse(
&code,
&ParserSettings {
source: file_name.clone(),
@@ -460,7 +461,7 @@
pub fn evaluate_snippet(&self, name: impl Into<IStr>, code: impl Into<IStr>) -> Result<Val> {
let code = code.into();
let source = Source::new_virtual(name.into(), code.clone());
- let parsed = jrsonnet_parser::parse(
+ let parsed = jrsonnet_peg_parser::parse(
&code,
&ParserSettings {
source: source.clone(),
@@ -481,7 +482,7 @@
) -> Result<Val> {
let code = code.into();
let source = Source::new_virtual(name.into(), code.clone());
- let parsed = jrsonnet_parser::parse(
+ let parsed = jrsonnet_peg_parser::parse(
&code,
&ParserSettings {
source: source.clone(),
crates/jrsonnet-evaluator/src/obj/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/obj/mod.rs
+++ b/crates/jrsonnet-evaluator/src/obj/mod.rs
@@ -5,12 +5,12 @@
use educe::Educe;
use jrsonnet_gcmodule::{cc_dyn, Acyclic, Cc, Trace, Weak};
use jrsonnet_interner::IStr;
-use jrsonnet_parser::Span;
+use jrsonnet_ir::Span;
use rustc_hash::{FxHashMap, FxHashSet};
mod oop;
-pub use jrsonnet_parser::Visibility;
+pub use jrsonnet_ir::Visibility;
pub use oop::ObjValueBuilder;
use crate::{
crates/jrsonnet-evaluator/src/obj/oop.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/obj/oop.rs
+++ b/crates/jrsonnet-evaluator/src/obj/oop.rs
@@ -8,7 +8,7 @@
bail, error::ErrorKind::*, in_frame, CcUnbound, MaybeUnbound, Result, Thunk, Unbound, Val,
};
use jrsonnet_gcmodule::{Cc, Trace};
-use jrsonnet_parser::IStr;
+use jrsonnet_ir::IStr;
use rustc_hash::{FxHashMap, FxHashSet};
use super::ordering::{FieldIndex, SuperDepth};
crates/jrsonnet-evaluator/src/tla.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/tla.rs
+++ b/crates/jrsonnet-evaluator/src/tla.rs
@@ -2,7 +2,7 @@
use jrsonnet_gcmodule::Trace;
use jrsonnet_interner::IStr;
-use jrsonnet_parser::{SourceFifo, SourcePath};
+use jrsonnet_ir::{SourceFifo, SourcePath};
use crate::{
function::{CallLocation, PreparedFuncVal},
crates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/trace/mod.rs
+++ b/crates/jrsonnet-evaluator/src/trace/mod.rs
@@ -6,9 +6,9 @@
};
use jrsonnet_gcmodule::Trace;
-use jrsonnet_parser::CodeLocation;
+use jrsonnet_ir::CodeLocation;
#[cfg(feature = "explaining-traces")]
-use jrsonnet_parser::Span;
+use jrsonnet_ir::Span;
use crate::{error::ErrorKind, Error};
crates/jrsonnet-formatter/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-formatter/src/lib.rs
+++ b/crates/jrsonnet-formatter/src/lib.rs
@@ -855,7 +855,7 @@
}
pub struct FormatOptions {
- // 0 for hard tabs
+ // 0 for hard tabs, otherwise number of spaces
pub indent: u8,
}
crates/jrsonnet-ir/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/Cargo.toml
@@ -0,0 +1,24 @@
+[package]
+name = "jrsonnet-ir"
+description = "jsonnet language parser and AST"
+authors.workspace = true
+edition.workspace = true
+license.workspace = true
+repository.workspace = true
+version.workspace = true
+
+[features]
+default = []
+exp-destruct = []
+exp-null-coaelse = []
+
+[dependencies]
+jrsonnet-interner.workspace = true
+jrsonnet-gcmodule.workspace = true
+
+static_assertions.workspace = true
+
+peg.workspace = true
+
+[dev-dependencies]
+insta.workspace = true
crates/jrsonnet-ir/README.adocdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/README.adoc
@@ -0,0 +1,3 @@
+= jrsonnet-parser
+
+Parser for jsonnet language
crates/jrsonnet-ir/src/expr.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/src/expr.rs
@@ -0,0 +1,493 @@
+use std::{
+ fmt::{self, Debug, Display},
+ ops::Deref,
+ rc::Rc,
+};
+
+use jrsonnet_gcmodule::Acyclic;
+use jrsonnet_interner::IStr;
+
+use crate::{
+ function::{FunctionSignature, ParamDefault, ParamName, ParamParse},
+ source::Source,
+};
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub enum FieldName {
+ /// {fixed: 2}
+ Fixed(IStr),
+ /// {["dyn"+"amic"]: 3}
+ Dyn(Spanned<Expr>),
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]
+#[repr(u8)]
+pub enum Visibility {
+ /// :
+ Normal,
+ /// ::
+ Hidden,
+ /// :::
+ Unhide,
+}
+
+impl Visibility {
+ pub fn is_visible(&self) -> bool {
+ matches!(self, Self::Normal | Self::Unhide)
+ }
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct AssertStmt(pub Spanned<Expr>, pub Option<Spanned<Expr>>);
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct FieldMember {
+ pub name: FieldName,
+ pub plus: bool,
+ pub params: Option<ExprParams>,
+ pub visibility: Visibility,
+ pub value: Rc<Spanned<Expr>>,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub enum Member {
+ Field(FieldMember),
+ BindStmt(BindSpec),
+ AssertStmt(AssertStmt),
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]
+pub enum UnaryOpType {
+ Plus,
+ Minus,
+ BitNot,
+ Not,
+}
+
+impl Display for UnaryOpType {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ use UnaryOpType::*;
+ write!(
+ f,
+ "{}",
+ match self {
+ Plus => "+",
+ Minus => "-",
+ BitNot => "~",
+ Not => "!",
+ }
+ )
+ }
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]
+pub enum BinaryOpType {
+ Mul,
+ Div,
+
+ /// Implemented as intrinsic, put here for completeness
+ Mod,
+
+ Add,
+ Sub,
+
+ Lhs,
+ Rhs,
+
+ Lt,
+ Gt,
+ Lte,
+ Gte,
+
+ BitAnd,
+ BitOr,
+ BitXor,
+
+ Eq,
+ Neq,
+
+ And,
+ Or,
+ #[cfg(feature = "exp-null-coaelse")]
+ NullCoaelse,
+
+ // Equialent to std.objectHasEx(a, b, true)
+ In,
+}
+
+impl Display for BinaryOpType {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ use BinaryOpType::*;
+ write!(
+ f,
+ "{}",
+ match self {
+ Mul => "*",
+ Div => "/",
+ Mod => "%",
+ Add => "+",
+ Sub => "-",
+ Lhs => "<<",
+ Rhs => ">>",
+ Lt => "<",
+ Gt => ">",
+ Lte => "<=",
+ Gte => ">=",
+ BitAnd => "&",
+ BitOr => "|",
+ BitXor => "^",
+ Eq => "==",
+ Neq => "!=",
+ And => "&&",
+ Or => "||",
+ In => "in",
+ #[cfg(feature = "exp-null-coaelse")]
+ NullCoaelse => "??",
+ }
+ )
+ }
+}
+
+/// name, default value
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct ExprParam {
+ pub destruct: Destruct,
+ pub default: Option<Rc<Spanned<Expr>>>,
+}
+
+/// Defined function parameters
+#[derive(Debug, Clone, PartialEq, Acyclic)]
+pub struct ExprParams {
+ pub exprs: Rc<Vec<ExprParam>>,
+ pub signature: FunctionSignature,
+ binds_len: usize,
+}
+impl ExprParams {
+ pub fn len(&self) -> usize {
+ self.exprs.len()
+ }
+ pub fn is_empty(&self) -> bool {
+ self.exprs.is_empty()
+ }
+
+ pub fn binds_len(&self) -> usize {
+ self.binds_len
+ }
+ pub fn new(exprs: Vec<ExprParam>) -> Self {
+ Self {
+ signature: FunctionSignature::new(
+ exprs
+ .iter()
+ .map(|p| {
+ ParamParse::new(
+ p.destruct.name(),
+ ParamDefault::exists(p.default.is_some()),
+ )
+ })
+ .collect(),
+ ),
+ binds_len: exprs.iter().map(|v| v.destruct.binds_len()).sum(),
+ exprs: Rc::new(exprs),
+ }
+ }
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct ArgsDesc {
+ pub unnamed: Vec<Rc<Spanned<Expr>>>,
+ pub named: Vec<(IStr, Rc<Spanned<Expr>>)>,
+}
+impl ArgsDesc {
+ pub fn new(unnamed: Vec<Rc<Spanned<Expr>>>, named: Vec<(IStr, Rc<Spanned<Expr>>)>) -> Self {
+ Self { unnamed, named }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Acyclic)]
+pub enum DestructRest {
+ /// ...rest
+ Keep(IStr),
+ /// ...
+ Drop,
+}
+
+#[derive(Debug, Clone, PartialEq, Acyclic)]
+pub enum Destruct {
+ Full(IStr),
+ #[cfg(feature = "exp-destruct")]
+ Skip,
+ #[cfg(feature = "exp-destruct")]
+ Array {
+ start: Vec<Destruct>,
+ rest: Option<DestructRest>,
+ end: Vec<Destruct>,
+ },
+ #[cfg(feature = "exp-destruct")]
+ Object {
+ #[allow(clippy::type_complexity)]
+ fields: Vec<(IStr, Option<Destruct>, Option<Rc<Spanned<Expr>>>)>,
+ rest: Option<DestructRest>,
+ },
+}
+impl Destruct {
+ /// Name of destructure, used for function parameter names
+ pub fn name(&self) -> ParamName {
+ match self {
+ Self::Full(name) => ParamName::Named(name.clone()),
+ #[cfg(feature = "exp-destruct")]
+ _ => ParamName::Unnamed,
+ }
+ }
+ pub fn binds_len(&self) -> usize {
+ #[cfg(feature = "exp-destruct")]
+ fn cap_rest(rest: &Option<DestructRest>) -> usize {
+ match rest {
+ Some(DestructRest::Keep(_)) => 1,
+ Some(DestructRest::Drop) => 0,
+ None => 0,
+ }
+ }
+ match self {
+ Self::Full(_) => 1,
+ #[cfg(feature = "exp-destruct")]
+ Self::Skip => 0,
+ #[cfg(feature = "exp-destruct")]
+ Self::Array { start, rest, end } => {
+ start.iter().map(Destruct::binds_len).sum::<usize>()
+ + end.iter().map(Destruct::binds_len).sum::<usize>()
+ + cap_rest(rest)
+ }
+ #[cfg(feature = "exp-destruct")]
+ Self::Object { fields, rest } => {
+ let mut out = 0;
+ for (_, into, _) in fields {
+ match into {
+ Some(v) => out += v.binds_len(),
+ // Field is destructured to default name
+ None => out += 1,
+ }
+ }
+ out + cap_rest(rest)
+ }
+ }
+ }
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub enum BindSpec {
+ Field {
+ into: Destruct,
+ value: Rc<Spanned<Expr>>,
+ },
+ Function {
+ name: IStr,
+ params: ExprParams,
+ value: Rc<Spanned<Expr>>,
+ },
+}
+impl BindSpec {
+ pub fn binds_len(&self) -> usize {
+ match self {
+ BindSpec::Field { into, .. } => into.binds_len(),
+ BindSpec::Function { .. } => 1,
+ }
+ }
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct IfSpecData(pub Spanned<Expr>);
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct ForSpecData(pub Destruct, pub Spanned<Expr>);
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub enum CompSpec {
+ IfSpec(IfSpecData),
+ ForSpec(ForSpecData),
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct ObjComp {
+ pub locals: Rc<Vec<BindSpec>>,
+ pub field: Rc<FieldMember>,
+ pub compspecs: Vec<CompSpec>,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct ObjMembers {
+ pub locals: Rc<Vec<BindSpec>>,
+ pub asserts: Rc<Vec<AssertStmt>>,
+ pub fields: Vec<FieldMember>,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub enum ObjBody {
+ MemberList(ObjMembers),
+ ObjComp(ObjComp),
+}
+
+#[derive(Debug, PartialEq, Eq, Clone, Copy, Acyclic)]
+pub enum LiteralType {
+ This,
+ Super,
+ Dollar,
+ Null,
+ True,
+ False,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct SliceDesc {
+ pub start: Option<Spanned<Expr>>,
+ pub end: Option<Spanned<Expr>>,
+ pub step: Option<Spanned<Expr>>,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct AssertExpr {
+ pub assert: AssertStmt,
+ pub rest: Spanned<Expr>,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct BinaryOp {
+ pub lhs: Spanned<Expr>,
+ pub op: BinaryOpType,
+ pub rhs: Spanned<Expr>,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub enum ImportKind {
+ Normal,
+ Str,
+ Bin,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct IfElse {
+ pub cond: IfSpecData,
+ pub cond_then: Spanned<Expr>,
+ pub cond_else: Option<Spanned<Expr>>,
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct Slice {
+ pub value: Spanned<Expr>,
+ pub slice: SliceDesc,
+}
+
+/// Syntax base
+#[derive(Debug, PartialEq, Acyclic)]
+pub enum Expr {
+ Literal(LiteralType),
+
+ /// String value: "hello"
+ Str(IStr),
+ /// Number: 1, 2.0, 2e+20
+ Num(f64),
+ /// Variable name: test
+ Var(Spanned<IStr>),
+
+ /// Array of expressions: [1, 2, "Hello"]
+ Arr(Rc<Vec<Spanned<Expr>>>),
+ /// Array comprehension:
+ /// ```jsonnet
+ /// ingredients: [
+ /// { kind: kind, qty: 4 / 3 }
+ /// for kind in [
+ /// 'Honey Syrup',
+ /// 'Lemon Juice',
+ /// 'Farmers Gin',
+ /// ]
+ /// ],
+ /// ```
+ ArrComp(Rc<Spanned<Expr>>, Vec<CompSpec>),
+
+ /// Object: {a: 2}
+ Obj(ObjBody),
+ /// Object extension: var1 {b: 2}
+ ObjExtend(Rc<Spanned<Expr>>, ObjBody),
+
+ /// -2
+ UnaryOp(UnaryOpType, Box<Spanned<Expr>>),
+ /// 2 - 2
+ BinaryOp(Box<BinaryOp>),
+ /// assert 2 == 2 : "Math is broken"
+ AssertExpr(Rc<AssertExpr>),
+ /// local a = 2; { b: a }
+ LocalExpr(Vec<BindSpec>, Box<Spanned<Expr>>),
+
+ /// import* "hello"
+ Import(ImportKind, Box<Spanned<Expr>>),
+ /// error "I'm broken"
+ ErrorStmt(Box<Spanned<Expr>>),
+ /// a(b, c)
+ Apply(Box<Spanned<Expr>>, Spanned<ArgsDesc>, bool),
+ /// a[b], a.b, a?.b
+ Index {
+ indexable: Box<Spanned<Expr>>,
+ parts: Vec<IndexPart>,
+ },
+ /// function(x) x
+ Function(ExprParams, Rc<Spanned<Expr>>),
+ /// if true == false then 1 else 2
+ IfElse(Box<IfElse>),
+ Slice(Box<Slice>),
+}
+
+#[derive(Debug, PartialEq, Acyclic)]
+pub struct IndexPart {
+ pub value: Spanned<Expr>,
+ #[cfg(feature = "exp-null-coaelse")]
+ pub null_coaelse: bool,
+}
+
+/// file, begin offset, end offset
+#[derive(Clone, PartialEq, Eq, Acyclic)]
+#[repr(C)]
+pub struct Span(pub Source, pub u32, pub u32);
+impl Span {
+ pub fn belongs_to(&self, other: &Span) -> bool {
+ other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2
+ }
+}
+
+static_assertions::assert_eq_size!(Span, (usize, usize));
+
+impl Debug for Span {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)
+ }
+}
+
+#[derive(Clone, PartialEq, Acyclic)]
+pub struct Spanned<T: Acyclic>(T, Span);
+impl<T: Acyclic> Deref for Spanned<T> {
+ type Target = T;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+impl<T: Acyclic> Spanned<T> {
+ #[inline]
+ pub fn new(v: T, s: Span) -> Self {
+ Self(v, s)
+ }
+ #[inline]
+ pub fn span(&self) -> Span {
+ self.1.clone()
+ }
+}
+
+impl<T: Debug + Acyclic> Debug for Spanned<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let expr = &**self;
+ if f.alternate() {
+ write!(f, "{:#?}", expr)?;
+ } else {
+ write!(f, "{:?}", expr)?;
+ }
+ write!(f, " from {:?}", self.span())?;
+ Ok(())
+ }
+}
crates/jrsonnet-ir/src/function.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/src/function.rs
@@ -0,0 +1,132 @@
+use std::fmt;
+use std::ops::Deref;
+use std::rc::Rc;
+
+use jrsonnet_gcmodule::Acyclic;
+use jrsonnet_interner::IStr;
+
+#[derive(Clone, Acyclic, Debug, PartialEq, Eq)]
+pub enum ParamName {
+ Unnamed,
+ Named(IStr),
+}
+impl ParamName {
+ pub fn as_str(&self) -> Option<&str> {
+ match self {
+ ParamName::Unnamed => None,
+ ParamName::Named(istr) => Some(istr),
+ }
+ }
+ pub fn is_anonymous(&self) -> bool {
+ matches!(self, Self::Unnamed)
+ }
+ pub fn is_named(&self) -> bool {
+ matches!(self, Self::Named(_))
+ }
+}
+impl PartialEq<IStr> for ParamName {
+ fn eq(&self, other: &IStr) -> bool {
+ match self {
+ ParamName::Unnamed => false,
+ ParamName::Named(istr) => istr == other,
+ }
+ }
+}
+
+impl fmt::Display for ParamName {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match &self {
+ Self::Named(v) => write!(f, "{v}"),
+ Self::Unnamed => write!(f, "<unnamed>"),
+ }
+ }
+}
+
+#[derive(Clone, Copy, Debug, Acyclic, PartialEq, Eq)]
+pub enum ParamDefault {
+ None,
+ Exists,
+ Literal(&'static str),
+}
+impl ParamDefault {
+ pub const fn exists(is_exists: bool) -> Self {
+ if is_exists {
+ Self::Exists
+ } else {
+ Self::None
+ }
+ }
+}
+impl fmt::Display for ParamDefault {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ ParamDefault::None => Ok(()),
+ ParamDefault::Exists => write!(f, " = <default>"),
+ ParamDefault::Literal(lit) => write!(f, " = {lit}"),
+ }
+ }
+}
+
+#[derive(Clone, Acyclic, Debug, PartialEq, Eq)]
+pub struct ParamParse {
+ name: ParamName,
+ default: ParamDefault,
+}
+impl ParamParse {
+ pub fn new(name: ParamName, default: ParamDefault) -> Self {
+ Self { name, default }
+ }
+ /// Parameter name for named call parsing
+ pub fn name(&self) -> &ParamName {
+ &self.name
+ }
+ pub fn default(&self) -> ParamDefault {
+ self.default
+ }
+ pub fn has_default(&self) -> bool {
+ !matches!(self.default, ParamDefault::None)
+ }
+}
+impl fmt::Display for ParamParse {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}{}", self.name, self.default)
+ }
+}
+
+#[derive(Debug, Clone, Acyclic, PartialEq, Eq)]
+pub struct FunctionSignature(Rc<[ParamParse]>);
+impl Deref for FunctionSignature {
+ type Target = [ParamParse];
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+thread_local! {
+ static EMPTY_SIGNATURE: FunctionSignature = FunctionSignature::new([].into());
+}
+
+impl FunctionSignature {
+ pub fn new(v: Rc<[ParamParse]>) -> Self {
+ Self(v)
+ }
+ pub fn empty() -> Self {
+ EMPTY_SIGNATURE.with(|p| p.clone())
+ }
+}
+impl fmt::Display for FunctionSignature {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ if self.0.is_empty() {
+ return write!(f, "(/*no arguments*/)");
+ }
+ write!(f, "(")?;
+ for (i, par) in self.0.iter().enumerate() {
+ if i != 0 {
+ write!(f, ", ")?;
+ }
+ write!(f, "{par}")?;
+ }
+ write!(f, ")")
+ }
+}
crates/jrsonnet-ir/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/src/lib.rs
@@ -0,0 +1,15 @@
+#![allow(clippy::redundant_closure_call, clippy::derive_partial_eq_without_eq)]
+
+mod expr;
+pub use expr::*;
+pub use jrsonnet_interner::IStr;
+pub mod function;
+mod location;
+mod source;
+pub mod unescape;
+
+pub use location::CodeLocation;
+pub use source::{
+ Source, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,
+ SourcePathT, SourceVirtual,
+};
crates/jrsonnet-ir/src/location.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/src/location.rs
@@ -0,0 +1,115 @@
+#[allow(clippy::module_name_repetitions)]
+#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
+pub struct CodeLocation {
+ pub offset: usize,
+
+ pub line: usize,
+ pub column: usize,
+
+ pub line_start_offset: usize,
+ pub line_end_offset: usize,
+}
+
+#[allow(clippy::module_name_repetitions)]
+pub fn location_to_offset(mut file: &str, mut line: usize, column: usize) -> Option<usize> {
+ let mut offset = 0;
+ while line > 1 {
+ let pos = file.find('\n')?;
+ offset += pos + 1;
+ file = &file[pos + 1..];
+ line -= 1;
+ }
+ offset += column - 1;
+ Some(offset)
+}
+
+#[allow(clippy::module_name_repetitions)]
+pub fn offset_to_location<const S: usize>(file: &str, offsets: &[u32; S]) -> [CodeLocation; S] {
+ if offsets.is_empty() {
+ return [CodeLocation::default(); S];
+ }
+ let mut line = 1;
+ let mut column = 1;
+ let max_offset = *offsets.iter().max().expect("offsets is not empty");
+
+ let mut offset_map = offsets
+ .iter()
+ .enumerate()
+ .map(|(pos, offset)| (*offset, pos))
+ .collect::<Vec<_>>();
+ offset_map.sort_by_key(|v| v.0);
+ offset_map.reverse();
+
+ let mut out = [CodeLocation::default(); S];
+ let mut with_no_known_line_ending = vec![];
+ let mut this_line_offset = 0;
+ for (pos, ch) in file
+ .chars()
+ .enumerate()
+ .chain(std::iter::once((file.len(), ' ')))
+ {
+ column += 1;
+ match offset_map.last() {
+ Some(x) if x.0 == pos as u32 => {
+ let out_idx = x.1;
+ with_no_known_line_ending.push(out_idx);
+ out[out_idx].offset = pos;
+ out[out_idx].line = line;
+ out[out_idx].column = column;
+ out[out_idx].line_start_offset = this_line_offset;
+ offset_map.pop();
+ }
+ _ => {}
+ }
+ if ch == '\n' {
+ line += 1;
+ column = 1;
+
+ for idx in with_no_known_line_ending.drain(..) {
+ out[idx].line_end_offset = pos;
+ }
+ this_line_offset = pos + 1;
+
+ if pos == max_offset as usize + 1 {
+ break;
+ }
+ }
+ }
+ let file_end = file.chars().count();
+ for idx in with_no_known_line_ending {
+ out[idx].line_end_offset = file_end;
+ }
+
+ out
+}
+
+#[cfg(test)]
+pub mod tests {
+ use super::{offset_to_location, CodeLocation};
+
+ #[test]
+ fn test() {
+ assert_eq!(
+ offset_to_location(
+ "hello world\n_______________________________________________________",
+ &[0, 14]
+ ),
+ [
+ CodeLocation {
+ offset: 0,
+ line: 1,
+ column: 2,
+ line_start_offset: 0,
+ line_end_offset: 11,
+ },
+ CodeLocation {
+ offset: 14,
+ line: 2,
+ column: 4,
+ line_start_offset: 12,
+ line_end_offset: 67
+ }
+ ]
+ )
+ }
+}
crates/jrsonnet-ir/src/source.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/src/source.rs
@@ -0,0 +1,307 @@
+use std::{
+ any::Any,
+ fmt::{self, Debug, Display},
+ hash::{Hash, Hasher},
+ path::{Path, PathBuf},
+ rc::Rc,
+};
+
+use jrsonnet_gcmodule::Acyclic;
+use jrsonnet_interner::{IBytes, IStr};
+
+use crate::location::{location_to_offset, offset_to_location, CodeLocation};
+
+macro_rules! any_ext_methods {
+ ($T:ident) => {
+ fn as_any(&self) -> &dyn Any;
+ fn dyn_hash(&self, hasher: &mut dyn Hasher);
+ fn dyn_eq(&self, other: &dyn $T) -> bool;
+ fn dyn_debug(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
+ };
+}
+macro_rules! any_ext_impl {
+ ($T:ident) => {
+ fn as_any(&self) -> &dyn Any {
+ self
+ }
+ fn dyn_hash(&self, mut hasher: &mut dyn Hasher) {
+ self.hash(&mut hasher)
+ }
+ fn dyn_eq(&self, other: &dyn $T) -> bool {
+ let Some(other) = other.as_any().downcast_ref::<Self>() else {
+ return false;
+ };
+ let this = <Self as $T>::as_any(self)
+ .downcast_ref::<Self>()
+ .expect("restricted by impl");
+ this == other
+ }
+ fn dyn_debug(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ <Self as std::fmt::Debug>::fmt(self, fmt)
+ }
+ };
+}
+macro_rules! any_ext {
+ ($T:ident) => {
+ impl Hash for dyn $T {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.dyn_hash(state)
+ }
+ }
+ impl PartialEq for dyn $T {
+ fn eq(&self, other: &Self) -> bool {
+ self.dyn_eq(other)
+ }
+ }
+ impl Eq for dyn $T {}
+ };
+}
+pub trait SourcePathT: Acyclic + Debug + Display {
+ /// This method should be checked by resolver before panicking with bad SourcePath input
+ /// if `true` - then resolver may threat this path as default, and default is usally a CWD
+ fn is_default(&self) -> bool;
+ fn path(&self) -> Option<&Path>;
+ any_ext_methods!(SourcePathT);
+}
+any_ext!(SourcePathT);
+
+/// Represents location of a file
+///
+/// Standard CLI only operates using
+/// - [`SourceFile`] - for any file
+/// - [`SourceDirectory`] - for resolution from CWD
+/// - [`SourceVirtual`] - for stdlib/ext-str
+/// - [`SourceFifo`] - for /dev/fd/X (This path may appear with `jrsonnet <(command_that_produces_jsonnet)`)
+///
+/// From all of those, only [`SourceVirtual`] may be constructed manually, any other path kind should be only obtained
+/// from assigned `ImportResolver`
+/// However, you should always check `is_default` method return, as it will return true for any paths, where default
+/// search location is applicable
+///
+/// Resolver may also return custom implementations of this trait, for example it may return http url in case of remotely loaded files
+#[derive(Eq, Clone, Acyclic)]
+pub struct SourcePath(Rc<dyn SourcePathT>);
+impl SourcePath {
+ pub fn new(inner: impl SourcePathT) -> Self {
+ Self(Rc::new(inner))
+ }
+ pub fn downcast_ref<T: SourcePathT>(&self) -> Option<&T> {
+ self.0.as_any().downcast_ref()
+ }
+ pub fn is_default(&self) -> bool {
+ self.0.is_default()
+ }
+ pub fn path(&self) -> Option<&Path> {
+ self.0.path()
+ }
+}
+impl Hash for SourcePath {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.0.hash(state);
+ }
+}
+impl PartialEq for SourcePath {
+ #[allow(clippy::op_ref)]
+ fn eq(&self, other: &Self) -> bool {
+ &*self.0 == &*other.0
+ }
+}
+impl Display for SourcePath {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", self.0)
+ }
+}
+impl Debug for SourcePath {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{:?}", self.0)
+ }
+}
+impl Default for SourcePath {
+ fn default() -> Self {
+ Self(Rc::new(SourceDefault))
+ }
+}
+
+#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
+struct SourceDefault;
+impl Display for SourceDefault {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "<default>")
+ }
+}
+impl SourcePathT for SourceDefault {
+ fn is_default(&self) -> bool {
+ true
+ }
+ fn path(&self) -> Option<&Path> {
+ None
+ }
+ any_ext_impl!(SourcePathT);
+}
+
+#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
+pub struct SourceDefaultIgnoreJpath;
+impl Display for SourceDefaultIgnoreJpath {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "<default (ignoring jpath)>")
+ }
+}
+impl SourcePathT for SourceDefaultIgnoreJpath {
+ fn is_default(&self) -> bool {
+ true
+ }
+ fn path(&self) -> Option<&Path> {
+ None
+ }
+ any_ext_impl!(SourcePathT);
+}
+
+/// Represents path to the file on the disk
+/// Directories shouldn't be put here, as resolution for files differs from resolution for directories:
+///
+/// When `file` is being resolved from `SourceFile(a/b/c)`, it should be resolved to `SourceFile(a/b/file)`,
+/// however if it is being resolved from `SourceDirectory(a/b/c)`, then it should be resolved to `SourceDirectory(a/b/c/file)`
+#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
+pub struct SourceFile(PathBuf);
+impl SourceFile {
+ pub fn new(path: PathBuf) -> Self {
+ Self(path)
+ }
+ pub fn path(&self) -> &Path {
+ &self.0
+ }
+}
+impl Display for SourceFile {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", self.0.display())
+ }
+}
+impl SourcePathT for SourceFile {
+ fn is_default(&self) -> bool {
+ false
+ }
+ fn path(&self) -> Option<&Path> {
+ Some(&self.0)
+ }
+ any_ext_impl!(SourcePathT);
+}
+
+/// Represents path to the directory on the disk
+///
+/// See also [`SourceFile`]
+#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
+pub struct SourceDirectory(PathBuf);
+impl SourceDirectory {
+ pub fn new(path: PathBuf) -> Self {
+ Self(path)
+ }
+ pub fn path(&self) -> &Path {
+ &self.0
+ }
+}
+impl Display for SourceDirectory {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", self.0.display())
+ }
+}
+impl SourcePathT for SourceDirectory {
+ fn is_default(&self) -> bool {
+ false
+ }
+ fn path(&self) -> Option<&Path> {
+ Some(&self.0)
+ }
+ any_ext_impl!(SourcePathT);
+}
+
+/// Represents virtual file, whose are located in memory, and shouldn't be cached
+///
+/// It is used for --ext-code=.../--tla-code=.../standard library source code by default,
+/// and user can construct arbitrary values by hand, without asking import resolver
+#[derive(Acyclic, Hash, PartialEq, Eq, Clone)]
+pub struct SourceVirtual(pub IStr);
+impl Display for SourceVirtual {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "virtual:{}", self.0)
+ }
+}
+impl fmt::Debug for SourceVirtual {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "virtual:{}", self.0)
+ }
+}
+impl SourcePathT for SourceVirtual {
+ fn is_default(&self) -> bool {
+ true
+ }
+ fn path(&self) -> Option<&Path> {
+ None
+ }
+ any_ext_impl!(SourcePathT);
+}
+
+/// Represents resolved FIFO file, those files may only be read once, and this type is only used for
+/// unix, where user might want to do `jrsonnet <(command_that_produces_jsonnet_source)`
+/// In most cases, user most probably want to use `jrsonnet -` instead of `jrsonnet /dev/stdin`
+/// for better cross-platform support.
+// PartialEq is limited to ptr equality
+#[allow(clippy::derived_hash_with_manual_eq)]
+#[derive(Acyclic, Debug, Hash)]
+pub struct SourceFifo(pub String, pub IBytes);
+impl PartialEq for SourceFifo {
+ fn eq(&self, other: &Self) -> bool {
+ std::ptr::eq(self, other)
+ }
+}
+impl fmt::Display for SourceFifo {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "fifo({:?})", self.0)
+ }
+}
+impl SourcePathT for SourceFifo {
+ fn is_default(&self) -> bool {
+ // In case of FD input, user won't expect relative paths to be resolved from /dev/fd/
+ true
+ }
+
+ fn path(&self) -> Option<&Path> {
+ None
+ }
+
+ any_ext_impl!(SourcePathT);
+}
+
+/// Either real file, or virtual
+/// Hash of FileName always have same value as raw Path, to make it possible to use with raw_entry_mut
+#[derive(Clone, PartialEq, Eq, Acyclic)]
+pub struct Source(pub Rc<(SourcePath, IStr)>);
+
+impl Source {
+ pub fn new(path: SourcePath, code: IStr) -> Self {
+ Self(Rc::new((path, code)))
+ }
+
+ pub fn new_virtual(name: IStr, code: IStr) -> Self {
+ Self::new(SourcePath::new(SourceVirtual(name)), code)
+ }
+
+ pub fn code(&self) -> &str {
+ &self.0 .1
+ }
+
+ pub fn source_path(&self) -> &SourcePath {
+ &self.0 .0
+ }
+
+ pub fn map_source_locations<const S: usize>(&self, locs: &[u32; S]) -> [CodeLocation; S] {
+ offset_to_location(&self.0 .1, locs)
+ }
+ pub fn map_from_source_location(&self, line: usize, column: usize) -> Option<usize> {
+ location_to_offset(&self.0 .1, line, column)
+ }
+}
+impl fmt::Debug for Source {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{:?}", self.0 .0)
+ }
+}
crates/jrsonnet-ir/src/unescape.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-ir/src/unescape.rs
@@ -0,0 +1,55 @@
+use std::str::Chars;
+
+fn decode_unicode(chars: &mut Chars) -> Option<u16> {
+ IntoIterator::into_iter([chars.next()?, chars.next()?, chars.next()?, chars.next()?])
+ .map(|c| c.to_digit(16).map(|f| f as u16))
+ .try_fold(0u16, |acc, v| Some((acc << 4) | (v?)))
+}
+
+pub fn unescape(s: &str) -> Option<String> {
+ let mut chars = s.chars();
+ let mut out = String::with_capacity(s.len());
+
+ while let Some(c) = chars.next() {
+ if c != '\\' {
+ out.push(c);
+ continue;
+ }
+ match chars.next()? {
+ c @ ('\\' | '"' | '\'') => out.push(c),
+ 'b' => out.push('\u{0008}'),
+ 'f' => out.push('\u{000c}'),
+ 'n' => out.push('\n'),
+ 'r' => out.push('\r'),
+ 't' => out.push('\t'),
+ 'u' => match decode_unicode(&mut chars)? {
+ // May only be second byte
+ 0xDC00..=0xDFFF => return None,
+ // Surrogate pair
+ n1 @ 0xD800..=0xDBFF => {
+ if chars.next() != Some('\\') {
+ return None;
+ }
+ if chars.next() != Some('u') {
+ return None;
+ }
+ let n2 = decode_unicode(&mut chars)?;
+ if !matches!(n2, 0xDC00..=0xDFFF) {
+ return None;
+ }
+ let n = (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + 0x1_0000;
+ out.push(char::from_u32(n)?);
+ }
+ n => out.push(char::from_u32(n as u32)?),
+ },
+ 'x' => {
+ let c = IntoIterator::into_iter([chars.next()?, chars.next()?])
+ .map(|c| c.to_digit(16))
+ .try_fold(0u32, |acc, v| Some((acc << 8) | (v?)))?;
+ out.push(char::from_u32(c)?)
+ }
+ _ => return None,
+ }
+ }
+ Some(out)
+}
crates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-parser/Cargo.toml
+++ /dev/null
@@ -1,24 +0,0 @@
-[package]
-name = "jrsonnet-parser"
-description = "jsonnet language parser and AST"
-authors.workspace = true
-edition.workspace = true
-license.workspace = true
-repository.workspace = true
-version.workspace = true
-
-[features]
-default = []
-exp-destruct = []
-exp-null-coaelse = []
-
-[dependencies]
-jrsonnet-interner.workspace = true
-jrsonnet-gcmodule.workspace = true
-
-static_assertions.workspace = true
-
-peg.workspace = true
-
-[dev-dependencies]
-insta.workspace = true
crates/jrsonnet-parser/README.adocdiffbeforeafterboth--- a/crates/jrsonnet-parser/README.adoc
+++ /dev/null
@@ -1,3 +0,0 @@
-= jrsonnet-parser
-
-Parser for jsonnet language
crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/expr.rs
+++ /dev/null
@@ -1,493 +0,0 @@
-use std::{
- fmt::{self, Debug, Display},
- ops::Deref,
- rc::Rc,
-};
-
-use jrsonnet_gcmodule::Acyclic;
-use jrsonnet_interner::IStr;
-
-use crate::{
- function::{FunctionSignature, ParamDefault, ParamName, ParamParse},
- source::Source,
-};
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub enum FieldName {
- /// {fixed: 2}
- Fixed(IStr),
- /// {["dyn"+"amic"]: 3}
- Dyn(Spanned<Expr>),
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]
-#[repr(u8)]
-pub enum Visibility {
- /// :
- Normal,
- /// ::
- Hidden,
- /// :::
- Unhide,
-}
-
-impl Visibility {
- pub fn is_visible(&self) -> bool {
- matches!(self, Self::Normal | Self::Unhide)
- }
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct AssertStmt(pub Spanned<Expr>, pub Option<Spanned<Expr>>);
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct FieldMember {
- pub name: FieldName,
- pub plus: bool,
- pub params: Option<ExprParams>,
- pub visibility: Visibility,
- pub value: Rc<Spanned<Expr>>,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub(crate) enum Member {
- Field(FieldMember),
- BindStmt(BindSpec),
- AssertStmt(AssertStmt),
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]
-pub enum UnaryOpType {
- Plus,
- Minus,
- BitNot,
- Not,
-}
-
-impl Display for UnaryOpType {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- use UnaryOpType::*;
- write!(
- f,
- "{}",
- match self {
- Plus => "+",
- Minus => "-",
- BitNot => "~",
- Not => "!",
- }
- )
- }
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]
-pub enum BinaryOpType {
- Mul,
- Div,
-
- /// Implemented as intrinsic, put here for completeness
- Mod,
-
- Add,
- Sub,
-
- Lhs,
- Rhs,
-
- Lt,
- Gt,
- Lte,
- Gte,
-
- BitAnd,
- BitOr,
- BitXor,
-
- Eq,
- Neq,
-
- And,
- Or,
- #[cfg(feature = "exp-null-coaelse")]
- NullCoaelse,
-
- // Equialent to std.objectHasEx(a, b, true)
- In,
-}
-
-impl Display for BinaryOpType {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- use BinaryOpType::*;
- write!(
- f,
- "{}",
- match self {
- Mul => "*",
- Div => "/",
- Mod => "%",
- Add => "+",
- Sub => "-",
- Lhs => "<<",
- Rhs => ">>",
- Lt => "<",
- Gt => ">",
- Lte => "<=",
- Gte => ">=",
- BitAnd => "&",
- BitOr => "|",
- BitXor => "^",
- Eq => "==",
- Neq => "!=",
- And => "&&",
- Or => "||",
- In => "in",
- #[cfg(feature = "exp-null-coaelse")]
- NullCoaelse => "??",
- }
- )
- }
-}
-
-/// name, default value
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct ExprParam {
- pub destruct: Destruct,
- pub default: Option<Rc<Spanned<Expr>>>,
-}
-
-/// Defined function parameters
-#[derive(Debug, Clone, PartialEq, Acyclic)]
-pub struct ExprParams {
- pub exprs: Rc<Vec<ExprParam>>,
- pub signature: FunctionSignature,
- binds_len: usize,
-}
-impl ExprParams {
- pub fn len(&self) -> usize {
- self.exprs.len()
- }
- pub fn is_empty(&self) -> bool {
- self.exprs.is_empty()
- }
-
- pub fn binds_len(&self) -> usize {
- self.binds_len
- }
- pub fn new(exprs: Vec<ExprParam>) -> Self {
- Self {
- signature: FunctionSignature::new(
- exprs
- .iter()
- .map(|p| {
- ParamParse::new(
- p.destruct.name(),
- ParamDefault::exists(p.default.is_some()),
- )
- })
- .collect(),
- ),
- binds_len: exprs.iter().map(|v| v.destruct.binds_len()).sum(),
- exprs: Rc::new(exprs),
- }
- }
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct ArgsDesc {
- pub unnamed: Vec<Rc<Spanned<Expr>>>,
- pub named: Vec<(IStr, Rc<Spanned<Expr>>)>,
-}
-impl ArgsDesc {
- pub fn new(unnamed: Vec<Rc<Spanned<Expr>>>, named: Vec<(IStr, Rc<Spanned<Expr>>)>) -> Self {
- Self { unnamed, named }
- }
-}
-
-#[derive(Debug, Clone, PartialEq, Eq, Acyclic)]
-pub enum DestructRest {
- /// ...rest
- Keep(IStr),
- /// ...
- Drop,
-}
-
-#[derive(Debug, Clone, PartialEq, Acyclic)]
-pub enum Destruct {
- Full(IStr),
- #[cfg(feature = "exp-destruct")]
- Skip,
- #[cfg(feature = "exp-destruct")]
- Array {
- start: Vec<Destruct>,
- rest: Option<DestructRest>,
- end: Vec<Destruct>,
- },
- #[cfg(feature = "exp-destruct")]
- Object {
- #[allow(clippy::type_complexity)]
- fields: Vec<(IStr, Option<Destruct>, Option<Rc<Spanned<Expr>>>)>,
- rest: Option<DestructRest>,
- },
-}
-impl Destruct {
- /// Name of destructure, used for function parameter names
- pub fn name(&self) -> ParamName {
- match self {
- Self::Full(name) => ParamName::Named(name.clone()),
- #[cfg(feature = "exp-destruct")]
- _ => ParamName::Unnamed,
- }
- }
- pub fn binds_len(&self) -> usize {
- #[cfg(feature = "exp-destruct")]
- fn cap_rest(rest: &Option<DestructRest>) -> usize {
- match rest {
- Some(DestructRest::Keep(_)) => 1,
- Some(DestructRest::Drop) => 0,
- None => 0,
- }
- }
- match self {
- Self::Full(_) => 1,
- #[cfg(feature = "exp-destruct")]
- Self::Skip => 0,
- #[cfg(feature = "exp-destruct")]
- Self::Array { start, rest, end } => {
- start.iter().map(Destruct::binds_len).sum::<usize>()
- + end.iter().map(Destruct::binds_len).sum::<usize>()
- + cap_rest(rest)
- }
- #[cfg(feature = "exp-destruct")]
- Self::Object { fields, rest } => {
- let mut out = 0;
- for (_, into, _) in fields {
- match into {
- Some(v) => out += v.binds_len(),
- // Field is destructured to default name
- None => out += 1,
- }
- }
- out + cap_rest(rest)
- }
- }
- }
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub enum BindSpec {
- Field {
- into: Destruct,
- value: Rc<Spanned<Expr>>,
- },
- Function {
- name: IStr,
- params: ExprParams,
- value: Rc<Spanned<Expr>>,
- },
-}
-impl BindSpec {
- pub fn binds_len(&self) -> usize {
- match self {
- BindSpec::Field { into, .. } => into.binds_len(),
- BindSpec::Function { .. } => 1,
- }
- }
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct IfSpecData(pub Spanned<Expr>);
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct ForSpecData(pub Destruct, pub Spanned<Expr>);
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub enum CompSpec {
- IfSpec(IfSpecData),
- ForSpec(ForSpecData),
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct ObjComp {
- pub locals: Rc<Vec<BindSpec>>,
- pub field: Rc<FieldMember>,
- pub compspecs: Vec<CompSpec>,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct ObjMembers {
- pub locals: Rc<Vec<BindSpec>>,
- pub asserts: Rc<Vec<AssertStmt>>,
- pub fields: Vec<FieldMember>,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub enum ObjBody {
- MemberList(ObjMembers),
- ObjComp(ObjComp),
-}
-
-#[derive(Debug, PartialEq, Eq, Clone, Copy, Acyclic)]
-pub enum LiteralType {
- This,
- Super,
- Dollar,
- Null,
- True,
- False,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct SliceDesc {
- pub start: Option<Spanned<Expr>>,
- pub end: Option<Spanned<Expr>>,
- pub step: Option<Spanned<Expr>>,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct AssertExpr {
- pub assert: AssertStmt,
- pub rest: Spanned<Expr>,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct BinaryOp {
- pub lhs: Spanned<Expr>,
- pub op: BinaryOpType,
- pub rhs: Spanned<Expr>,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub enum ImportKind {
- Normal,
- Str,
- Bin,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct IfElse {
- pub cond: IfSpecData,
- pub cond_then: Spanned<Expr>,
- pub cond_else: Option<Spanned<Expr>>,
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct Slice {
- pub value: Spanned<Expr>,
- pub slice: SliceDesc,
-}
-
-/// Syntax base
-#[derive(Debug, PartialEq, Acyclic)]
-pub enum Expr {
- Literal(LiteralType),
-
- /// String value: "hello"
- Str(IStr),
- /// Number: 1, 2.0, 2e+20
- Num(f64),
- /// Variable name: test
- Var(IStr),
-
- /// Array of expressions: [1, 2, "Hello"]
- Arr(Rc<Vec<Spanned<Expr>>>),
- /// Array comprehension:
- /// ```jsonnet
- /// ingredients: [
- /// { kind: kind, qty: 4 / 3 }
- /// for kind in [
- /// 'Honey Syrup',
- /// 'Lemon Juice',
- /// 'Farmers Gin',
- /// ]
- /// ],
- /// ```
- ArrComp(Rc<Spanned<Expr>>, Vec<CompSpec>),
-
- /// Object: {a: 2}
- Obj(ObjBody),
- /// Object extension: var1 {b: 2}
- ObjExtend(Rc<Spanned<Expr>>, ObjBody),
-
- /// -2
- UnaryOp(UnaryOpType, Box<Spanned<Expr>>),
- /// 2 - 2
- BinaryOp(Box<BinaryOp>),
- /// assert 2 == 2 : "Math is broken"
- AssertExpr(Rc<AssertExpr>),
- /// local a = 2; { b: a }
- LocalExpr(Vec<BindSpec>, Box<Spanned<Expr>>),
-
- /// import* "hello"
- Import(ImportKind, Box<Spanned<Expr>>),
- /// error "I'm broken"
- ErrorStmt(Box<Spanned<Expr>>),
- /// a(b, c)
- Apply(Box<Spanned<Expr>>, ArgsDesc, bool),
- /// a[b], a.b, a?.b
- Index {
- indexable: Box<Spanned<Expr>>,
- parts: Vec<IndexPart>,
- },
- /// function(x) x
- Function(ExprParams, Rc<Spanned<Expr>>),
- /// if true == false then 1 else 2
- IfElse(Box<IfElse>),
- Slice(Box<Slice>),
-}
-
-#[derive(Debug, PartialEq, Acyclic)]
-pub struct IndexPart {
- pub value: Spanned<Expr>,
- #[cfg(feature = "exp-null-coaelse")]
- pub null_coaelse: bool,
-}
-
-/// file, begin offset, end offset
-#[derive(Clone, PartialEq, Eq, Acyclic)]
-#[repr(C)]
-pub struct Span(pub Source, pub u32, pub u32);
-impl Span {
- pub fn belongs_to(&self, other: &Span) -> bool {
- other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2
- }
-}
-
-static_assertions::assert_eq_size!(Span, (usize, usize));
-
-impl Debug for Span {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)
- }
-}
-
-#[derive(Clone, PartialEq, Acyclic)]
-pub struct Spanned<T: Acyclic>(T, Span);
-impl<T: Acyclic> Deref for Spanned<T> {
- type Target = T;
- fn deref(&self) -> &Self::Target {
- &self.0
- }
-}
-impl<T: Acyclic> Spanned<T> {
- #[inline]
- pub fn new(v: T, s: Span) -> Self {
- Self(v, s)
- }
- #[inline]
- pub fn span(&self) -> Span {
- self.1.clone()
- }
-}
-
-impl<T: Debug + Acyclic> Debug for Spanned<T> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- let expr = &**self;
- if f.alternate() {
- write!(f, "{:#?}", expr)?;
- } else {
- write!(f, "{:?}", expr)?;
- }
- write!(f, " from {:?}", self.span())?;
- Ok(())
- }
-}
crates/jrsonnet-parser/src/function.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/function.rs
+++ /dev/null
@@ -1,132 +0,0 @@
-use std::fmt;
-use std::ops::Deref;
-use std::rc::Rc;
-
-use jrsonnet_gcmodule::Acyclic;
-use jrsonnet_interner::IStr;
-
-#[derive(Clone, Acyclic, Debug, PartialEq, Eq)]
-pub enum ParamName {
- Unnamed,
- Named(IStr),
-}
-impl ParamName {
- pub fn as_str(&self) -> Option<&str> {
- match self {
- ParamName::Unnamed => None,
- ParamName::Named(istr) => Some(istr),
- }
- }
- pub fn is_anonymous(&self) -> bool {
- matches!(self, Self::Unnamed)
- }
- pub fn is_named(&self) -> bool {
- matches!(self, Self::Named(_))
- }
-}
-impl PartialEq<IStr> for ParamName {
- fn eq(&self, other: &IStr) -> bool {
- match self {
- ParamName::Unnamed => false,
- ParamName::Named(istr) => istr == other,
- }
- }
-}
-
-impl fmt::Display for ParamName {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match &self {
- Self::Named(v) => write!(f, "{v}"),
- Self::Unnamed => write!(f, "<unnamed>"),
- }
- }
-}
-
-#[derive(Clone, Copy, Debug, Acyclic, PartialEq, Eq)]
-pub enum ParamDefault {
- None,
- Exists,
- Literal(&'static str),
-}
-impl ParamDefault {
- pub const fn exists(is_exists: bool) -> Self {
- if is_exists {
- Self::Exists
- } else {
- Self::None
- }
- }
-}
-impl fmt::Display for ParamDefault {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self {
- ParamDefault::None => Ok(()),
- ParamDefault::Exists => write!(f, " = <default>"),
- ParamDefault::Literal(lit) => write!(f, " = {lit}"),
- }
- }
-}
-
-#[derive(Clone, Acyclic, Debug, PartialEq, Eq)]
-pub struct ParamParse {
- name: ParamName,
- default: ParamDefault,
-}
-impl ParamParse {
- pub fn new(name: ParamName, default: ParamDefault) -> Self {
- Self { name, default }
- }
- /// Parameter name for named call parsing
- pub fn name(&self) -> &ParamName {
- &self.name
- }
- pub fn default(&self) -> ParamDefault {
- self.default
- }
- pub fn has_default(&self) -> bool {
- !matches!(self.default, ParamDefault::None)
- }
-}
-impl fmt::Display for ParamParse {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}{}", self.name, self.default)
- }
-}
-
-#[derive(Debug, Clone, Acyclic, PartialEq, Eq)]
-pub struct FunctionSignature(Rc<[ParamParse]>);
-impl Deref for FunctionSignature {
- type Target = [ParamParse];
-
- fn deref(&self) -> &Self::Target {
- &self.0
- }
-}
-
-thread_local! {
- static EMPTY_SIGNATURE: FunctionSignature = FunctionSignature::new([].into());
-}
-
-impl FunctionSignature {
- pub fn new(v: Rc<[ParamParse]>) -> Self {
- Self(v)
- }
- pub fn empty() -> Self {
- EMPTY_SIGNATURE.with(|p| p.clone())
- }
-}
-impl fmt::Display for FunctionSignature {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- if self.0.is_empty() {
- return write!(f, "(/*no arguments*/)");
- }
- write!(f, "(")?;
- for (i, par) in self.0.iter().enumerate() {
- if i != 0 {
- write!(f, ", ")?;
- }
- write!(f, "{par}")?;
- }
- write!(f, ")")
- }
-}
crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/lib.rs
+++ /dev/null
@@ -1,553 +0,0 @@
-#![allow(clippy::redundant_closure_call, clippy::derive_partial_eq_without_eq)]
-
-use std::rc::Rc;
-
-use peg::parser;
-mod expr;
-pub use expr::*;
-pub use jrsonnet_interner::IStr;
-pub use peg;
-pub mod function;
-mod location;
-mod source;
-mod unescape;
-
-pub use location::CodeLocation;
-pub use source::{
- Source, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,
- SourcePathT, SourceVirtual,
-};
-
-pub struct ParserSettings {
- pub source: Source,
-}
-
-macro_rules! expr_bin {
- ($a:ident $op:ident $b:ident) => {
- Expr::BinaryOp(Box::new(BinaryOp {
- lhs: $a,
- op: $op,
- rhs: $b,
- }))
- };
-}
-macro_rules! expr_un {
- ($op:ident $a:ident) => {
- Expr::UnaryOp($op, Box::new($a))
- };
-}
-
-parser! {
- grammar jsonnet_parser() for str {
- use peg::ParseLiteral;
-
- rule eof() = quiet!{![_]} / expected!("<eof>")
- rule eol() = "\n" / eof()
-
- /// Standard C-like comments
- rule comment()
- = "//" (!eol()[_])* eol()
- / "/*" (!("*/")[_])* "*/"
- / "#" (!eol()[_])* eol()
-
- rule single_whitespace() = quiet!{([' ' | '\r' | '\n' | '\t'] / comment())} / expected!("<whitespace>")
- rule _() = quiet!{([' ' | '\r' | '\n' | '\t']+) / comment()}* / expected!("<whitespace>")
-
- /// For comma-delimited elements
- rule comma() = quiet!{_ "," _} / expected!("<comma>")
- rule alpha() -> char = c:$(['_' | 'a'..='z' | 'A'..='Z']) {c.chars().next().unwrap()}
- rule digit() -> char = d:$(['0'..='9']) {d.chars().next().unwrap()}
- rule end_of_ident() = !['0'..='9' | '_' | 'a'..='z' | 'A'..='Z']
- /// Sequence of digits
- rule uint_str() -> &'input str = a:$(digit()+ ("_" digit()+)*) { a }
- /// Number in scientific notation format
- rule number() -> f64 = quiet!{a:$(uint_str() ("." uint_str())? (['e'|'E'] (s:['+'|'-'])? uint_str())?) {? a.replace("_","").parse().map_err(|_| "<number>") }} / expected!("<number>")
-
- /// Reserved word followed by any non-alphanumberic
- rule reserved() = ("assert" / "else" / "error" / "false" / "for" / "function" / "if" / "import" / "importstr" / "importbin" / "in" / "local" / "null" / "tailstrict" / "then" / "self" / "super" / "true") end_of_ident()
- rule id() -> IStr = v:$(quiet!{ !reserved() alpha() (alpha() / digit())*} / expected!("<identifier>")) { v.into() }
-
- rule keyword(id: &'static str) -> ()
- = ##parse_string_literal(id) end_of_ident()
-
- pub rule param(s: &ParserSettings) -> expr::ExprParam = destruct:destruct(s) expr:(_ "=" _ expr:expr(s){expr})? { expr::ExprParam { destruct, default: expr.map(Rc::new) } }
- pub rule params(s: &ParserSettings) -> expr::ExprParams
- = params:param(s) ** comma() comma()? { expr::ExprParams::new(params) }
- / { expr::ExprParams::new(Vec::new()) }
-
- pub rule arg(s: &ParserSettings) -> (Option<IStr>, Rc<Spanned<Expr>>)
- = name:(quiet! { (s:id() _ "=" !['='] _ {s})? } / expected!("<argument name>")) expr:expr(s) {(name, Rc::new(expr))}
-
- pub rule args(s: &ParserSettings) -> expr::ArgsDesc
- = args:arg(s)**comma() comma()? {?
- let unnamed_count = args.iter().take_while(|(n, _)| n.is_none()).count();
- let mut unnamed = Vec::with_capacity(unnamed_count);
- let mut named = Vec::with_capacity(args.len() - unnamed_count);
- let mut named_started = false;
- for (name, value) in args {
- if let Some(name) = name {
- named_started = true;
- named.push((name, value));
- } else {
- if named_started {
- return Err("<named argument>")
- }
- unnamed.push(value);
- }
- }
- Ok(expr::ArgsDesc::new(unnamed, named))
- }
-
- pub rule destruct_rest() -> expr::DestructRest
- = "..." into:(_ into:id() {into})? {if let Some(into) = into {
- expr::DestructRest::Keep(into)
- } else {expr::DestructRest::Drop}}
- pub rule destruct_array(s: &ParserSettings) -> expr::Destruct
- = "[" _ start:destruct(s)**comma() rest:(
- comma() _ rest:destruct_rest()? end:(
- comma() end:destruct(s)**comma() (_ comma())? {end}
- / comma()? {Vec::new()}
- ) {(rest, end)}
- / comma()? {(None, Vec::new())}
- ) _ "]" {?
- #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Array {
- start,
- rest: rest.0,
- end: rest.1,
- });
- #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
- }
- pub rule destruct_object(s: &ParserSettings) -> expr::Destruct
- = "{" _
- fields:(name:id() into:(_ ":" _ into:destruct(s) {into})? default:(_ "=" _ v:expr(s) {v})? {(name, into, default.map(Rc::new))})**comma()
- rest:(
- comma() rest:destruct_rest()? {rest}
- / comma()? {None}
- )
- _ "}" {?
- #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Object {
- fields,
- rest,
- });
- #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
- }
- pub rule destruct(s: &ParserSettings) -> expr::Destruct
- = v:id() {expr::Destruct::Full(v)}
- / "?" {?
- #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Skip);
- #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
- }
- / arr:destruct_array(s) {arr}
- / obj:destruct_object(s) {obj}
-
- pub rule bind(s: &ParserSettings) -> expr::BindSpec
- = into:destruct(s) _ "=" _ value:expr(s) {expr::BindSpec::Field{into, value: Rc::new(value)}}
- / name:id() _ "(" _ params:params(s) _ ")" _ "=" _ value:expr(s) {expr::BindSpec::Function{name, params, value: Rc::new(value)}}
-
- pub rule assertion(s: &ParserSettings) -> expr::AssertStmt
- = keyword("assert") _ cond:expr(s) msg:(_ ":" _ e:expr(s) {e})? { expr::AssertStmt(cond, msg) }
-
- pub rule whole_line() -> &'input str
- = str:$((!['\n'][_])* "\n") {str}
- pub rule string_block() -> String
- = "|||" chomped:"-"? (!['\n']single_whitespace())* "\n"
- empty_lines:$(['\n']*)
- prefix:[' ' | '\t']+ first_line:whole_line()
- lines:("\n" {"\n"} / [' ' | '\t']*<{prefix.len()}> s:whole_line() {s})*
- [' ' | '\t']*<, {prefix.len() - 1}> "|||"
- {
- let mut l = empty_lines.to_owned();
- l.push_str(first_line);
- l.extend(lines);
- if chomped.is_some() {
- debug_assert!(l.ends_with('\n'));
- l.truncate(l.len() - 1);
- }
- l
- }
-
- rule hex_char()
- = quiet! { ['0'..='9' | 'a'..='f' | 'A'..='F'] } / expected!("<hex char>")
-
- rule string_char(c: rule<()>)
- = (!['\\']!c()[_])+
- / "\\\\"
- / "\\u" hex_char() hex_char() hex_char() hex_char()
- / "\\x" hex_char() hex_char()
- / ['\\'] (quiet! { ['b' | 'f' | 'n' | 'r' | 't' | '"' | '\''] } / expected!("<escape character>"))
- pub rule string() -> String
- = ['"'] str:$(string_char(<"\"">)*) ['"'] {? unescape::unescape(str).ok_or("<escaped string>")}
- / ['\''] str:$(string_char(<"\'">)*) ['\''] {? unescape::unescape(str).ok_or("<escaped string>")}
- / quiet!{ "@'" str:$(("''" / (!['\''][_]))*) "'" {str.replace("''", "'")}
- / "@\"" str:$(("\"\"" / (!['"'][_]))*) "\"" {str.replace("\"\"", "\"")}
- / string_block() } / expected!("<string>")
-
- pub rule field_name(s: &ParserSettings) -> expr::FieldName
- = name:id() {expr::FieldName::Fixed(name)}
- / name:string() {expr::FieldName::Fixed(name.into())}
- / "[" _ expr:expr(s) _ "]" {expr::FieldName::Dyn(expr)}
- pub rule visibility() -> expr::Visibility
- = ":::" {expr::Visibility::Unhide}
- / "::" {expr::Visibility::Hidden}
- / ":" {expr::Visibility::Normal}
- pub rule field(s: &ParserSettings) -> expr::FieldMember
- = name:field_name(s) _ plus:"+"? _ visibility:visibility() _ value:expr(s) {expr::FieldMember{
- name,
- plus: plus.is_some(),
- params: None,
- visibility,
- value: Rc::new(value),
- }}
- / name:field_name(s) _ "(" _ params:params(s) _ ")" _ visibility:visibility() _ value:expr(s) {expr::FieldMember{
- name,
- plus: false,
- params: Some(params),
- visibility,
- value: Rc::new(value),
- }}
- pub rule obj_local(s: &ParserSettings) -> BindSpec
- = keyword("local") _ bind:bind(s) {bind}
- pub rule member(s: &ParserSettings) -> expr::Member
- = bind:obj_local(s) {expr::Member::BindStmt(bind)}
- / 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})* &"[" field:field(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());
- let mut locals = pre_locals;
- locals.extend(post_locals);
- expr::ObjBody::ObjComp(expr::ObjComp{
- locals: Rc::new(locals),
- field: Rc::new(field),
- compspecs,
- })
- }
- / members:(member(s) ** comma()) comma()? {
- let mut locals = Vec::new();
- let mut asserts = Vec::new();
- let mut fields = Vec::new();
- for member in members {
- match member {
- Member::Field(field_member) => fields.push(field_member),
- Member::BindStmt(bind_spec) => locals.push(bind_spec),
- Member::AssertStmt(assert_stmt) => asserts.push(assert_stmt),
- }
- }
- expr::ObjBody::MemberList(ObjMembers {
- locals: Rc::new(locals), asserts: Rc::new(asserts), fields
- })
- }
- pub rule ifspec(s: &ParserSettings) -> IfSpecData
- = keyword("if") _ expr:expr(s) {IfSpecData(expr)}
- pub rule forspec(s: &ParserSettings) -> ForSpecData
- = keyword("for") _ id:destruct(s) _ keyword("in") _ cond:expr(s) {ForSpecData(id, cond)}
- pub rule compspec(s: &ParserSettings) -> Vec<expr::CompSpec>
- = s:(i:ifspec(s) { expr::CompSpec::IfSpec(i) } / f:forspec(s) {expr::CompSpec::ForSpec(f)} ) ** _ {s}
- pub rule local_expr(s: &ParserSettings) -> Expr
- = keyword("local") _ binds:bind(s) ** comma() (_ ",")? _ ";" _ expr:expr(s) { Expr::LocalExpr(binds, Box::new(expr)) }
- pub rule string_expr(s: &ParserSettings) -> Expr
- = s:string() {Expr::Str(s.into())}
- 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))}
- pub rule array_comp_expr(s: &ParserSettings) -> Expr
- = "[" _ expr:expr(s) _ comma()? _ forspec:forspec(s) _ others:(others: compspec(s) _ {others})? "]" {
- let mut specs = vec![CompSpec::ForSpec(forspec)];
- specs.extend(others.unwrap_or_default());
- Expr::ArrComp(Rc::new(expr), specs)
- }
- pub rule number_expr(s: &ParserSettings) -> Expr
- = n:number() {? if n.is_finite() {
- Ok(expr::Expr::Num(n))
- } else {
- Err("!!!numbers are finite")
- }}
- pub rule var_expr(s: &ParserSettings) -> Expr
- = n:id() { expr::Expr::Var(n) }
- pub rule id_loc(s: &ParserSettings) -> Spanned<Expr>
- = a:position!() n:id() b:position!() { Spanned::new(expr::Expr::Str(n), Span(s.source.clone(), a as u32,b as u32)) }
- pub rule if_then_else_expr(s: &ParserSettings) -> Expr
- = cond:ifspec(s) _ keyword("then") _ cond_then:expr(s) cond_else:(_ keyword("else") _ e:expr(s) {e})? {Expr::IfElse(Box::new(IfElse{
- cond,
- cond_then,
- cond_else,
- }))}
-
- pub rule literal(s: &ParserSettings) -> Expr
- = v:(
- keyword("null") {LiteralType::Null}
- / keyword("true") {LiteralType::True}
- / keyword("false") {LiteralType::False}
- / keyword("self") {LiteralType::This}
- / keyword("$") {LiteralType::Dollar}
- / keyword("super") {LiteralType::Super}
- ) {Expr::Literal(v)}
-
- rule import_kind() -> ImportKind
- = keyword("importstr") { ImportKind::Str }
- / keyword("importbin") { ImportKind::Bin }
- / keyword("import") { ImportKind::Normal }
-
- pub rule expr_basic(s: &ParserSettings) -> Expr
- = literal(s)
-
- / string_expr(s) / number_expr(s)
- / array_expr(s)
- / obj_expr(s)
- / array_expr(s)
- / array_comp_expr(s)
-
- / kind:import_kind() _ path:expr(s) {Expr::Import(kind, Box::new(path))}
-
- / var_expr(s)
- / 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{
- assert, rest
- })) }
-
- / keyword("error") _ expr:expr(s) { Expr::ErrorStmt(Box::new(expr)) }
-
- rule slice_part(s: &ParserSettings) -> Option<Spanned<Expr>>
- = _ e:(e:expr(s) _{e})? {e}
- pub rule slice_desc(s: &ParserSettings) -> SliceDesc
- = start:slice_part(s) ":" pair:(end:slice_part(s) step:(":" e:slice_part(s){e})? {(end, step.flatten())})? {
- let (end, step) = if let Some((end, step)) = pair {
- (end, step)
- }else{
- (None, None)
- };
-
- SliceDesc { start, end, step }
- }
-
- rule binop(x: rule<()>) -> ()
- = quiet!{ x() } / expected!("<binary op>")
- rule unaryop(x: rule<()>) -> ()
- = quiet!{ x() } / expected!("<unary op>")
-
- rule ensure_null_coaelse()
- = "" {?
- #[cfg(not(feature = "exp-null-coaelse"))] return Err("!!!experimental null coaelscing was not enabled");
- #[cfg(feature = "exp-null-coaelse")] Ok(())
- }
- use BinaryOpType::*;
- use UnaryOpType::*;
- rule expr(s: &ParserSettings) -> Spanned<Expr>
- = precedence! {
- "(" _ e:expr(s) _ ")" {e}
- start:position!() v:@ end:position!() { Spanned::new(v, Span(s.source.clone(), start as u32, end as u32)) }
- --
- a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)}
- a:(@) _ binop(<"??">) _ ensure_null_coaelse() b:@ {
- #[cfg(feature = "exp-null-coaelse")] return expr_bin!(a NullCoaelse b);
- unreachable!("ensure_null_coaelse will fail if feature is not enabled")
- }
- --
- a:(@) _ binop(<"&&">) _ b:@ {expr_bin!(a And b)}
- --
- a:(@) _ binop(<"|">) _ b:@ {expr_bin!(a BitOr b)}
- --
- a:@ _ binop(<"^">) _ b:(@) {expr_bin!(a BitXor b)}
- --
- a:(@) _ binop(<"&">) _ b:@ {expr_bin!(a BitAnd b)}
- --
- a:(@) _ binop(<"==">) _ b:@ {expr_bin!(a Eq b)}
- a:(@) _ binop(<"!=">) _ b:@ {expr_bin!(a Neq b)}
- --
- a:(@) _ binop(<"<">) _ b:@ {expr_bin!(a Lt b)}
- a:(@) _ binop(<">">) _ b:@ {expr_bin!(a Gt b)}
- a:(@) _ binop(<"<=">) _ b:@ {expr_bin!(a Lte b)}
- a:(@) _ binop(<">=">) _ b:@ {expr_bin!(a Gte b)}
- a:(@) _ binop(<keyword("in")>) _ b:@ {expr_bin!(a In b)}
- --
- a:(@) _ binop(<"<<">) _ b:@ {expr_bin!(a Lhs b)}
- a:(@) _ binop(<">>">) _ b:@ {expr_bin!(a Rhs b)}
- --
- a:(@) _ binop(<"+">) _ b:@ {expr_bin!(a Add b)}
- a:(@) _ binop(<"-">) _ b:@ {expr_bin!(a Sub b)}
- --
- a:(@) _ binop(<"*">) _ b:@ {expr_bin!(a Mul b)}
- a:(@) _ binop(<"/">) _ b:@ {expr_bin!(a Div b)}
- a:(@) _ binop(<"%">) _ b:@ {expr_bin!(a Mod b)}
- --
- unaryop(<"+">) _ b:@ {expr_un!(Plus b)}
- unaryop(<"-">) _ b:@ {expr_un!(Minus b)}
- unaryop(<"!">) _ b:@ {expr_un!(Not b)}
- unaryop(<"~">) _ b:@ {expr_un!(BitNot b)}
- --
- 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:args(s) _ ")" ts:(_ keyword("tailstrict"))? {Expr::Apply(Box::new(a), args, ts.is_some())}
- a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(Rc::new(a), body)}
- --
- e:expr_basic(s) {e}
- }
- pub rule index_part(s: &ParserSettings) -> IndexPart
- = n:("?" _ ensure_null_coaelse())? "." _ value:id_loc(s) {IndexPart {
- value,
- #[cfg(feature = "exp-null-coaelse")]
- null_coaelse: n.is_some(),
- }}
- / n:("?" _ "." _ ensure_null_coaelse())? "[" _ value:expr(s) _ "]" {IndexPart {
- value,
- #[cfg(feature = "exp-null-coaelse")]
- null_coaelse: n.is_some(),
- }}
-
- pub rule jsonnet(s: &ParserSettings) -> Spanned<Expr> = _ e:expr(s) _ {e}
- }
-}
-
-pub type ParseError = peg::error::ParseError<peg::str::LineCol>;
-pub fn parse(str: &str, settings: &ParserSettings) -> Result<Spanned<Expr>, ParseError> {
- jsonnet_parser::jsonnet(str, settings)
-}
-/// Used for importstr values
-pub fn string_to_expr(str: IStr, settings: &ParserSettings) -> Spanned<Expr> {
- let len = str.len();
- Spanned::new(Expr::Str(str), Span(settings.source.clone(), 0, len as u32))
-}
-
-#[cfg(test)]
-pub mod tests {
- use insta::assert_snapshot;
- use jrsonnet_interner::IStr;
-
- use super::parse;
- use crate::{source::Source, ParserSettings};
-
- fn parsep(s: &str) -> String {
- let v = parse(
- s,
- &ParserSettings {
- source: Source::new_virtual("<test>".into(), IStr::empty()),
- },
- )
- .unwrap();
- format!("{v:#?}")
- }
-
- macro_rules! parse {
- ($s:expr) => {
- assert_snapshot!(parsep($s));
- };
- }
-
- #[test]
- fn multiline_string() {
- parse!("|||\n Hello world!\n a\n|||");
- parse!("|||\n Hello world!\n a\n|||");
- parse!("|||\n\t\tHello world!\n\t\t\ta\n|||");
- parse!("|||\n Hello world!\n a\n |||");
- }
-
- #[test]
- fn slice() {
- parse!("a[1:]");
- parse!("a[1::]");
- parse!("a[:1:]");
- parse!("a[::1]");
- parse!("str[:len - 1]");
- }
-
- #[test]
- fn string_escaping() {
- parse!(r#""Hello, \"world\"!""#);
- parse!(r#"'Hello \'world\'!'"#);
- parse!(r#"'\\\\'"#);
- }
-
- #[test]
- fn string_unescaping() {
- parse!(r#""Hello\nWorld""#);
- }
-
- #[test]
- fn string_verbantim() {
- parse!(r#"@"Hello\n""World""""#);
- }
-
- #[test]
- fn imports() {
- parse!("import \"hello\"");
- parse!("importstr \"garnish.txt\"");
- parse!("importbin \"garnish.bin\"");
- }
-
- #[test]
- fn empty_object() {
- parse!("{}");
- }
-
- #[test]
- fn basic_math() {
- parse!("2+2*2");
- parse!("2 + 2 * 2 ");
- parse!("2+(2+2*2)");
- parse!("2//comment\n+//comment\n3/*test*/*/*test*/4");
- }
-
- #[test]
- fn suffix() {
- parse!("std.test");
- parse!("std(2)");
- parse!("std.test(2)");
- parse!("a[b]");
- }
-
- #[test]
- fn array_comp() {
- parse!("[std.deepJoin(x) for x in arr]");
- }
-
- #[test]
- fn reserved() {
- parse!("null");
- parse!("nulla");
- }
-
- #[test]
- fn multiple_args_buf() {
- parse!("a(b, null_fields)");
- }
-
- #[test]
- fn infix_precedence() {
- parse!("!a && !b");
- parse!("!a / !b");
- }
-
- #[test]
- fn double_negation() {
- parse!("!!a");
- }
-
- #[test]
- fn array_test_error() {
- parse!("[a for a in b if c for e in f]");
- }
-
- #[test]
- fn missing_newline_between_comment_and_eof() {
- parse!(
- "{a:1}
-
- //+213"
- );
- }
-
- #[test]
- fn default_param_before_nondefault() {
- parse!("local x(foo = 'foo', bar) = null; null");
- }
-
- #[test]
- fn add_location_info_to_all_sub_expressions() {
- parse!("{} { local x = 1, x: x } + {}");
- }
-}
crates/jrsonnet-parser/src/location.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/location.rs
+++ /dev/null
@@ -1,115 +0,0 @@
-#[allow(clippy::module_name_repetitions)]
-#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
-pub struct CodeLocation {
- pub offset: usize,
-
- pub line: usize,
- pub column: usize,
-
- pub line_start_offset: usize,
- pub line_end_offset: usize,
-}
-
-#[allow(clippy::module_name_repetitions)]
-pub fn location_to_offset(mut file: &str, mut line: usize, column: usize) -> Option<usize> {
- let mut offset = 0;
- while line > 1 {
- let pos = file.find('\n')?;
- offset += pos + 1;
- file = &file[pos + 1..];
- line -= 1;
- }
- offset += column - 1;
- Some(offset)
-}
-
-#[allow(clippy::module_name_repetitions)]
-pub fn offset_to_location<const S: usize>(file: &str, offsets: &[u32; S]) -> [CodeLocation; S] {
- if offsets.is_empty() {
- return [CodeLocation::default(); S];
- }
- let mut line = 1;
- let mut column = 1;
- let max_offset = *offsets.iter().max().expect("offsets is not empty");
-
- let mut offset_map = offsets
- .iter()
- .enumerate()
- .map(|(pos, offset)| (*offset, pos))
- .collect::<Vec<_>>();
- offset_map.sort_by_key(|v| v.0);
- offset_map.reverse();
-
- let mut out = [CodeLocation::default(); S];
- let mut with_no_known_line_ending = vec![];
- let mut this_line_offset = 0;
- for (pos, ch) in file
- .chars()
- .enumerate()
- .chain(std::iter::once((file.len(), ' ')))
- {
- column += 1;
- match offset_map.last() {
- Some(x) if x.0 == pos as u32 => {
- let out_idx = x.1;
- with_no_known_line_ending.push(out_idx);
- out[out_idx].offset = pos;
- out[out_idx].line = line;
- out[out_idx].column = column;
- out[out_idx].line_start_offset = this_line_offset;
- offset_map.pop();
- }
- _ => {}
- }
- if ch == '\n' {
- line += 1;
- column = 1;
-
- for idx in with_no_known_line_ending.drain(..) {
- out[idx].line_end_offset = pos;
- }
- this_line_offset = pos + 1;
-
- if pos == max_offset as usize + 1 {
- break;
- }
- }
- }
- let file_end = file.chars().count();
- for idx in with_no_known_line_ending {
- out[idx].line_end_offset = file_end;
- }
-
- out
-}
-
-#[cfg(test)]
-pub mod tests {
- use super::{offset_to_location, CodeLocation};
-
- #[test]
- fn test() {
- assert_eq!(
- offset_to_location(
- "hello world\n_______________________________________________________",
- &[0, 14]
- ),
- [
- CodeLocation {
- offset: 0,
- line: 1,
- column: 2,
- line_start_offset: 0,
- line_end_offset: 11,
- },
- CodeLocation {
- offset: 14,
- line: 2,
- column: 4,
- line_start_offset: 12,
- line_end_offset: 67
- }
- ]
- )
- }
-}
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__add_location_info_to_all_sub_expressions.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__add_location_info_to_all_sub_expressions.snap
+++ /dev/null
@@ -1,57 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"{} { local x = 1, x: x } + {}\")"
----
-BinaryOp(
- BinaryOp {
- lhs: ObjExtend(
- Obj(
- MemberList(
- ObjMembers {
- locals: [],
- asserts: [],
- fields: [],
- },
- ),
- ) from virtual:<test>:0-2,
- MemberList(
- ObjMembers {
- locals: [
- Field {
- into: Full(
- "x",
- ),
- value: Num(
- 1.0,
- ) from virtual:<test>:15-16,
- },
- ],
- asserts: [],
- fields: [
- FieldMember {
- name: Fixed(
- "x",
- ),
- plus: false,
- params: None,
- visibility: Normal,
- value: Var(
- "x",
- ) from virtual:<test>:21-22,
- },
- ],
- },
- ),
- ) from virtual:<test>:0-24,
- op: Add,
- rhs: Obj(
- MemberList(
- ObjMembers {
- locals: [],
- asserts: [],
- fields: [],
- },
- ),
- ) from virtual:<test>:27-29,
- },
-) from virtual:<test>:0-29
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_comp.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_comp.snap
+++ /dev/null
@@ -1,41 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"[std.deepJoin(x) for x in arr]\")"
----
-ArrComp(
- Apply(
- Index {
- indexable: Var(
- "std",
- ) from virtual:<test>:1-4,
- parts: [
- IndexPart {
- value: Str(
- "deepJoin",
- ) from virtual:<test>:5-13,
- },
- ],
- } from virtual:<test>:1-13,
- ArgsDesc {
- unnamed: [
- Var(
- "x",
- ) from virtual:<test>:14-15,
- ],
- named: [],
- },
- false,
- ) from virtual:<test>:1-16,
- [
- ForSpec(
- ForSpecData(
- Full(
- "x",
- ),
- Var(
- "arr",
- ) from virtual:<test>:26-29,
- ),
- ),
- ],
-) from virtual:<test>:0-30
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_test_error.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_test_error.snap
+++ /dev/null
@@ -1,38 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"[a for a in b if c for e in f]\")"
----
-ArrComp(
- Var(
- "a",
- ) from virtual:<test>:1-2,
- [
- ForSpec(
- ForSpecData(
- Full(
- "a",
- ),
- Var(
- "b",
- ) from virtual:<test>:12-13,
- ),
- ),
- IfSpec(
- IfSpecData(
- Var(
- "c",
- ) from virtual:<test>:17-18,
- ),
- ),
- ForSpec(
- ForSpecData(
- Full(
- "e",
- ),
- Var(
- "f",
- ) from virtual:<test>:28-29,
- ),
- ),
- ],
-) from virtual:<test>:0-30
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-2.snap
+++ /dev/null
@@ -1,23 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"2\t+ \t 2\t *\t2 \t\")"
----
-BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:0-1,
- op: Add,
- rhs: BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:7-8,
- op: Mul,
- rhs: Num(
- 2.0,
- ) from virtual:<test>:13-14,
- },
- ) from virtual:<test>:7-14,
- },
-) from virtual:<test>:0-14
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-3.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-3.snap
+++ /dev/null
@@ -1,31 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"2+(2+2*2)\")"
----
-BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:0-1,
- op: Add,
- rhs: BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:3-4,
- op: Add,
- rhs: BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:5-6,
- op: Mul,
- rhs: Num(
- 2.0,
- ) from virtual:<test>:7-8,
- },
- ) from virtual:<test>:5-8,
- },
- ) from virtual:<test>:3-8,
- },
-) from virtual:<test>:0-9
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-4.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-4.snap
+++ /dev/null
@@ -1,23 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"2//comment\\n+//comment\\n3/*test*/*/*test*/4\")"
----
-BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:0-1,
- op: Add,
- rhs: BinaryOp(
- BinaryOp {
- lhs: Num(
- 3.0,
- ) from virtual:<test>:22-23,
- op: Mul,
- rhs: Num(
- 4.0,
- ) from virtual:<test>:40-41,
- },
- ) from virtual:<test>:22-41,
- },
-) from virtual:<test>:0-41
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math.snap
+++ /dev/null
@@ -1,23 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"2+2*2\")"
----
-BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:0-1,
- op: Add,
- rhs: BinaryOp(
- BinaryOp {
- lhs: Num(
- 2.0,
- ) from virtual:<test>:2-3,
- op: Mul,
- rhs: Num(
- 2.0,
- ) from virtual:<test>:4-5,
- },
- ) from virtual:<test>:2-5,
- },
-) from virtual:<test>:0-5
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__default_param_before_nondefault.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__default_param_before_nondefault.snap
+++ /dev/null
@@ -1,54 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"local x(foo = 'foo', bar) = null; null\")"
----
-LocalExpr(
- [
- Function {
- name: "x",
- params: ExprParams {
- exprs: [
- ExprParam {
- destruct: Full(
- "foo",
- ),
- default: Some(
- Str(
- "foo",
- ) from virtual:<test>:14-19,
- ),
- },
- ExprParam {
- destruct: Full(
- "bar",
- ),
- default: None,
- },
- ],
- signature: FunctionSignature(
- [
- ParamParse {
- name: Named(
- "foo",
- ),
- default: Exists,
- },
- ParamParse {
- name: Named(
- "bar",
- ),
- default: None,
- },
- ],
- ),
- binds_len: 2,
- },
- value: Literal(
- Null,
- ) from virtual:<test>:28-32,
- },
- ],
- Literal(
- Null,
- ) from virtual:<test>:34-38,
-) from virtual:<test>:0-38
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__double_negation.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__double_negation.snap
+++ /dev/null
@@ -1,13 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"!!a\")"
----
-UnaryOp(
- Not,
- UnaryOp(
- Not,
- Var(
- "a",
- ) from virtual:<test>:2-3,
- ) from virtual:<test>:1-3,
-) from virtual:<test>:0-3
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__empty_object.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__empty_object.snap
+++ /dev/null
@@ -1,13 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"{}\")"
----
-Obj(
- MemberList(
- ObjMembers {
- locals: [],
- asserts: [],
- fields: [],
- },
- ),
-) from virtual:<test>:0-2
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-2.snap
+++ /dev/null
@@ -1,10 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"importstr \\\"garnish.txt\\\"\")"
----
-Import(
- Str,
- Str(
- "garnish.txt",
- ) from virtual:<test>:10-23,
-) from virtual:<test>:0-23
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-3.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-3.snap
+++ /dev/null
@@ -1,10 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"importbin \\\"garnish.bin\\\"\")"
----
-Import(
- Bin,
- Str(
- "garnish.bin",
- ) from virtual:<test>:10-23,
-) from virtual:<test>:0-23
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports.snap
+++ /dev/null
@@ -1,10 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"import \\\"hello\\\"\")"
----
-Import(
- Normal,
- Str(
- "hello",
- ) from virtual:<test>:7-14,
-) from virtual:<test>:0-14
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence-2.snap
+++ /dev/null
@@ -1,21 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"!a / !b\")"
----
-BinaryOp(
- BinaryOp {
- lhs: UnaryOp(
- Not,
- Var(
- "a",
- ) from virtual:<test>:1-2,
- ) from virtual:<test>:0-2,
- op: Div,
- rhs: UnaryOp(
- Not,
- Var(
- "b",
- ) from virtual:<test>:6-7,
- ) from virtual:<test>:5-7,
- },
-) from virtual:<test>:0-7
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence.snap
+++ /dev/null
@@ -1,21 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"!a && !b\")"
----
-BinaryOp(
- BinaryOp {
- lhs: UnaryOp(
- Not,
- Var(
- "a",
- ) from virtual:<test>:1-2,
- ) from virtual:<test>:0-2,
- op: And,
- rhs: UnaryOp(
- Not,
- Var(
- "b",
- ) from virtual:<test>:7-8,
- ) from virtual:<test>:6-8,
- },
-) from virtual:<test>:0-8
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__missing_newline_between_comment_and_eof.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__missing_newline_between_comment_and_eof.snap
+++ /dev/null
@@ -1,25 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"{a:1}\n\n\t\t\t//+213\")"
----
-Obj(
- MemberList(
- ObjMembers {
- locals: [],
- asserts: [],
- fields: [
- FieldMember {
- name: Fixed(
- "a",
- ),
- plus: false,
- params: None,
- visibility: Normal,
- value: Num(
- 1.0,
- ) from virtual:<test>:3-4,
- },
- ],
- },
- ),
-) from virtual:<test>:0-5
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-2.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"|||\\n Hello world!\\n a\\n|||\")"
----
-Str(
- "Hello world!\n a\n",
-) from virtual:<test>:0-27
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-3.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-3.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"|||\\n\\t\\tHello world!\\n\\t\\t\\ta\\n|||\")"
----
-Str(
- "Hello world!\n\ta\n",
-) from virtual:<test>:0-27
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-4.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-4.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"|||\\n Hello world!\\n a\\n |||\")"
----
-Str(
- "Hello world!\n a\n",
-) from virtual:<test>:0-30
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"|||\\n Hello world!\\n a\\n|||\")"
----
-Str(
- "Hello world!\n a\n",
-) from virtual:<test>:0-31
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiple_args_buf.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiple_args_buf.snap
+++ /dev/null
@@ -1,21 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"a(b, null_fields)\")"
----
-Apply(
- Var(
- "a",
- ) from virtual:<test>:0-1,
- ArgsDesc {
- unnamed: [
- Var(
- "b",
- ) from virtual:<test>:2-3,
- Var(
- "null_fields",
- ) from virtual:<test>:5-16,
- ],
- named: [],
- },
- false,
-) from virtual:<test>:0-17
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved-2.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"nulla\")"
----
-Var(
- "nulla",
-) from virtual:<test>:0-5
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"null\")"
----
-Literal(
- Null,
-) from virtual:<test>:0-4
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-2.snap
+++ /dev/null
@@ -1,20 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"a[1::]\")"
----
-Slice(
- Slice {
- value: Var(
- "a",
- ) from virtual:<test>:0-1,
- slice: SliceDesc {
- start: Some(
- Num(
- 1.0,
- ) from virtual:<test>:2-3,
- ),
- end: None,
- step: None,
- },
- },
-) from virtual:<test>:0-6
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-3.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-3.snap
+++ /dev/null
@@ -1,20 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"a[:1:]\")"
----
-Slice(
- Slice {
- value: Var(
- "a",
- ) from virtual:<test>:0-1,
- slice: SliceDesc {
- start: None,
- end: Some(
- Num(
- 1.0,
- ) from virtual:<test>:3-4,
- ),
- step: None,
- },
- },
-) from virtual:<test>:0-6
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-4.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-4.snap
+++ /dev/null
@@ -1,20 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"a[::1]\")"
----
-Slice(
- Slice {
- value: Var(
- "a",
- ) from virtual:<test>:0-1,
- slice: SliceDesc {
- start: None,
- end: None,
- step: Some(
- Num(
- 1.0,
- ) from virtual:<test>:4-5,
- ),
- },
- },
-) from virtual:<test>:0-6
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-5.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-5.snap
+++ /dev/null
@@ -1,28 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"str[:len - 1]\")"
----
-Slice(
- Slice {
- value: Var(
- "str",
- ) from virtual:<test>:0-3,
- slice: SliceDesc {
- start: None,
- end: Some(
- BinaryOp(
- BinaryOp {
- lhs: Var(
- "len",
- ) from virtual:<test>:5-8,
- op: Sub,
- rhs: Num(
- 1.0,
- ) from virtual:<test>:11-12,
- },
- ) from virtual:<test>:5-12,
- ),
- step: None,
- },
- },
-) from virtual:<test>:0-13
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice.snap
+++ /dev/null
@@ -1,20 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"a[1:]\")"
----
-Slice(
- Slice {
- value: Var(
- "a",
- ) from virtual:<test>:0-1,
- slice: SliceDesc {
- start: Some(
- Num(
- 1.0,
- ) from virtual:<test>:2-3,
- ),
- end: None,
- step: None,
- },
- },
-) from virtual:<test>:0-5
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-2.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(r#\"'Hello \\'world\\'!'\"#)"
----
-Str(
- "Hello 'world'!",
-) from virtual:<test>:0-18
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-3.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-3.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(r#\"'\\\\\\\\'\"#)"
----
-Str(
- "\\\\",
-) from virtual:<test>:0-6
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(r#\"\"Hello, \\\"world\\\"!\"\"#)"
----
-Str(
- "Hello, \"world\"!",
-) from virtual:<test>:0-19
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_unescaping.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_unescaping.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(r#\"\"Hello\\nWorld\"\"#)"
----
-Str(
- "Hello\nWorld",
-) from virtual:<test>:0-14
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_verbantim.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_verbantim.snap
+++ /dev/null
@@ -1,7 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(r#\"@\"Hello\\n\"\"World\"\"\"\"#)"
----
-Str(
- "Hello\\n\"World\"",
-) from virtual:<test>:0-19
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-2.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-2.snap
+++ /dev/null
@@ -1,18 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"std(2)\")"
----
-Apply(
- Var(
- "std",
- ) from virtual:<test>:0-3,
- ArgsDesc {
- unnamed: [
- Num(
- 2.0,
- ) from virtual:<test>:4-5,
- ],
- named: [],
- },
- false,
-) from virtual:<test>:0-6
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-3.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-3.snap
+++ /dev/null
@@ -1,27 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"std.test(2)\")"
----
-Apply(
- Index {
- indexable: Var(
- "std",
- ) from virtual:<test>:0-3,
- parts: [
- IndexPart {
- value: Str(
- "test",
- ) from virtual:<test>:4-8,
- },
- ],
- } from virtual:<test>:0-8,
- ArgsDesc {
- unnamed: [
- Num(
- 2.0,
- ) from virtual:<test>:9-10,
- ],
- named: [],
- },
- false,
-) from virtual:<test>:0-11
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-4.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-4.snap
+++ /dev/null
@@ -1,16 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"a[b]\")"
----
-Index {
- indexable: Var(
- "a",
- ) from virtual:<test>:0-1,
- parts: [
- IndexPart {
- value: Var(
- "b",
- ) from virtual:<test>:2-3,
- },
- ],
-} from virtual:<test>:0-4
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix.snapdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix.snap
+++ /dev/null
@@ -1,16 +0,0 @@
----
-source: crates/jrsonnet-parser/src/lib.rs
-expression: "parsep(\"std.test\")"
----
-Index {
- indexable: Var(
- "std",
- ) from virtual:<test>:0-3,
- parts: [
- IndexPart {
- value: Str(
- "test",
- ) from virtual:<test>:4-8,
- },
- ],
-} from virtual:<test>:0-8
crates/jrsonnet-parser/src/source.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/source.rs
+++ /dev/null
@@ -1,307 +0,0 @@
-use std::{
- any::Any,
- fmt::{self, Debug, Display},
- hash::{Hash, Hasher},
- path::{Path, PathBuf},
- rc::Rc,
-};
-
-use jrsonnet_gcmodule::Acyclic;
-use jrsonnet_interner::{IBytes, IStr};
-
-use crate::location::{location_to_offset, offset_to_location, CodeLocation};
-
-macro_rules! any_ext_methods {
- ($T:ident) => {
- fn as_any(&self) -> &dyn Any;
- fn dyn_hash(&self, hasher: &mut dyn Hasher);
- fn dyn_eq(&self, other: &dyn $T) -> bool;
- fn dyn_debug(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
- };
-}
-macro_rules! any_ext_impl {
- ($T:ident) => {
- fn as_any(&self) -> &dyn Any {
- self
- }
- fn dyn_hash(&self, mut hasher: &mut dyn Hasher) {
- self.hash(&mut hasher)
- }
- fn dyn_eq(&self, other: &dyn $T) -> bool {
- let Some(other) = other.as_any().downcast_ref::<Self>() else {
- return false;
- };
- let this = <Self as $T>::as_any(self)
- .downcast_ref::<Self>()
- .expect("restricted by impl");
- this == other
- }
- fn dyn_debug(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- <Self as std::fmt::Debug>::fmt(self, fmt)
- }
- };
-}
-macro_rules! any_ext {
- ($T:ident) => {
- impl Hash for dyn $T {
- fn hash<H: Hasher>(&self, state: &mut H) {
- self.dyn_hash(state)
- }
- }
- impl PartialEq for dyn $T {
- fn eq(&self, other: &Self) -> bool {
- self.dyn_eq(other)
- }
- }
- impl Eq for dyn $T {}
- };
-}
-pub trait SourcePathT: Acyclic + Debug + Display {
- /// This method should be checked by resolver before panicking with bad SourcePath input
- /// if `true` - then resolver may threat this path as default, and default is usally a CWD
- fn is_default(&self) -> bool;
- fn path(&self) -> Option<&Path>;
- any_ext_methods!(SourcePathT);
-}
-any_ext!(SourcePathT);
-
-/// Represents location of a file
-///
-/// Standard CLI only operates using
-/// - [`SourceFile`] - for any file
-/// - [`SourceDirectory`] - for resolution from CWD
-/// - [`SourceVirtual`] - for stdlib/ext-str
-/// - [`SourceFifo`] - for /dev/fd/X (This path may appear with `jrsonnet <(command_that_produces_jsonnet)`)
-///
-/// From all of those, only [`SourceVirtual`] may be constructed manually, any other path kind should be only obtained
-/// from assigned `ImportResolver`
-/// However, you should always check `is_default` method return, as it will return true for any paths, where default
-/// search location is applicable
-///
-/// Resolver may also return custom implementations of this trait, for example it may return http url in case of remotely loaded files
-#[derive(Eq, Clone, Acyclic)]
-pub struct SourcePath(Rc<dyn SourcePathT>);
-impl SourcePath {
- pub fn new(inner: impl SourcePathT) -> Self {
- Self(Rc::new(inner))
- }
- pub fn downcast_ref<T: SourcePathT>(&self) -> Option<&T> {
- self.0.as_any().downcast_ref()
- }
- pub fn is_default(&self) -> bool {
- self.0.is_default()
- }
- pub fn path(&self) -> Option<&Path> {
- self.0.path()
- }
-}
-impl Hash for SourcePath {
- fn hash<H: Hasher>(&self, state: &mut H) {
- self.0.hash(state);
- }
-}
-impl PartialEq for SourcePath {
- #[allow(clippy::op_ref)]
- fn eq(&self, other: &Self) -> bool {
- &*self.0 == &*other.0
- }
-}
-impl Display for SourcePath {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.0)
- }
-}
-impl Debug for SourcePath {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{:?}", self.0)
- }
-}
-impl Default for SourcePath {
- fn default() -> Self {
- Self(Rc::new(SourceDefault))
- }
-}
-
-#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
-struct SourceDefault;
-impl Display for SourceDefault {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "<default>")
- }
-}
-impl SourcePathT for SourceDefault {
- fn is_default(&self) -> bool {
- true
- }
- fn path(&self) -> Option<&Path> {
- None
- }
- any_ext_impl!(SourcePathT);
-}
-
-#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
-pub struct SourceDefaultIgnoreJpath;
-impl Display for SourceDefaultIgnoreJpath {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "<default (ignoring jpath)>")
- }
-}
-impl SourcePathT for SourceDefaultIgnoreJpath {
- fn is_default(&self) -> bool {
- true
- }
- fn path(&self) -> Option<&Path> {
- None
- }
- any_ext_impl!(SourcePathT);
-}
-
-/// Represents path to the file on the disk
-/// Directories shouldn't be put here, as resolution for files differs from resolution for directories:
-///
-/// When `file` is being resolved from `SourceFile(a/b/c)`, it should be resolved to `SourceFile(a/b/file)`,
-/// however if it is being resolved from `SourceDirectory(a/b/c)`, then it should be resolved to `SourceDirectory(a/b/c/file)`
-#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
-pub struct SourceFile(PathBuf);
-impl SourceFile {
- pub fn new(path: PathBuf) -> Self {
- Self(path)
- }
- pub fn path(&self) -> &Path {
- &self.0
- }
-}
-impl Display for SourceFile {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.0.display())
- }
-}
-impl SourcePathT for SourceFile {
- fn is_default(&self) -> bool {
- false
- }
- fn path(&self) -> Option<&Path> {
- Some(&self.0)
- }
- any_ext_impl!(SourcePathT);
-}
-
-/// Represents path to the directory on the disk
-///
-/// See also [`SourceFile`]
-#[derive(Acyclic, Hash, PartialEq, Eq, Debug)]
-pub struct SourceDirectory(PathBuf);
-impl SourceDirectory {
- pub fn new(path: PathBuf) -> Self {
- Self(path)
- }
- pub fn path(&self) -> &Path {
- &self.0
- }
-}
-impl Display for SourceDirectory {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.0.display())
- }
-}
-impl SourcePathT for SourceDirectory {
- fn is_default(&self) -> bool {
- false
- }
- fn path(&self) -> Option<&Path> {
- Some(&self.0)
- }
- any_ext_impl!(SourcePathT);
-}
-
-/// Represents virtual file, whose are located in memory, and shouldn't be cached
-///
-/// It is used for --ext-code=.../--tla-code=.../standard library source code by default,
-/// and user can construct arbitrary values by hand, without asking import resolver
-#[derive(Acyclic, Hash, PartialEq, Eq, Clone)]
-pub struct SourceVirtual(pub IStr);
-impl Display for SourceVirtual {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "virtual:{}", self.0)
- }
-}
-impl fmt::Debug for SourceVirtual {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "virtual:{}", self.0)
- }
-}
-impl SourcePathT for SourceVirtual {
- fn is_default(&self) -> bool {
- true
- }
- fn path(&self) -> Option<&Path> {
- None
- }
- any_ext_impl!(SourcePathT);
-}
-
-/// Represents resolved FIFO file, those files may only be read once, and this type is only used for
-/// unix, where user might want to do `jrsonnet <(command_that_produces_jsonnet_source)`
-/// In most cases, user most probably want to use `jrsonnet -` instead of `jrsonnet /dev/stdin`
-/// for better cross-platform support.
-// PartialEq is limited to ptr equality
-#[allow(clippy::derived_hash_with_manual_eq)]
-#[derive(Acyclic, Debug, Hash)]
-pub struct SourceFifo(pub String, pub IBytes);
-impl PartialEq for SourceFifo {
- fn eq(&self, other: &Self) -> bool {
- std::ptr::eq(self, other)
- }
-}
-impl fmt::Display for SourceFifo {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "fifo({:?})", self.0)
- }
-}
-impl SourcePathT for SourceFifo {
- fn is_default(&self) -> bool {
- // In case of FD input, user won't expect relative paths to be resolved from /dev/fd/
- true
- }
-
- fn path(&self) -> Option<&Path> {
- None
- }
-
- any_ext_impl!(SourcePathT);
-}
-
-/// Either real file, or virtual
-/// Hash of FileName always have same value as raw Path, to make it possible to use with raw_entry_mut
-#[derive(Clone, PartialEq, Eq, Acyclic)]
-pub struct Source(pub Rc<(SourcePath, IStr)>);
-
-impl Source {
- pub fn new(path: SourcePath, code: IStr) -> Self {
- Self(Rc::new((path, code)))
- }
-
- pub fn new_virtual(name: IStr, code: IStr) -> Self {
- Self::new(SourcePath::new(SourceVirtual(name)), code)
- }
-
- pub fn code(&self) -> &str {
- &self.0 .1
- }
-
- pub fn source_path(&self) -> &SourcePath {
- &self.0 .0
- }
-
- pub fn map_source_locations<const S: usize>(&self, locs: &[u32; S]) -> [CodeLocation; S] {
- offset_to_location(&self.0 .1, locs)
- }
- pub fn map_from_source_location(&self, line: usize, column: usize) -> Option<usize> {
- location_to_offset(&self.0 .1, line, column)
- }
-}
-impl fmt::Debug for Source {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{:?}", self.0 .0)
- }
-}
crates/jrsonnet-parser/src/unescape.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/unescape.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-use std::str::Chars;
-
-fn decode_unicode(chars: &mut Chars) -> Option<u16> {
- IntoIterator::into_iter([chars.next()?, chars.next()?, chars.next()?, chars.next()?])
- .map(|c| c.to_digit(16).map(|f| f as u16))
- .try_fold(0u16, |acc, v| Some((acc << 4) | (v?)))
-}
-
-pub fn unescape(s: &str) -> Option<String> {
- let mut chars = s.chars();
- let mut out = String::with_capacity(s.len());
-
- while let Some(c) = chars.next() {
- if c != '\\' {
- out.push(c);
- continue;
- }
- match chars.next()? {
- c @ ('\\' | '"' | '\'') => out.push(c),
- 'b' => out.push('\u{0008}'),
- 'f' => out.push('\u{000c}'),
- 'n' => out.push('\n'),
- 'r' => out.push('\r'),
- 't' => out.push('\t'),
- 'u' => match decode_unicode(&mut chars)? {
- // May only be second byte
- 0xDC00..=0xDFFF => return None,
- // Surrogate pair
- n1 @ 0xD800..=0xDBFF => {
- if chars.next() != Some('\\') {
- return None;
- }
- if chars.next() != Some('u') {
- return None;
- }
- let n2 = decode_unicode(&mut chars)?;
- if !matches!(n2, 0xDC00..=0xDFFF) {
- return None;
- }
- let n = (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + 0x1_0000;
- out.push(char::from_u32(n)?);
- }
- n => out.push(char::from_u32(n as u32)?),
- },
- 'x' => {
- let c = IntoIterator::into_iter([chars.next()?, chars.next()?])
- .map(|c| c.to_digit(16))
- .try_fold(0u32, |acc, v| Some((acc << 8) | (v?)))?;
- out.push(char::from_u32(c)?)
- }
- _ => return None,
- }
- }
- Some(out)
-}
crates/jrsonnet-peg-parser/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/Cargo.toml
@@ -0,0 +1,22 @@
+[package]
+name = "jrsonnet-peg-parser"
+authors.workspace = true
+edition.workspace = true
+license.workspace = true
+repository.workspace = true
+version.workspace = true
+
+[dependencies]
+jrsonnet-ir.workspace = true
+peg.workspace = true
+
+[lints]
+workspace = true
+
+[dev-dependencies]
+insta.workspace = true
+
+[features]
+default = []
+exp-destruct = ["jrsonnet-ir/exp-destruct"]
+exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]
crates/jrsonnet-peg-parser/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/lib.rs
@@ -0,0 +1,556 @@
+use jrsonnet_ir::{
+ BinaryOp, Expr, ExprParams, IStr, IndexPart, Member, Slice, SliceDesc, Source, Span, Spanned,
+ ExprParam, ArgsDesc, AssertExpr, ImportKind, LiteralType, IfElse, CompSpec, ForSpecData, IfSpecData, ObjMembers, ObjBody,
+ ObjComp, FieldMember, Visibility, FieldName, unescape, AssertStmt, BindSpec, Destruct, DestructRest,
+};
+use peg::parser;
+use std::rc::Rc;
+
+pub struct ParserSettings {
+ pub source: Source,
+}
+
+macro_rules! expr_bin {
+ ($a:ident $op:ident $b:ident) => {
+ Expr::BinaryOp(Box::new(BinaryOp {
+ lhs: $a,
+ op: $op,
+ rhs: $b,
+ }))
+ };
+}
+macro_rules! expr_un {
+ ($op:ident $a:ident) => {
+ Expr::UnaryOp($op, Box::new($a))
+ };
+}
+
+parser! {
+ grammar jsonnet_parser() for str {
+ use peg::ParseLiteral;
+
+ rule eof() = quiet!{![_]} / expected!("<eof>")
+ rule eol() = "\n" / eof()
+
+ /// Standard C-like comments
+ rule comment()
+ = "//" (!eol()[_])* eol()
+ / "/*" (!("*/")[_])* "*/"
+ / "#" (!eol()[_])* eol()
+
+ rule single_whitespace() = quiet!{([' ' | '\r' | '\n' | '\t'] / comment())} / expected!("<whitespace>")
+ rule _() = quiet!{([' ' | '\r' | '\n' | '\t']+) / comment()}* / expected!("<whitespace>")
+
+ /// For comma-delimited elements
+ rule comma() = quiet!{_ "," _} / expected!("<comma>")
+ rule alpha() -> char = c:$(['_' | 'a'..='z' | 'A'..='Z']) {c.chars().next().unwrap()}
+ rule digit() -> char = d:$(['0'..='9']) {d.chars().next().unwrap()}
+ rule end_of_ident() = !['0'..='9' | '_' | 'a'..='z' | 'A'..='Z']
+ /// Sequence of digits
+ rule uint_str() -> &'input str = a:$(digit()+ ("_" digit()+)*) { a }
+ /// Number in scientific notation format
+ rule number() -> f64 = quiet!{a:$(uint_str() ("." uint_str())? (['e'|'E'] (s:['+'|'-'])? uint_str())?) {? a.replace("_","").parse().map_err(|_| "<number>") }} / expected!("<number>")
+
+ /// Reserved word followed by any non-alphanumberic
+ rule reserved() = ("assert" / "else" / "error" / "false" / "for" / "function" / "if" / "import" / "importstr" / "importbin" / "in" / "local" / "null" / "tailstrict" / "then" / "self" / "super" / "true") end_of_ident()
+ rule id() -> IStr = v:$(quiet!{ !reserved() alpha() (alpha() / digit())*} / expected!("<identifier>")) { v.into() }
+
+ rule keyword(id: &'static str) -> ()
+ = ##parse_string_literal(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 params(s: &ParserSettings) -> ExprParams
+ = params:param(s) ** comma() comma()? { ExprParams::new(params) }
+ / { ExprParams::new(Vec::new()) }
+
+ pub rule arg(s: &ParserSettings) -> (Option<IStr>, Rc<Spanned<Expr>>)
+ = name:(quiet! { (s:id() _ "=" !['='] _ {s})? } / expected!("<argument name>")) expr:expr(s) {(name, Rc::new(expr))}
+
+ pub rule args(s: &ParserSettings) -> ArgsDesc
+ = args:arg(s)**comma() comma()? {?
+ let unnamed_count = args.iter().take_while(|(n, _)| n.is_none()).count();
+ let mut unnamed = Vec::with_capacity(unnamed_count);
+ let mut named = Vec::with_capacity(args.len() - unnamed_count);
+ let mut named_started = false;
+ for (name, value) in args {
+ if let Some(name) = name {
+ named_started = true;
+ named.push((name, value));
+ } else {
+ if named_started {
+ return Err("<named argument>")
+ }
+ unnamed.push(value);
+ }
+ }
+ Ok(ArgsDesc::new(unnamed, named))
+ }
+
+ pub rule destruct_rest() -> DestructRest
+ = "..." into:(_ into:id() {into})? {if let Some(into) = into {
+ DestructRest::Keep(into)
+ } else {DestructRest::Drop}}
+ pub rule destruct_array(s: &ParserSettings) -> Destruct
+ = "[" _ start:destruct(s)**comma() rest:(
+ comma() _ rest:destruct_rest()? end:(
+ comma() end:destruct(s)**comma() (_ comma())? {end}
+ / comma()? {Vec::new()}
+ ) {(rest, end)}
+ / comma()? {(None, Vec::new())}
+ ) _ "]" {?
+ #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Array {
+ start,
+ rest: rest.0,
+ end: rest.1,
+ });
+ #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
+ }
+ pub rule destruct_object(s: &ParserSettings) -> Destruct
+ = "{" _
+ fields:(name:id() into:(_ ":" _ into:destruct(s) {into})? default:(_ "=" _ v:expr(s) {v})? {(name, into, default.map(Rc::new))})**comma()
+ rest:(
+ comma() rest:destruct_rest()? {rest}
+ / comma()? {None}
+ )
+ _ "}" {?
+ #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Object {
+ fields,
+ rest,
+ });
+ #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
+ }
+ pub rule destruct(s: &ParserSettings) -> Destruct
+ = v:id() {Destruct::Full(v)}
+ / "?" {?
+ #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Skip);
+ #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
+ }
+ / arr:destruct_array(s) {arr}
+ / 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)}}
+
+ pub rule assertion(s: &ParserSettings) -> AssertStmt
+ = keyword("assert") _ cond:expr(s) msg:(_ ":" _ e:expr(s) {e})? { AssertStmt(cond, msg) }
+
+ pub rule whole_line() -> &'input str
+ = str:$((!['\n'][_])* "\n") {str}
+ pub rule string_block() -> String
+ = "|||" chomped:"-"? (!['\n']single_whitespace())* "\n"
+ empty_lines:$(['\n']*)
+ prefix:[' ' | '\t']+ first_line:whole_line()
+ lines:("\n" {"\n"} / [' ' | '\t']*<{prefix.len()}> s:whole_line() {s})*
+ [' ' | '\t']*<, {prefix.len() - 1}> "|||"
+ {
+ let mut l = empty_lines.to_owned();
+ l.push_str(first_line);
+ l.extend(lines);
+ if chomped.is_some() {
+ debug_assert!(l.ends_with('\n'));
+ l.truncate(l.len() - 1);
+ }
+ l
+ }
+
+ rule hex_char()
+ = quiet! { ['0'..='9' | 'a'..='f' | 'A'..='F'] } / expected!("<hex char>")
+
+ rule string_char(c: rule<()>)
+ = (!['\\']!c()[_])+
+ / "\\\\"
+ / "\\u" hex_char() hex_char() hex_char() hex_char()
+ / "\\x" hex_char() hex_char()
+ / ['\\'] (quiet! { ['b' | 'f' | 'n' | 'r' | 't' | '"' | '\''] } / expected!("<escape character>"))
+ pub rule string() -> String
+ = ['"'] str:$(string_char(<"\"">)*) ['"'] {? unescape::unescape(str).ok_or("<escaped string>")}
+ / ['\''] str:$(string_char(<"\'">)*) ['\''] {? unescape::unescape(str).ok_or("<escaped string>")}
+ / quiet!{ "@'" str:$(("''" / (!['\''][_]))*) "'" {str.replace("''", "'")}
+ / "@\"" str:$(("\"\"" / (!['"'][_]))*) "\"" {str.replace("\"\"", "\"")}
+ / string_block() } / expected!("<string>")
+
+ pub rule field_name(s: &ParserSettings) -> FieldName
+ = name:id() {FieldName::Fixed(name)}
+ / name:string() {FieldName::Fixed(name.into())}
+ / "[" _ expr:expr(s) _ "]" {FieldName::Dyn(expr)}
+ pub rule visibility() -> Visibility
+ = ":::" {Visibility::Unhide}
+ / "::" {Visibility::Hidden}
+ / ":" {Visibility::Normal}
+ pub rule field(s: &ParserSettings) -> FieldMember
+ = name:field_name(s) _ plus:"+"? _ visibility:visibility() _ value:expr(s) {FieldMember{
+ name,
+ plus: plus.is_some(),
+ params: None,
+ visibility,
+ value: Rc::new(value),
+ }}
+ / name:field_name(s) _ "(" _ params:params(s) _ ")" _ visibility:visibility() _ value:expr(s) {FieldMember{
+ name,
+ plus: false,
+ params: Some(params),
+ visibility,
+ value: Rc::new(value),
+ }}
+ pub rule obj_local(s: &ParserSettings) -> BindSpec
+ = keyword("local") _ bind:bind(s) {bind}
+ pub rule member(s: &ParserSettings) -> Member
+ = bind:obj_local(s) {Member::BindStmt(bind)}
+ / assertion:assertion(s) {Member::AssertStmt(assertion)}
+ / field:field(s) {Member::Field(field)}
+ pub rule objinside(s: &ParserSettings) -> ObjBody
+ = members:(member(s) ** comma()) comma()? _ compspecs:compspecs(s)? {?
+ Ok(if let Some(compspecs) = compspecs {
+ let mut locals = Vec::new();
+ let mut field = None;
+ for member in members {
+ match member {
+ Member::Field(field_member) => if field.replace(field_member).is_some() {
+ return Err("<object comprehension can only contain one field>")
+ },
+ Member::BindStmt(bind_spec) => locals.push(bind_spec),
+ Member::AssertStmt(assert_stmt) => return Err("<asserts are unsupported in object comprehension>"),
+ }
+ }
+ ObjBody::ObjComp(ObjComp {
+ locals: Rc::new(locals),
+ field: field.map(Rc::new).ok_or("<missing object comprehension field>")?,
+ compspecs
+ })
+ } else {
+ let mut locals = Vec::new();
+ let mut asserts = Vec::new();
+ let mut fields = Vec::new();
+ for member in members {
+ match member {
+ Member::Field(field_member) => fields.push(field_member),
+ Member::BindStmt(bind_spec) => locals.push(bind_spec),
+ Member::AssertStmt(assert_stmt) => asserts.push(assert_stmt),
+ }
+ }
+ ObjBody::MemberList(ObjMembers {
+ locals: Rc::new(locals),
+ asserts: Rc::new(asserts),
+ fields
+ })
+ })
+ }
+ pub rule ifspec(s: &ParserSettings) -> IfSpecData
+ = keyword("if") _ expr:expr(s) {IfSpecData(expr)}
+ pub rule forspec(s: &ParserSettings) -> ForSpecData
+ = keyword("for") _ id:destruct(s) _ keyword("in") _ cond:expr(s) {ForSpecData(id, cond)}
+ rule compspec(s: &ParserSettings) -> CompSpec
+ = i:ifspec(s) { CompSpec::IfSpec(i) } / f:forspec(s) {CompSpec::ForSpec(f)}
+ pub rule compspecs(s: &ParserSettings) -> Vec<CompSpec>
+ = specs:compspec(s) ++ _ {?
+ if !matches!(specs[0], CompSpec::ForSpec(_)) {
+ return Err("<first compspec should be for>")
+ }
+ Ok(specs)
+ }
+ pub rule local_expr(s: &ParserSettings) -> Expr
+ = keyword("local") _ binds:bind(s) ** comma() (_ ",")? _ ";" _ expr:expr(s) { Expr::LocalExpr(binds, Box::new(expr)) }
+ pub rule string_expr(s: &ParserSettings) -> Expr
+ = s:string() {Expr::Str(s.into())}
+ 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))}
+ pub rule array_comp_expr(s: &ParserSettings) -> Expr
+ = "[" _ expr:expr(s) _ comma()? _ specs:(r: compspecs(s) _ {r}) "]" {
+ Expr::ArrComp(Rc::new(expr), specs)
+ }
+ pub rule number_expr(s: &ParserSettings) -> Expr
+ = n:number() {? if n.is_finite() {
+ Ok(Expr::Num(n))
+ } else {
+ Err("!!!numbers are finite")
+ }}
+ pub rule var_expr(s: &ParserSettings) -> Expr
+ = n:id() { Expr::Var(n) }
+ pub rule id_loc(s: &ParserSettings) -> Spanned<Expr>
+ = a:position!() n:id() b:position!() { Spanned::new(Expr::Str(n), Span(s.source.clone(), a as u32,b as u32)) }
+ pub rule if_then_else_expr(s: &ParserSettings) -> Expr
+ = cond:ifspec(s) _ keyword("then") _ cond_then:expr(s) cond_else:(_ keyword("else") _ e:expr(s) {e})? {Expr::IfElse(Box::new(IfElse{
+ cond,
+ cond_then,
+ cond_else,
+ }))}
+
+ pub rule literal(s: &ParserSettings) -> Expr
+ = v:(
+ keyword("null") {LiteralType::Null}
+ / keyword("true") {LiteralType::True}
+ / keyword("false") {LiteralType::False}
+ / keyword("self") {LiteralType::This}
+ / keyword("$") {LiteralType::Dollar}
+ / keyword("super") {LiteralType::Super}
+ ) {Expr::Literal(v)}
+
+ rule import_kind() -> ImportKind
+ = keyword("importstr") { ImportKind::Str }
+ / keyword("importbin") { ImportKind::Bin }
+ / keyword("import") { ImportKind::Normal }
+
+ pub rule expr_basic(s: &ParserSettings) -> Expr
+ = literal(s)
+
+ / string_expr(s) / number_expr(s)
+ / array_expr(s)
+ / obj_expr(s)
+ / array_expr(s)
+ / array_comp_expr(s)
+
+ / kind:import_kind() _ path:expr(s) {Expr::Import(kind, Box::new(path))}
+
+ / var_expr(s)
+ / 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{
+ assert, rest
+ })) }
+
+ / keyword("error") _ expr:expr(s) { Expr::ErrorStmt(Box::new(expr)) }
+
+ rule slice_part(s: &ParserSettings) -> Option<Spanned<Expr>>
+ = _ e:(e:expr(s) _{e})? {e}
+ pub rule slice_desc(s: &ParserSettings) -> SliceDesc
+ = start:slice_part(s) ":" pair:(end:slice_part(s) step:(":" e:slice_part(s){e})? {(end, step.flatten())})? {
+ let (end, step) = if let Some((end, step)) = pair {
+ (end, step)
+ }else{
+ (None, None)
+ };
+
+ SliceDesc { start, end, step }
+ }
+
+ rule binop(x: rule<()>) -> ()
+ = quiet!{ x() } / expected!("<binary op>")
+ rule unaryop(x: rule<()>) -> ()
+ = quiet!{ x() } / expected!("<unary op>")
+
+ rule ensure_null_coaelse()
+ = "" {?
+ #[cfg(not(feature = "exp-null-coaelse"))] return Err("!!!experimental null coaelscing was not enabled");
+ #[cfg(feature = "exp-null-coaelse")] Ok(())
+ }
+ use jrsonnet_ir::BinaryOpType::*;
+ use jrsonnet_ir::UnaryOpType::*;
+ rule expr(s: &ParserSettings) -> Spanned<Expr>
+ = precedence! {
+ "(" _ e:expr(s) _ ")" {e}
+ start:position!() v:@ end:position!() { Spanned::new(v, Span(s.source.clone(), start as u32, end as u32)) }
+ --
+ a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)}
+ a:(@) _ binop(<"??">) _ ensure_null_coaelse() b:@ {
+ #[cfg(feature = "exp-null-coaelse")] return expr_bin!(a NullCoaelse b);
+ unreachable!("ensure_null_coaelse will fail if feature is not enabled")
+ }
+ --
+ a:(@) _ binop(<"&&">) _ b:@ {expr_bin!(a And b)}
+ --
+ a:(@) _ binop(<"|">) _ b:@ {expr_bin!(a BitOr b)}
+ --
+ a:@ _ binop(<"^">) _ b:(@) {expr_bin!(a BitXor b)}
+ --
+ a:(@) _ binop(<"&">) _ b:@ {expr_bin!(a BitAnd b)}
+ --
+ a:(@) _ binop(<"==">) _ b:@ {expr_bin!(a Eq b)}
+ a:(@) _ binop(<"!=">) _ b:@ {expr_bin!(a Neq b)}
+ --
+ a:(@) _ binop(<"<">) _ b:@ {expr_bin!(a Lt b)}
+ a:(@) _ binop(<">">) _ b:@ {expr_bin!(a Gt b)}
+ a:(@) _ binop(<"<=">) _ b:@ {expr_bin!(a Lte b)}
+ a:(@) _ binop(<">=">) _ b:@ {expr_bin!(a Gte b)}
+ a:(@) _ binop(<keyword("in")>) _ b:@ {expr_bin!(a In b)}
+ --
+ a:(@) _ binop(<"<<">) _ b:@ {expr_bin!(a Lhs b)}
+ a:(@) _ binop(<">>">) _ b:@ {expr_bin!(a Rhs b)}
+ --
+ a:(@) _ binop(<"+">) _ b:@ {expr_bin!(a Add b)}
+ a:(@) _ binop(<"-">) _ b:@ {expr_bin!(a Sub b)}
+ --
+ a:(@) _ binop(<"*">) _ b:@ {expr_bin!(a Mul b)}
+ a:(@) _ binop(<"/">) _ b:@ {expr_bin!(a Div b)}
+ a:(@) _ binop(<"%">) _ b:@ {expr_bin!(a Mod b)}
+ --
+ unaryop(<"+">) _ b:@ {expr_un!(Plus b)}
+ unaryop(<"-">) _ b:@ {expr_un!(Minus b)}
+ unaryop(<"!">) _ b:@ {expr_un!(Not b)}
+ unaryop(<"~">) _ b:@ {expr_un!(BitNot b)}
+ --
+ 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:args(s) _ ")" ts:(_ keyword("tailstrict"))? {Expr::Apply(Box::new(a), args, ts.is_some())}
+ a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(Rc::new(a), body)}
+ --
+ e:expr_basic(s) {e}
+ }
+ pub rule index_part(s: &ParserSettings) -> IndexPart
+ = n:("?" _ ensure_null_coaelse())? "." _ value:id_loc(s) {IndexPart {
+ value,
+ #[cfg(feature = "exp-null-coaelse")]
+ null_coaelse: n.is_some(),
+ }}
+ / n:("?" _ "." _ ensure_null_coaelse())? "[" _ value:expr(s) _ "]" {IndexPart {
+ value,
+ #[cfg(feature = "exp-null-coaelse")]
+ null_coaelse: n.is_some(),
+ }}
+
+ pub rule jsonnet(s: &ParserSettings) -> Spanned<Expr> = _ e:expr(s) _ {e}
+ }
+}
+
+pub type ParseError = peg::error::ParseError<peg::str::LineCol>;
+pub fn parse(str: &str, settings: &ParserSettings) -> Result<Spanned<Expr>, ParseError> {
+ jsonnet_parser::jsonnet(str, settings)
+}
+/// Used for importstr values
+pub fn string_to_expr(str: IStr, settings: &ParserSettings) -> Spanned<Expr> {
+ let len = str.len();
+ Spanned::new(Expr::Str(str), Span(settings.source.clone(), 0, len as u32))
+}
+
+#[cfg(test)]
+pub mod tests {
+ use insta::assert_snapshot;
+ use jrsonnet_ir::{IStr, Source};
+
+ use super::parse;
+ use crate::ParserSettings;
+
+ fn parsep(s: &str) -> String {
+ let v = parse(
+ s,
+ &ParserSettings {
+ source: Source::new_virtual("<test>".into(), IStr::empty()),
+ },
+ )
+ .unwrap();
+ format!("{v:#?}")
+ }
+
+ macro_rules! parse {
+ ($s:expr) => {
+ assert_snapshot!(parsep($s));
+ };
+ }
+
+ #[test]
+ fn multiline_string() {
+ parse!("|||\n Hello world!\n a\n|||");
+ parse!("|||\n Hello world!\n a\n|||");
+ parse!("|||\n\t\tHello world!\n\t\t\ta\n|||");
+ parse!("|||\n Hello world!\n a\n |||");
+ }
+
+ #[test]
+ fn slice() {
+ parse!("a[1:]");
+ parse!("a[1::]");
+ parse!("a[:1:]");
+ parse!("a[::1]");
+ parse!("str[:len - 1]");
+ }
+
+ #[test]
+ fn string_escaping() {
+ parse!(r#""Hello, \"world\"!""#);
+ parse!(r#"'Hello \'world\'!'"#);
+ parse!(r#"'\\\\'"#);
+ }
+
+ #[test]
+ fn string_unescaping() {
+ parse!(r#""Hello\nWorld""#);
+ }
+
+ #[test]
+ fn string_verbantim() {
+ parse!(r#"@"Hello\n""World""""#);
+ }
+
+ #[test]
+ fn imports() {
+ parse!("import \"hello\"");
+ parse!("importstr \"garnish.txt\"");
+ parse!("importbin \"garnish.bin\"");
+ }
+
+ #[test]
+ fn empty_object() {
+ parse!("{}");
+ }
+
+ #[test]
+ fn basic_math() {
+ parse!("2+2*2");
+ parse!("2 + 2 * 2 ");
+ parse!("2+(2+2*2)");
+ parse!("2//comment\n+//comment\n3/*test*/*/*test*/4");
+ }
+
+ #[test]
+ fn suffix() {
+ parse!("std.test");
+ parse!("std(2)");
+ parse!("std.test(2)");
+ parse!("a[b]");
+ }
+
+ #[test]
+ fn array_comp() {
+ parse!("[std.deepJoin(x) for x in arr]");
+ }
+
+ #[test]
+ fn reserved() {
+ parse!("null");
+ parse!("nulla");
+ }
+
+ #[test]
+ fn multiple_args_buf() {
+ parse!("a(b, null_fields)");
+ }
+
+ #[test]
+ fn infix_precedence() {
+ parse!("!a && !b");
+ parse!("!a / !b");
+ }
+
+ #[test]
+ fn double_negation() {
+ parse!("!!a");
+ }
+
+ #[test]
+ fn array_test_error() {
+ parse!("[a for a in b if c for e in f]");
+ }
+
+ #[test]
+ fn missing_newline_between_comment_and_eof() {
+ parse!(
+ "{a:1}
+
+ //+213"
+ );
+ }
+
+ #[test]
+ fn default_param_before_nondefault() {
+ parse!("local x(foo = 'foo', bar) = null; null");
+ }
+
+ #[test]
+ fn add_location_info_to_all_sub_expressions() {
+ parse!("{} { local x = 1, x: x } + {}");
+ }
+}
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__add_location_info_to_all_sub_expressions.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__add_location_info_to_all_sub_expressions.snap
@@ -0,0 +1,57 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"{} { local x = 1, x: x } + {}\")"
+---
+BinaryOp(
+ BinaryOp {
+ lhs: ObjExtend(
+ Obj(
+ MemberList(
+ ObjMembers {
+ locals: [],
+ asserts: [],
+ fields: [],
+ },
+ ),
+ ) from virtual:<test>:0-2,
+ MemberList(
+ ObjMembers {
+ locals: [
+ Field {
+ into: Full(
+ "x",
+ ),
+ value: Num(
+ 1.0,
+ ) from virtual:<test>:15-16,
+ },
+ ],
+ asserts: [],
+ fields: [
+ FieldMember {
+ name: Fixed(
+ "x",
+ ),
+ plus: false,
+ params: None,
+ visibility: Normal,
+ value: Var(
+ "x",
+ ) from virtual:<test>:21-22,
+ },
+ ],
+ },
+ ),
+ ) from virtual:<test>:0-24,
+ op: Add,
+ rhs: Obj(
+ MemberList(
+ ObjMembers {
+ locals: [],
+ asserts: [],
+ fields: [],
+ },
+ ),
+ ) from virtual:<test>:27-29,
+ },
+) from virtual:<test>:0-29
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_comp.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_comp.snap
@@ -0,0 +1,41 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"[std.deepJoin(x) for x in arr]\")"
+---
+ArrComp(
+ Apply(
+ Index {
+ indexable: Var(
+ "std",
+ ) from virtual:<test>:1-4,
+ parts: [
+ IndexPart {
+ value: Str(
+ "deepJoin",
+ ) from virtual:<test>:5-13,
+ },
+ ],
+ } from virtual:<test>:1-13,
+ ArgsDesc {
+ unnamed: [
+ Var(
+ "x",
+ ) from virtual:<test>:14-15,
+ ],
+ named: [],
+ },
+ false,
+ ) from virtual:<test>:1-16,
+ [
+ ForSpec(
+ ForSpecData(
+ Full(
+ "x",
+ ),
+ Var(
+ "arr",
+ ) from virtual:<test>:26-29,
+ ),
+ ),
+ ],
+) from virtual:<test>:0-30
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_test_error.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_test_error.snap
@@ -0,0 +1,38 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"[a for a in b if c for e in f]\")"
+---
+ArrComp(
+ Var(
+ "a",
+ ) from virtual:<test>:1-2,
+ [
+ ForSpec(
+ ForSpecData(
+ Full(
+ "a",
+ ),
+ Var(
+ "b",
+ ) from virtual:<test>:12-13,
+ ),
+ ),
+ IfSpec(
+ IfSpecData(
+ Var(
+ "c",
+ ) from virtual:<test>:17-18,
+ ),
+ ),
+ ForSpec(
+ ForSpecData(
+ Full(
+ "e",
+ ),
+ Var(
+ "f",
+ ) from virtual:<test>:28-29,
+ ),
+ ),
+ ],
+) from virtual:<test>:0-30
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__basic_math.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__basic_math.snap
@@ -0,0 +1,23 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"2+2*2\")"
+---
+BinaryOp(
+ BinaryOp {
+ lhs: Num(
+ 2.0,
+ ) from virtual:<test>:0-1,
+ op: Add,
+ rhs: BinaryOp(
+ BinaryOp {
+ lhs: Num(
+ 2.0,
+ ) from virtual:<test>:2-3,
+ op: Mul,
+ rhs: Num(
+ 2.0,
+ ) from virtual:<test>:4-5,
+ },
+ ) from virtual:<test>:2-5,
+ },
+) from virtual:<test>:0-5
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__default_param_before_nondefault.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__default_param_before_nondefault.snap
@@ -0,0 +1,54 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"local x(foo = 'foo', bar) = null; null\")"
+---
+LocalExpr(
+ [
+ Function {
+ name: "x",
+ params: ExprParams {
+ exprs: [
+ ExprParam {
+ destruct: Full(
+ "foo",
+ ),
+ default: Some(
+ Str(
+ "foo",
+ ) from virtual:<test>:14-19,
+ ),
+ },
+ ExprParam {
+ destruct: Full(
+ "bar",
+ ),
+ default: None,
+ },
+ ],
+ signature: FunctionSignature(
+ [
+ ParamParse {
+ name: Named(
+ "foo",
+ ),
+ default: Exists,
+ },
+ ParamParse {
+ name: Named(
+ "bar",
+ ),
+ default: None,
+ },
+ ],
+ ),
+ binds_len: 2,
+ },
+ value: Literal(
+ Null,
+ ) from virtual:<test>:28-32,
+ },
+ ],
+ Literal(
+ Null,
+ ) from virtual:<test>:34-38,
+) from virtual:<test>:0-38
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__double_negation.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__double_negation.snap
@@ -0,0 +1,13 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"!!a\")"
+---
+UnaryOp(
+ Not,
+ UnaryOp(
+ Not,
+ Var(
+ "a",
+ ) from virtual:<test>:2-3,
+ ) from virtual:<test>:1-3,
+) from virtual:<test>:0-3
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__empty_object.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__empty_object.snap
@@ -0,0 +1,13 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"{}\")"
+---
+Obj(
+ MemberList(
+ ObjMembers {
+ locals: [],
+ asserts: [],
+ fields: [],
+ },
+ ),
+) from virtual:<test>:0-2
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__imports.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__imports.snap
@@ -0,0 +1,10 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"import \\\"hello\\\"\")"
+---
+Import(
+ Normal,
+ Str(
+ "hello",
+ ) from virtual:<test>:7-14,
+) from virtual:<test>:0-14
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__infix_precedence.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__infix_precedence.snap
@@ -0,0 +1,21 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"!a && !b\")"
+---
+BinaryOp(
+ BinaryOp {
+ lhs: UnaryOp(
+ Not,
+ Var(
+ "a",
+ ) from virtual:<test>:1-2,
+ ) from virtual:<test>:0-2,
+ op: And,
+ rhs: UnaryOp(
+ Not,
+ Var(
+ "b",
+ ) from virtual:<test>:7-8,
+ ) from virtual:<test>:6-8,
+ },
+) from virtual:<test>:0-8
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__missing_newline_between_comment_and_eof.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__missing_newline_between_comment_and_eof.snap
@@ -0,0 +1,25 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"{a:1}\n\n\t\t\t//+213\")"
+---
+Obj(
+ MemberList(
+ ObjMembers {
+ locals: [],
+ asserts: [],
+ fields: [
+ FieldMember {
+ name: Fixed(
+ "a",
+ ),
+ plus: false,
+ params: None,
+ visibility: Normal,
+ value: Num(
+ 1.0,
+ ) from virtual:<test>:3-4,
+ },
+ ],
+ },
+ ),
+) from virtual:<test>:0-5
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiline_string.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiline_string.snap
@@ -0,0 +1,7 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"|||\\n Hello world!\\n a\\n|||\")"
+---
+Str(
+ "Hello world!\n a\n",
+) from virtual:<test>:0-31
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiple_args_buf.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiple_args_buf.snap
@@ -0,0 +1,21 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"a(b, null_fields)\")"
+---
+Apply(
+ Var(
+ "a",
+ ) from virtual:<test>:0-1,
+ ArgsDesc {
+ unnamed: [
+ Var(
+ "b",
+ ) from virtual:<test>:2-3,
+ Var(
+ "null_fields",
+ ) from virtual:<test>:5-16,
+ ],
+ named: [],
+ },
+ false,
+) from virtual:<test>:0-17
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__reserved.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__reserved.snap
@@ -0,0 +1,7 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"null\")"
+---
+Literal(
+ Null,
+) from virtual:<test>:0-4
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__slice.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__slice.snap
@@ -0,0 +1,20 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"a[1:]\")"
+---
+Slice(
+ Slice {
+ value: Var(
+ "a",
+ ) from virtual:<test>:0-1,
+ slice: SliceDesc {
+ start: Some(
+ Num(
+ 1.0,
+ ) from virtual:<test>:2-3,
+ ),
+ end: None,
+ step: None,
+ },
+ },
+) from virtual:<test>:0-5
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_escaping.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_escaping.snap
@@ -0,0 +1,7 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(r#\"\"Hello, \\\"world\\\"!\"\"#)"
+---
+Str(
+ "Hello, \"world\"!",
+) from virtual:<test>:0-19
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_unescaping.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_unescaping.snap
@@ -0,0 +1,7 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(r#\"\"Hello\\nWorld\"\"#)"
+---
+Str(
+ "Hello\nWorld",
+) from virtual:<test>:0-14
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_verbantim.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_verbantim.snap
@@ -0,0 +1,7 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(r#\"@\"Hello\\n\"\"World\"\"\"\"#)"
+---
+Str(
+ "Hello\\n\"World\"",
+) from virtual:<test>:0-19
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__suffix.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__suffix.snap
@@ -0,0 +1,16 @@
+---
+source: crates/jrsonnet-peg-parser/src/lib.rs
+expression: "parsep(\"std.test\")"
+---
+Index {
+ indexable: Var(
+ "std",
+ ) from virtual:<test>:0-3,
+ parts: [
+ IndexPart {
+ value: Str(
+ "test",
+ ) from virtual:<test>:4-8,
+ },
+ ],
+} from virtual:<test>:0-8
crates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -16,14 +16,17 @@
# Bigint type
exp-bigint = ["dep:num-bigint", "jrsonnet-evaluator/exp-bigint"]
-exp-null-coaelse = ["jrsonnet-parser/exp-null-coaelse", "jrsonnet-evaluator/exp-null-coaelse"]
+exp-null-coaelse = [
+ "jrsonnet-ir/exp-null-coaelse",
+ "jrsonnet-evaluator/exp-null-coaelse",
+]
# std.regexMatch and other helpers
exp-regex = ["dep:regex", "dep:lru", "dep:rustc-hash"]
[dependencies]
jrsonnet-evaluator.workspace = true
jrsonnet-macros.workspace = true
-jrsonnet-parser.workspace = true
+jrsonnet-ir.workspace = true
jrsonnet-gcmodule.workspace = true
# Used for std.parseJson/std.parseYaml
@@ -50,6 +53,3 @@
regex = { workspace = true, optional = true }
lru = { workspace = true, optional = true }
rustc-hash = { workspace = true, optional = true }
-
-[build-dependencies]
-jrsonnet-parser.workspace = true
crates/jrsonnet-stdlib/resultdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-stdlib/result
@@ -0,0 +1 @@
+/nix/store/2fxmjvz4f6c8g6gi37y35h356vj0n8k6-benchmarks
\ No newline at end of file
crates/jrsonnet-stdlib/src/compat.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/compat.rs
+++ b/crates/jrsonnet-stdlib/src/compat.rs
@@ -8,7 +8,7 @@
#[allow(non_snake_case)]
pub fn builtin___compare(v1: Val, v2: Val) -> Result<i32> {
Ok(
- match evaluate_compare_op(&v1, &v2, jrsonnet_parser::BinaryOpType::Lt)? {
+ match evaluate_compare_op(&v1, &v2, jrsonnet_ir::BinaryOpType::Lt)? {
Ordering::Less => -1,
Ordering::Equal => 0,
Ordering::Greater => 1,
@@ -30,7 +30,7 @@
let ordering = evaluate_compare_op(
&Val::Arr(arr1),
&Val::Arr(arr2),
- jrsonnet_parser::BinaryOpType::Lt,
+ jrsonnet_ir::BinaryOpType::Lt,
)?;
Ok($operator.contains(&ordering))
}
crates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -20,7 +20,7 @@
ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,
};
use jrsonnet_gcmodule::{Acyclic, Cc, Trace};
-use jrsonnet_parser::Source;
+use jrsonnet_ir::Source;
pub use manifest::*;
pub use math::*;
pub use misc::*;
crates/jrsonnet-stdlib/src/manifest/ini.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/manifest/ini.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/ini.rs
@@ -4,8 +4,8 @@
manifest::{ManifestFormat, ToStringFormat},
typed::{FromUntyped, Typed},
ObjValue, Result, ResultExt, Val,
+ IStr,
};
-use jrsonnet_parser::IStr;
pub struct IniFormat {
#[cfg(feature = "exp-preserve-order")]
crates/jrsonnet-stdlib/src/sets.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/sets.rs
+++ b/crates/jrsonnet-stdlib/src/sets.rs
@@ -3,7 +3,7 @@
use jrsonnet_evaluator::{
function::builtin, operator::evaluate_compare_op, val::ArrValue, Result, Thunk, Val,
};
-use jrsonnet_parser::BinaryOpType;
+use jrsonnet_ir::BinaryOpType;
use crate::keyf::KeyF;
crates/jrsonnet-stdlib/src/sort.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/sort.rs
+++ b/crates/jrsonnet-stdlib/src/sort.rs
@@ -9,7 +9,7 @@
val::{equals, ArrValue},
Result, Thunk, Val,
};
-use jrsonnet_parser::BinaryOpType;
+use jrsonnet_ir::BinaryOpType;
use crate::{eval_on_empty, keyf::KeyF};
flake.nixdiffbeforeafterboth--- a/flake.nix
+++ b/flake.nix
@@ -160,6 +160,7 @@
]
++ lib.optionals (!stdenv.isDarwin) [
valgrind
+ kdePackages.kcachegrind
];
};
};
xtask/src/main.rsdiffbeforeafterboth--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -52,10 +52,9 @@
} => {
let out = sh.create_temp_dir()?;
- // build-std
cmd!(
sh,
- "cargo build -Zbuild-std --target={target} --profile releasedebug"
+ "cargo build --target={target} --profile releasedebug"
)
.run()?;
let built = format!("./target/{target}/releasedebug/jrsonnet");