diff --git a/Cargo.lock b/Cargo.lock index 1f8d349..99f1c3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -139,7 +139,7 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "assert_no_alloc" version = "1.1.2" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" +source = "git+https://github.com/zorp-corp/sword.git?rev=bcb2e7fba0e24d45d4887fae77389d7c5e86b507#bcb2e7fba0e24d45d4887fae77389d7c5e86b507" [[package]] name = "async-trait" @@ -267,29 +267,6 @@ dependencies = [ "virtue", ] -[[package]] -name = "bindgen" -version = "0.69.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" -dependencies = [ - "bitflags 2.6.0", - "cexpr", - "clang-sys", - "itertools 0.12.1", - "lazy_static", - "lazycell", - "log", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.82", - "which", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -370,15 +347,6 @@ version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -422,17 +390,6 @@ dependencies = [ "inout", ] -[[package]] -name = "clang-sys" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "3.2.25" @@ -517,6 +474,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +[[package]] +name = "coolor" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "691defa50318376447a73ced869862baecfab35f6aabaa91a4cd726b315bfe1a" +dependencies = [ + "crossterm", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -544,7 +510,7 @@ dependencies = [ "ciborium", "clap 3.2.25", "criterion-plot", - "itertools 0.10.5", + "itertools", "lazy_static", "num-traits", "oorandom", @@ -565,7 +531,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools 0.10.5", + "itertools", +] + +[[package]] +name = "crokey" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520e83558f4c008ac06fa6a86e5c1d4357be6f994cce7434463ebcdaadf47bb1" +dependencies = [ + "crokey-proc_macros", + "crossterm", + "once_cell", + "serde", + "strict", +] + +[[package]] +name = "crokey-proc_macros" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "370956e708a1ce65fe4ac5bb7185791e0ece7485087f17736d54a23a0895049f" +dependencies = [ + "crossterm", + "proc-macro2", + "quote", + "strict", + "syn 1.0.109", +] + +[[package]] +name = "crossbeam" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", ] [[package]] @@ -596,16 +601,50 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crossterm" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" +dependencies = [ + "bitflags 2.6.0", + "crossterm_winapi", + "mio 1.0.2", + "parking_lot", + "rustix", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + [[package]] name = "crown" version = "0.1.0" -source = "git+https://github.com/zorp-corp/nockapp?rev=57f9d9f0d5cbd8bf0b88cd8c8a108c1f551e33d8#57f9d9f0d5cbd8bf0b88cd8c8a108c1f551e33d8" +source = "git+https://github.com/zorp-corp/nockapp?rev=d950678e86caa4642fde6432a8d02d1e04b8bcae#d950678e86caa4642fde6432a8d02d1e04b8bcae" dependencies = [ "anyhow", "assert_no_alloc", @@ -626,6 +665,7 @@ dependencies = [ "sword", "sword_macros", "tempfile", + "termimad", "thiserror", "tokio", "tokio-util", @@ -914,12 +954,6 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - [[package]] name = "half" version = "2.4.1" @@ -957,15 +991,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "1.1.0" @@ -1050,7 +1075,7 @@ dependencies = [ [[package]] name = "ibig" version = "0.3.6" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" +source = "git+https://github.com/zorp-corp/sword.git?rev=bcb2e7fba0e24d45d4887fae77389d7c5e86b507#bcb2e7fba0e24d45d4887fae77389d7c5e86b507" dependencies = [ "cfg-if", "num-traits", @@ -1124,15 +1149,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -1188,32 +1204,39 @@ dependencies = [ ] [[package]] -name = "lazy_static" -version = "1.5.0" +name = "lazy-regex" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "60c7310b93682b36b98fa7ea4de998d3463ccbebd94d935d6b48ba5b6ffa7126" +dependencies = [ + "lazy-regex-proc_macros", + "once_cell", + "regex", +] [[package]] -name = "lazycell" -version = "1.3.0" +name = "lazy-regex-proc_macros" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +checksum = "4ba01db5ef81e17eb10a5e0f2109d1b3a3e29bac3070fdbd7d156bf7dbd206a1" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn 2.0.82", +] [[package]] -name = "libc" -version = "0.2.161" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] -name = "libloading" -version = "0.8.5" +name = "libc" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" -dependencies = [ - "cfg-if", - "windows-targets 0.52.6", -] +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libredox" @@ -1232,6 +1255,16 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.22" @@ -1260,13 +1293,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "memmap" -version = "0.7.0" +name = "memmap2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" dependencies = [ "libc", - "winapi", ] [[package]] @@ -1276,10 +1308,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "minimal-lexical" -version = "0.2.1" +name = "minimad" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +checksum = "a9c5d708226d186590a7b6d4a9780e2bdda5f689e0d58cd17012a298efd745d2" +dependencies = [ + "once_cell", +] [[package]] name = "miniz_oxide" @@ -1310,6 +1345,7 @@ checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi 0.3.9", "libc", + "log", "wasi", "windows-sys 0.52.0", ] @@ -1317,17 +1353,7 @@ dependencies = [ [[package]] name = "murmur3" version = "0.5.2" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] +source = "git+https://github.com/zorp-corp/sword.git?rev=bcb2e7fba0e24d45d4887fae77389d7c5e86b507#bcb2e7fba0e24d45d4887fae77389d7c5e86b507" [[package]] name = "notify" @@ -1419,6 +1445,29 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1474,16 +1523,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "prettyplease" -version = "0.2.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" -dependencies = [ - "proc-macro2", - "syn 2.0.82", -] - [[package]] name = "proc-macro2" version = "1.0.88" @@ -1617,12 +1656,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc_version" version = "0.4.1" @@ -1666,6 +1699,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "semver" version = "1.0.23" @@ -1757,12 +1796,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "signal-hook" version = "0.3.17" @@ -1773,6 +1806,17 @@ dependencies = [ "signal-hook-registry", ] +[[package]] +name = "signal-hook-mio" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +dependencies = [ + "libc", + "mio 1.0.2", + "signal-hook", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -1819,6 +1863,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strict" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f42444fea5b87a39db4218d9422087e66a85d0e7a0963a439b07bcdf91804006" + [[package]] name = "strsim" version = "0.11.1" @@ -1834,7 +1884,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sword" version = "0.1.0" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" +source = "git+https://github.com/zorp-corp/sword.git?rev=bcb2e7fba0e24d45d4887fae77389d7c5e86b507#bcb2e7fba0e24d45d4887fae77389d7c5e86b507" dependencies = [ "assert_no_alloc", "autotools", @@ -1847,7 +1897,7 @@ dependencies = [ "json", "lazy_static", "libc", - "memmap", + "memmap2", "murmur3", "num-derive", "num-traits", @@ -1855,16 +1905,14 @@ dependencies = [ "signal-hook", "static_assertions", "sword_crypto", - "sword_guard", "sword_macros", - "sword_pma", "thiserror", ] [[package]] name = "sword_crypto" version = "0.1.0" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" +source = "git+https://github.com/zorp-corp/sword.git?rev=bcb2e7fba0e24d45d4887fae77389d7c5e86b507#bcb2e7fba0e24d45d4887fae77389d7c5e86b507" dependencies = [ "aes", "aes-siv", @@ -1877,33 +1925,15 @@ dependencies = [ "x25519-dalek", ] -[[package]] -name = "sword_guard" -version = "0.1.0" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" -dependencies = [ - "bindgen", - "cc", -] - [[package]] name = "sword_macros" version = "0.1.0" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" +source = "git+https://github.com/zorp-corp/sword.git?rev=bcb2e7fba0e24d45d4887fae77389d7c5e86b507#bcb2e7fba0e24d45d4887fae77389d7c5e86b507" dependencies = [ "quote", "syn 1.0.109", ] -[[package]] -name = "sword_pma" -version = "0.1.0" -source = "git+https://github.com/zorp-corp/sword.git?rev=29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509#29cc8d897c8cb7a70e5baf52c9b83f5ef04fe509" -dependencies = [ - "bindgen", - "cc", -] - [[package]] name = "syn" version = "1.0.109" @@ -1971,6 +2001,22 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "termimad" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a5d4cf55d9f1cb04fcda48f725772d0733ae34e030dfc4dd36e738a5965f4" +dependencies = [ + "coolor", + "crokey", + "crossbeam", + "lazy-regex", + "minimad", + "serde", + "thiserror", + "unicode-width", +] + [[package]] name = "textwrap" version = "0.16.1" @@ -2181,6 +2227,12 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "utf8parse" version = "0.2.2" @@ -2286,18 +2338,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Makefile b/Makefile index 971e46f..62d1bbc 100644 --- a/Makefile +++ b/Makefile @@ -31,11 +31,11 @@ release: build-release .PHONY: release-test-zero release-test-zero: - cargo run $(PROFILE_RELEASE) -- --new test-n 0 + RUST_LOG=TRACE cargo run $(PROFILE_RELEASE) -- --new test-n 0 .PHONY: release-test-all release-test-all: - cargo run $(PROFILE_RELEASE) -- --new exec-all + RUST_LOG=TRACE cargo run $(PROFILE_RELEASE) -- --new exec-all -: ## ----------------------------------------------------------- -: ## ---------- Rest of the commands in the Makefile ----------- @@ -45,28 +45,28 @@ release-test-all: build-dev-fast: ## Slower to compile, faster to execute. Builds all projects @set -e; \ RUST_LOG=TRACE ./choo hoon/main.hoon hoon; \ - # mv out.jam assets/jocktest.jam; \ + mv out.jam assets/jocktest.jam; \ cargo build $(PROFILE_DEV_FAST) .PHONY: build-parallel build-parallel: ## profiling profile with parallel feature enabled @set -e; \ ./choo hoon/main.hoon hoon; \ - # mv out.jam assets/jocktest.jam; \ + mv out.jam assets/jocktest.jam; \ cargo build $(FEATURES_PARALLEL) $(PROFILE_PROFILING) .PHONY: build build-dev-debug: ## Fast to compile, slow to execute. Builds all projects @set -e; \ RUST_LOG=TRACE ./choo --new --log-level trace hoon/main.hoon hoon; \ - # mv out.jam assets/jocktest.jam; \ + mv out.jam assets/jocktest.jam; \ cargo build .PHONY: build-release build-release: ## Slowest to compile, fastest to execute. Builds all projects @set -e; \ RUST_LOG=TRACE ./choo hoon/main.hoon hoon; \ - # mv out.jam assets/jocktest.jam; \ + mv out.jam assets/jocktest.jam; \ cargo build $(PROFILE_RELEASE) .PHONY: update-choo diff --git a/README.md b/README.md index 4084fa9..98ff133 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,9 @@ make build release # run all codes in /lib/tests ./target/release/jock-testing exec-all +# - or - +make release-test-all + # run specific code in /lib/tests ./target/release/jock-testing test-n 0 ``` diff --git a/assets/jocktest.jam b/assets/jocktest.jam index e95e916..bcab075 100644 Binary files a/assets/jocktest.jam and b/assets/jocktest.jam differ diff --git a/hoon/lib/jock.hoon b/hoon/lib/jock.hoon index eaa849f..991a5ce 100644 --- a/hoon/lib/jock.hoon +++ b/hoon/lib/jock.hoon @@ -38,6 +38,7 @@ $? %let %func %lambda + %protocol %if %else %crash @@ -60,7 +61,7 @@ $? %'.' %';' %',' %':' %'&' %'$' %'@' %'?' %'!' %'((' %'(' %')' %'{' %'}' %'[' %']' - %'=' %'<' %'>' + %'=' %'<' %'>' %'#' %'+' %'-' %'*' %'/' %'_' == :: @@ -139,7 +140,8 @@ ++ tagged-keyword (stag %keyword keyword) ++ keyword %- perk - :~ %let %func %lambda %if %else %crash %assert + :~ %let %func %lambda %protocol + %if %else %crash %assert %object %compose %loop %defer %recur %match %eval %with %this %type %case @@ -158,7 +160,7 @@ :~ %'.' %';' %',' %':' %'&' %'$' %'@' %'?' %'!' :: XXX exclude %'((' which is a pseudo-punctuator %'(' %')' %'{' %'}' %'[' %']' - %'=' %'<' %'>' + %'=' %'<' %'>' %'#' %'+' %'-' %'*' %'/' %'_' == :: @@ -213,6 +215,7 @@ $^ [p=jock q=jock] $% [%let type=jype val=jock next=jock] [%func type=jype body=jock next=jock] + [%protocol type=jock body=(map term jype) next=jock] [%edit limb=(list jlimb) val=jock next=jock] [%increment val=jock] [%cell-check val=jock] @@ -288,8 +291,8 @@ [%list type=jype] :: %set [%set type=jype] - :: %none is a null type (as for undetermined variable labels) - [%none ~] + :: %none is a null type (as for undetermined variable labels or protocols) + [%none p=(unit term)] == :: Jype atom base types; corresponds to jatom tags +$ jatom-type @@ -322,7 +325,7 @@ :: Arm lookups +$ jlimb $% :: Arm or leg name - [%name p=term] + [%name p=cord] :: Numeric axis [%axis p=@] == @@ -348,14 +351,14 @@ ++ match-inner-jock |= =tokens ^- [jock (list token)] - ?~ tokens ~|("expect inner-jock. token: ~" !!) + ?: =(~ tokens) ~|("expect inner-jock. token: ~" !!) ?: ?| (has-keyword -.tokens %object) (has-keyword -.tokens %with) (has-keyword -.tokens %this) (has-keyword -.tokens %crash) == (match-jock tokens) - ?+ -.i.tokens !! + ?+ -<.tokens !! %literal :: TODO: check if we're in a compare (match-literal tokens) @@ -368,7 +371,7 @@ ++ match-pair-inner-jock |= =tokens ^- [jock (list token)] - ?~ tokens ~|("expect jock. token: ~" !!) + ?: =(~ tokens) ~|("expect jock. token: ~" !!) ?: (has-punctuator -.tokens %'(') => .(tokens `(list token)`+.tokens) =^ jock-one tokens @@ -391,13 +394,31 @@ =^ pairs tokens $ [[jock-nex pairs] tokens] - ?+ -.i.tokens !! + ?+ -<.tokens !! %literal (match-literal tokens) %name (match-start-name tokens) %punctuator (match-start-punctuator tokens) %type !! ::(match-metatype tokens) :: shouldn't reach this way == :: +++ match-trait + |= =tokens + ^- [jype (list token)] + ?: =(~ tokens) ~|("expect trait. token: ~" !!) + =^ type tokens + (match-jype tokens) + =^ inp=jype tokens + (match-block [tokens %'((' %')'] match-jype) + ?> (got-punctuator -.tokens %'-') + ?> (got-punctuator +<.tokens %'>') + =. tokens +>.tokens + =^ out=jype tokens + (match-jype tokens) + ?> (got-punctuator -.tokens %';') + :_ +.tokens + :- `jype-leaf`[%core [%& [`inp out]] ~] + name.type +:: ++ match-start-punctuator |= =tokens ^- [jock (list token)] @@ -511,28 +532,33 @@ ++ match-start-name |= =tokens ^- [jock (list token)] - ?~ tokens ~|("expect expression starting with name. token: ~" !!) - :: - %name (';' is is the next token) - :: - %edit ('=' is the next token) - :: - %call ('((' is the next token) - :: - %compare ('==' or '<' or '>' or '!' is next) - ?. ?=(%name -.i.tokens) - ~|("expect name. token: {<-.i.tokens>}" !!) + ?: =(~ tokens) ~|("expect expression starting with name. token: ~" !!) + :: ?. ?=(%name -<.tokens) + :: ~|("expect name. token: {<-<.tokens>}" !!) + :: How a name is parsed depends on the next symbol. =/ name=term - (got-name i.tokens) - => .(tokens t.tokens) - =/ limbs=(list jlimb) [%name name]~ + ~| "expect name. token: {<-<.tokens>}" + (got-name -.tokens) + =. tokens +.tokens + =/ limbs=(list jlimb) ~[[%name name]] + :: - %name (there is no next token, which is the end of the jock) ?: =(~ tokens) [[%limb limbs] tokens] + :: - %name (there is a wing with multiple entries) ?: ?=(^ (get-name -.tokens)) [[%limb limbs] tokens] + :: - %name (';' is the next token, which is consumed outside) + ?: (has-punctuator -.tokens %';') + [[%limb limbs] tokens] |- ?: =(~ tokens) [[%limb limbs] tokens] ?^ nom=(get-name -.tokens) $(tokens +.tokens, limbs [[%name u.nom] limbs]) + :: - %name ('.' is the next token; there is a wing) ?: (has-punctuator -.tokens %'.') $(tokens +.tokens) + :: - %edit ('=' is the next token) ?: (has-punctuator -.tokens %'=') ?: (has-punctuator -.+.tokens %'=') =^ b tokens @@ -544,6 +570,7 @@ =^ jock tokens (match-jock +.tokens) [[%edit limbs val jock] tokens] + :: - %compare ('==' or '<' or '>' or '!' is next) ?: ?| (has-punctuator -.tokens %'<') (has-punctuator -.tokens %'>') (has-punctuator -.tokens %'!') @@ -553,6 +580,7 @@ =^ inner-two tokens (match-inner-jock tokens) [[%compare [%limb limbs] comparator inner-two] tokens] + :: - %call ('((' is the next token) ?: (has-punctuator -.tokens %'((') |- =. tokens +.tokens @@ -643,6 +671,33 @@ :: %')' consumed by +match-pair-inner-jock [[%call [%lambda lambda] `arg] tokens] :: + :: protocol A { func add(#) -> #; func sub(#) -> #; }; + :: [%protocol type=jock body=(map jype jype) next=jock] + %protocol + :: metatype label + =/ type -.tokens + ?> ?=(%type -.type) + :: mask out reserved types + ?: =([%type 'List'] type) !! + ?: =([%type 'Set'] type) !! + ?: =([%type 'Map'] type) !! + =. tokens +.tokens + ?> (got-punctuator -.tokens %'{') + =| arg=(map term jype) + =. tokens +.tokens + =^ body tokens + |- + ?: (has-punctuator -.tokens %'}') + [arg +.tokens] + =^ jype tokens + (match-trait +.tokens) + $(arg (~(put by arg) name.jype jype)) + ?> (got-punctuator -.tokens %';') + =. tokens +.tokens + =^ next tokens + (match-jock tokens) + [`jock`[%protocol `jock`[%limb ~[[%name +.type]]] `(map term jype)`body `jock`next] tokens] + :: :: if (a < b) { +(a) } else { +(b) } :: [%if cond=jock then=jock after-if=after-if-expression] %if @@ -678,8 +733,16 @@ %object =/ has-name ?=(^ (get-name -.tokens)) =/ cor-name (fall (get-name -.tokens) %$) - =? tokens has-name - +.tokens + ~& name+cor-name + ~& tokkens+[+.tokens] + =? tokens has-name +.tokens + ~& name+cor-name + ~& tokens+tokens + =/ validated=? (has-punctuator -.tokens %':') + =/ has-type ?=(^ (get-name +<.tokens)) + =/ cor-type (fall (get-name +<.tokens) %$) + ~& type+cor-type + =? tokens has-type +>.tokens ?> (got-punctuator -.tokens %'{') =. tokens +.tokens =^ core tokens @@ -811,9 +874,12 @@ :: Match on loobean type a:? ?: (has-punctuator -.tokens %'?') [[%atom %loobean %.n] +.tokens] - :: Match on no type a:* + :: Match on noun type a:* ?: (has-punctuator -.tokens %'*') [[%none ~] +.tokens] + :: Match on trait placeholder type # + ?: (has-punctuator -.tokens %'#') + [[%none [~ %$]] +.tokens] :: %core :: Match on lambda definition (a:@) -> @ ?: (has-punctuator -.tokens %'(') @@ -865,31 +931,31 @@ ++ mini ?(%'<' %'>' %'=' %'!') ++ comp (perk %'<' %'>' %'=' %'!' ~) -- - ?~ tokens ~|("expect comparator. token: ~" !!) - ?. ?=(%punctuator -.i.tokens) - ~|("expect punctuator. token: {<-.i.tokens>}" !!) + ?: =(~ tokens) ~|("expect comparator. token: ~" !!) + ?. ?=(%punctuator -<.tokens) + ~|("expect punctuator. token: {<-<.tokens>}" !!) =/ cm1=(unit mini) - (rust (trip +.i.tokens) (full comp)) + (rust (trip ->.tokens) (full comp)) ?~ cm1 - ~|("match-comparator failed: {}" !!) - ?~ t.tokens - [;;(comparator u.cm1) t.tokens] - ?. ?=(%punctuator -.i.t.tokens) - [;;(comparator u.cm1) t.tokens] + ~|("match-comparator failed: {<-.tokens>}" !!) + ?: =(~ +.tokens) + [;;(comparator u.cm1) +.tokens] + ?. ?=(%punctuator +<-.tokens) + [;;(comparator u.cm1) +.tokens] =/ cm2=(unit mini) - (rust (trip +.i.t.tokens) (full comp)) + (rust (trip +<+.tokens) (full comp)) ?~ cm2 - [;;(comparator u.cm1) t.tokens] + [;;(comparator u.cm1) +.tokens] =/ final (cat 3 u.cm1 u.cm2) - [;;(comparator final) t.t.tokens] + [;;(comparator final) +>.tokens] :: ++ match-after-if-expression |= =tokens ^- (pair after-if-expression (list token)) - ?~ tokens + ?: =(~ tokens) ~|("expect after-if. token: ~" !!) ?. ?=(%keyword -<.tokens) - ~|("expect keyword. token: {<-.i.tokens>}" !!) + ~|("expect keyword. token: {<-<.tokens>}" !!) ?. =(%else ->.tokens) ~|("expect %else. token: {<->.tokens>}" !!) => .(tokens `(list token)`+.tokens) @@ -917,7 +983,7 @@ ++ match-literal |= =tokens ^- [[%atom jatom] (list token)] - ?~ tokens ~|("expect literal. token: ~" !!) + ?: =(~ tokens) ~|("expect literal. token: ~" !!) ?. ?=(%literal -<.tokens) ~|("expect literal. token: {<-<.tokens>}" !!) [[%atom ->.tokens] +.tokens] @@ -972,10 +1038,10 @@ ++ got-jatom-number |= =tokens ^- @ - ?~ tokens ~|("expect literal. token: ~" !!) - ?. ?=(%literal -.i.tokens) - ~|("expect literal or symbol. token: {<-.i.tokens>}" !!) - =/ p=jatom +.i.tokens + ?: =(~ tokens) ~|("expect literal. token: ~" !!) + ?. ?=(%literal -<.tokens) + ~|("expect literal or symbol. token: {<-<.tokens>}" !!) + =/ p=jatom ->.tokens ?. ?=(%number -<.p) ~|("expect number or symbol. token: {<-.p>}" !!) ->.p @@ -989,9 +1055,10 @@ :: ++ get-name |= =token - ^- (unit term) - ?. ?=(%name -.token) ~ - [~ +.token] + ^- (unit cord) + ?. |(?=(%name -.token) ?=(%type -.token)) ~ + ?: ?=(%name -.token) [~ +.token] + ?> ?=(%type -.token) [~ +.token] :: ++ got-punctuator |= [=token punc=jpunc] @@ -1221,7 +1288,7 @@ :_ name.jyp ?: =(%none -.p.jyp) p.v - ?: =(%none -.p.v) + ?: =(%none -.p.v) p.jyp ?> =(-.p.jyp -.p.v) p.jyp @@ -1269,6 +1336,29 @@ ~| %func-next =+ [nex nex-jyp]=$(j next.j) [[%8 val nex] nex-jyp] + :: + %protocol + ~| %protocol + ~& type+type.j + ~& body+body.j + ~& next+next.j + :: ~& %+ turn + :: ~(tap by body.j) + :: |= [k=term v=jype] + :: :: =/ res (~(get-limb jt jyp) ~[[%name k]]) + :: =+ [typ typ-jyp]=^$(j v) + :: =. jyp + :: =/ inferred-type + :: (~(unify jt type.j) typ-jyp) + :: ?~ inferred-type + :: ~| '%protocol: body type does not nest in declared type' + :: ~| ['have:' typ-jyp 'need:' type.j] + :: !! + :: (~(cons jt u.inferred-type) jyp) + :: [k res] + :: :: |=([k=term v=jype] =+([val val-jyp]=^$(jyp v) [key+k val+val jyp+val-jyp])) + =+ [nex nex-jyp]=$(j next.j) + [nex nex-jyp] :: %edit =/ [typ=jype axi=@] @@ -1594,8 +1684,8 @@ == :: %atom - ~| [%atom +.-.+.j] - :- [%1 +.-.+.j] + ~| [%atom +<+.j] + :- [%1 +<+.j] [^-(jype-leaf [%atom +<-.j +>.j]) %$] :: %crash diff --git a/hoon/lib/test-jock.hoon b/hoon/lib/test-jock.hoon index 9c76731..1b9d91d 100644 --- a/hoon/lib/test-jock.hoon +++ b/hoon/lib/test-jock.hoon @@ -24,6 +24,7 @@ /* match-type %jock /lib/tests/match-type/jock /* example-atom %jock /lib/tests/example-atom/jock /* sets %jock /lib/tests/sets/jock +/* protocol %jock /lib/tests/protocol/jock :: /* test-let-edit %hoon /tests/lib/let-edit/hoon /* test-let-inner-exp %hoon /tests/lib/let-inner-exp/hoon @@ -79,6 +80,7 @@ [%match-type q.match-type] :: 21 [%example-atom q.example-atom] :: 22 [%sets q.sets] :: 23 + [%protocol q.protocol] :: 24 == :: ++ test-jocks @@ -158,6 +160,9 @@ [%test-sets-tokens test-tokenize:test-sets] [%test-sets-jeam test-jeam:test-sets] [%test-sets-mint test-mint:test-sets] + :: [%test-protocol-tokens test-tokenize:test-protocol] + :: [%test-protocol-jeam test-jeam:test-protocol] + :: [%test-protocol-mint test-mint:test-protocol] == :: ++ parse diff --git a/hoon/lib/tests/protocol.jock b/hoon/lib/tests/protocol.jock new file mode 100644 index 0000000..5a6d627 --- /dev/null +++ b/hoon/lib/tests/protocol.jock @@ -0,0 +1,26 @@ +protocol Arithmetic { + func add(#) -> #; + func sub(#) -> #; +}; + +object Point: Arithmetic { + p:(x:@ y:@); + init(q:(x:@ y:@)) -> Point { + p.x = q.x; + p.y = q.y; + } + add(q:Point) -> Point { + Point(((p.x + q.x) (p.y + q.y))) + }; + sub(q:Point) -> Point { + Point(((p.x - q.x) (p.y - q.y))) + }; +}; + +5; + +/*let origin:Point = (0 0); +let vector:Point = (1 2); + +origin.add(vector) +*/ diff --git a/hoon/tests/lib/let-edit.hoon b/hoon/tests/lib/let-edit.hoon index 4c447ab..ac1186c 100644 --- a/hoon/tests/lib/let-edit.hoon +++ b/hoon/tests/lib/let-edit.hoon @@ -1,23 +1,23 @@ :: /lib/tests/let-edit -/+ jock, - test +/+ *jock, + *test :: |% ++ text 'let a: ? = true;\0a\0aa = false;\0a\0aa' ++ test-tokenize - %+ expect-eq:test + %+ expect-eq !> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'?'] [%punctuator %'='] [%literal [[%loobean p=%.y] q=%.n]] [%punctuator %';'] [%name %a] [%punctuator %'='] [%literal [[%loobean p=%.n] q=%.n]] [%punctuator %';'] [%name %a]] - !> (rash text parse-tokens:jock) + !> (rash text parse-tokens) :: ++ test-jeam - %+ expect-eq:test - !> ^- jock:jock + %+ expect-eq + !> ^- jock [%let type=[p=[%atom p=%loobean q=%.n] name=%a] val=[%atom p=[[%loobean p=%.y] q=%.n]] next=[%edit limb=~[[%name p=%a]] val=[%atom p=[[%loobean p=%.n] q=%.n]] next=[%limb p=~[[%name p=%a]]]]] - !> (jeam:jock text) + !> (jeam text) :: ++ test-mint - %+ expect-eq:test + %+ expect-eq !> [8 [1 0] 7 [10 [2 1 1] 0 1] 0 2] - !> (mint:jock text) + !> (mint text) -- \ No newline at end of file diff --git a/main.rs b/main.rs index 248b459..69e0115 100644 --- a/main.rs +++ b/main.rs @@ -42,7 +42,8 @@ enum Command { #[tokio::main] async fn main() -> Result<(), Box> { let cli = TestCli::parse(); - let nockapp = boot::setup(KERNEL_JAM, Some(cli.boot), &[], "jock")?; + let nockapp = boot::setup(KERNEL_JAM, Some(cli.boot.clone()), &[], "jock")?; + boot::init_default_tracing(&cli.boot.clone()); let mut kernel = nockapp.kernel; let poke = match cli.command {