From a71e4d374cd6d460943c911d4e02dacf9fc0a268 Mon Sep 17 00:00:00 2001 From: sevki Date: Mon, 15 Jul 2024 12:27:36 +0100 Subject: [PATCH] formatting --- Cargo.lock | 212 ++++++++++++++--------------- build.rs | 7 +- crates/src-derive-test/src/main.rs | 20 +-- crates/src-derive/src/lib.rs | 8 +- crates/src-derive/src/node.rs | 91 +++++-------- crates/src-derive/src/walker.rs | 179 ------------------------ src/analyzer/mod.rs | 9 +- src/ast/mod.rs | 27 +++- src/compiler/errors.rs | 4 +- src/compiler/mod.rs | 8 +- src/lexer/mod.rs | 63 ++++----- src/ops/mod.rs | 3 +- src/parser/ast.rs | 5 +- src/parser/errors.rs | 13 +- src/parser/mod.rs | 19 +-- src/parser/span.rs | 4 +- src/parser/src.rs | 2 +- 17 files changed, 232 insertions(+), 442 deletions(-) delete mode 100644 crates/src-derive/src/walker.rs diff --git a/Cargo.lock b/Cargo.lock index e02f4f9..1b11f81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,13 +92,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] @@ -121,9 +121,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -163,9 +163,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bumpalo" @@ -175,15 +175,15 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cc" -version = "1.0.98" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "324c74f2155653c90b04f25b2a47a8a631360cb908f92a772695f430c7e31052" [[package]] name = "cfg-if" @@ -382,9 +382,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "ena" @@ -535,7 +535,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] @@ -641,9 +641,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "idna" @@ -767,9 +767,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -789,7 +789,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -817,9 +817,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lsp-text" @@ -848,15 +848,15 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -900,9 +900,9 @@ dependencies = [ [[package]] name = "object" -version = "0.35.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" dependencies = [ "memchr", ] @@ -915,7 +915,7 @@ checksum = "769aac233e4883cafe74ae54d6ed7195f32498efce93eb325656408fc7fb4f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] @@ -970,7 +970,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1047,7 +1047,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] @@ -1110,22 +1110,22 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand", @@ -1193,11 +1193,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -1213,9 +1213,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -1225,9 +1225,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -1236,9 +1236,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "ropey" @@ -1268,7 +1268,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -1348,29 +1348,29 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -1385,7 +1385,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] @@ -1514,7 +1514,7 @@ name = "srclang" version = "0.1.0" dependencies = [ "anyhow", - "bitflags 2.5.0", + "bitflags 2.6.0", "getrandom", "hashbrown 0.14.5", "insta", @@ -1528,7 +1528,7 @@ dependencies = [ "salsa-2022", "salsa-2022-macros", "src-derive", - "syn 2.0.66", + "syn 2.0.71", "tiny-keccak", ] @@ -1564,9 +1564,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" dependencies = [ "proc-macro2", "quote", @@ -1607,22 +1607,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] @@ -1636,9 +1636,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -1651,9 +1651,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -1670,13 +1670,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] [[package]] @@ -1785,9 +1785,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1847,15 +1847,15 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.31" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "futures-core", @@ -1882,7 +1882,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1962,7 +1962,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1982,18 +1982,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2004,9 +2004,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2016,9 +2016,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2028,15 +2028,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2046,9 +2046,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2058,9 +2058,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2070,9 +2070,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2082,9 +2082,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "yansi" @@ -2094,20 +2094,20 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.71", ] diff --git a/build.rs b/build.rs index bfa9546..312c9eb 100644 --- a/build.rs +++ b/build.rs @@ -1,12 +1,12 @@ use core::panic; use std::fmt::Write as _; use std::fs::File; -use std::io::{BufRead, BufReader, Write}; +use std::io::{BufRead, BufReader}; use std::path::PathBuf; use tiny_keccak::{Hasher, Sha3}; const SOURCE: &str = "src/parser/src.lalrpop"; -const TARGET: &str = "parser/src.rs"; +const TARGET: &str = "src/parser/src.rs"; fn main() -> anyhow::Result<()> { println!("cargo:rerun-if-changed={SOURCE}"); @@ -79,7 +79,8 @@ fn try_lalrpop(source: &str, target: &str) -> anyhow::Result<()> { println!("cargo:rerun-if-changed={}", path); lalrpop::Configuration::new() .generate_in_source_tree() - .process_file(path).expect("msg"); + .process_file(path) + .expect("msg"); Ok(()) } diff --git a/crates/src-derive-test/src/main.rs b/crates/src-derive-test/src/main.rs index 2150fe0..516cb84 100644 --- a/crates/src-derive-test/src/main.rs +++ b/crates/src-derive-test/src/main.rs @@ -61,33 +61,33 @@ pub enum Operator { struct PrettyPrinter; impl FieldVisitor for PrettyPrinter { - fn visit_vis(&self, vis: &Visibility, range: &Range) -> ops::traversal::Result { + fn visit_vis(&self, vis: &Visibility, range: &Range) -> ops::traversal::Control { print!("{} ", vis); - ops::traversal::Result::Continue + ops::traversal::Control::Continue } - fn visit_name(&self, name: &String, range: &Range) -> ops::traversal::Result { + fn visit_name(&self, name: &String, range: &Range) -> ops::traversal::Control { print!("{} :", name); - ops::traversal::Result::Continue + ops::traversal::Control::Continue } - fn visit_ty(&self, ty: &Ident, range: &Range) -> ops::traversal::Result { + fn visit_ty(&self, ty: &Ident, range: &Range) -> ops::traversal::Control { ty.accept(self); - ops::traversal::Result::Continue + ops::traversal::Control::Continue } } impl IdentVisitor for PrettyPrinter { - fn visit_name(&self, name: &String, range: &Range) -> ops::traversal::Result { + fn visit_name(&self, name: &String, range: &Range) -> ops::traversal::Control { print!("{}", name); - ops::traversal::Result::Continue + ops::traversal::Control::Continue } - fn visit_generics(&self, generic: &Ident, range: &Range) -> ops::traversal::Result { + fn visit_generics(&self, generic: &Ident, range: &Range) -> ops::traversal::Control { print!("<"); generic.accept(self); print!(">"); - ops::traversal::Result::Continue + ops::traversal::Control::Continue } } diff --git a/crates/src-derive/src/lib.rs b/crates/src-derive/src/lib.rs index eab6525..b8d3a71 100644 --- a/crates/src-derive/src/lib.rs +++ b/crates/src-derive/src/lib.rs @@ -1,13 +1,7 @@ use proc_macro::TokenStream; mod node; -mod walker; #[proc_macro_attribute] pub fn node(_attr: TokenStream, item: TokenStream) -> TokenStream { - TokenStream::from(node::define_nodes(_attr, item)) -} - -#[proc_macro_attribute] -pub fn walker(_attr: TokenStream, item: TokenStream) -> TokenStream { - TokenStream::from(walker::generate_walker_impl(item)) + node::define_nodes(_attr, item) } diff --git a/crates/src-derive/src/node.rs b/crates/src-derive/src/node.rs index 2c287d1..2093521 100644 --- a/crates/src-derive/src/node.rs +++ b/crates/src-derive/src/node.rs @@ -1,9 +1,6 @@ use proc_macro::TokenStream; use quote::{format_ident, quote, ToTokens}; -use syn::{ - parse_macro_input, Data, DeriveInput, Fields, GenericArgument, Ident, PathArguments, Type, - TypePath, -}; +use syn::{parse_macro_input, Data, DeriveInput, GenericArgument, PathArguments, Type, TypePath}; pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as DeriveInput); @@ -38,7 +35,7 @@ pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { } }); - let expanded_impl = fields.iter().map(|field| { + let _expanded_impl = fields.iter().map(|field| { let field_name = &field.ident; let field_span_getter = format_ident!("{}_span", field_name.as_ref().unwrap()); let field_node_getter = format_ident!("{}_node", field_name.as_ref().unwrap()); @@ -68,22 +65,20 @@ pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { let visitor_name = format_ident!("{}Visitor", struct_name); let visitor_trait_stub = fields.iter().map(|field| { let field_name = &field.ident; - let field_visit = format_ident!("visit_{}", field_name.as_ref().unwrap()); - let field_type = &field.ty; - match field_type { - Type::Path(path) => { - let unwrapped_type = unwrap_path(path); - quote! { - fn #field_visit(&self, node: &#unwrapped_type, span: &Range) -> ops::traversal::Result; - } + if let Some(field_name) = field_name { + if field_name.to_string().starts_with('_') { + return quote! {}; } - _ => { - panic!( - "Only named fields are supported which {} is not", - field_type.into_token_stream() - ); + let field_visit = format_ident!("visit_{}", field_name); + let field_type = &field.ty; + if let Type::Path(path) = field_type { + let unwrapped_type = unwrap_path(path); + return quote! { + fn #field_visit(&self, node: &#unwrapped_type, span: &Range) -> ops::traversal::Control; + }; } } + panic!("All fields must be named") }); let accept_impl = fields.iter().map(|field| { @@ -99,13 +94,20 @@ pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { if let cont = visitor.#visit_fn( &self.#field_name.1, &(self.#field_name.0..self.#field_name.2) - ) { - return; + ) { + if cont == ops::traversal::Control::Break { + return; + } } } } PathArguments::AngleBracketed(args) => match args.args.first() { Some(GenericArgument::Type(_)) => match ident.to_string().as_str() { + "PhantomData" => { + quote! { + // Do nothing + } + } "Option" => { quote! { if let Some(inner) = &self.#field_name { @@ -197,11 +199,17 @@ pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { let field_types_clone = field_types.clone(); let struct_name_lower = format_ident!("{}", struct_name.to_string().to_lowercase()); let field_ids = fields.iter().enumerate().map(|field| { + if fields.len() == 1 { + return quote! { + #struct_name_lower + }; + } let field_name = syn::Index::from(field.0); quote! { #struct_name_lower.#field_name } }); + let vis = &input.vis; let expanded = quote! { #[derive(Debug)] @@ -216,8 +224,8 @@ pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { > for #struct_name { fn from( #struct_name_lower: ( - #(#field_types_clone),* - ) + #(#field_types_clone),* + ) ) -> Self { Self::new( #(#field_ids),* @@ -244,16 +252,13 @@ pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { } fn wrap_range_location(path: &TypePath) -> impl ToTokens { match path.path.segments.last() { - Some(syn::PathSegment { ident, arguments }) => { - if let syn::PathArguments::AngleBracketed(args) = arguments { - if let Some(GenericArgument::Type(inner_ty)) = args.args.first() { - quote! { - #ident> - } - } else { - quote! { - Range - } + Some(syn::PathSegment { + ident, + arguments: syn::PathArguments::AngleBracketed(args), + }) => { + if let Some(GenericArgument::Type(_inner_ty)) = args.args.first() { + quote! { + #ident> } } else { quote! { @@ -322,25 +327,3 @@ fn unwrap_path(path: &TypePath) -> impl ToTokens { } } } - -fn wrap_type_in_spanned(ty: &Type, field_name: &Option) -> impl ToTokens { - match (ty, field_name) { - (Type::Path(path), Some(field_name)) => { - let ty = wrap_path_in_spanned(path); - quote! { - #field_name: #ty, - } - } - (Type::Path(path), None) => { - let ty = wrap_path_in_spanned(path); - quote! { - #ty, - } - } - _ => { - quote! { - compile_error!("Only named fields are supported"); - } - } - } -} diff --git a/crates/src-derive/src/walker.rs b/crates/src-derive/src/walker.rs deleted file mode 100644 index a92743a..0000000 --- a/crates/src-derive/src/walker.rs +++ /dev/null @@ -1,179 +0,0 @@ -use proc_macro2::{Ident, TokenStream}; -use quote::{format_ident, quote, ToTokens}; -use syn::{ - parse_macro_input, Data, DeriveInput, Fields, GenericArgument, PathArguments, Type, TypePath, -}; - -pub fn generate_walker_impl(item: proc_macro::TokenStream) -> proc_macro::TokenStream { - let input = parse_macro_input!(item as DeriveInput); - let type_name = &input.ident; - let walker_name = format_ident!("{}Walker", type_name); - let visitor_name = format_ident!("{}Visitor", type_name); - - let walk_impl = generate_walk_impl(type_name, &input.data); - - let expanded = quote! { - #input - - pub struct #walker_name; - - impl #walker_name { - pub fn walk(node: &Spanned<#type_name>, visitor: &mut V) { - #walk_impl - } - } - }; - - proc_macro::TokenStream::from(expanded) -} - -fn generate_walk_impl(type_name: &Ident, data: &Data) -> TokenStream { - match data { - Data::Struct(data_struct) => generate_struct_walk_impl(data_struct), - Data::Enum(data_enum) => generate_enum_walk_impl(type_name, data_enum), - Data::Union(_) => panic!("Unions are not supported"), - } -} -fn generate_field_visit(ty: &Type, field_access: TokenStream) -> TokenStream { - match ty { - Type::Path(TypePath { path, .. }) => { - if let Some(segment) = path.segments.last() { - match segment.ident.to_string().as_str() { - "Spanned" => { - if let PathArguments::AngleBracketed(args) = &segment.arguments { - if let Some(GenericArgument::Type(inner_type)) = args.args.first() { - let visit_method = format_ident!( - "visit_{}", - inner_type.to_token_stream().to_string().to_lowercase() - ); - return quote! { - visitor.#visit_method(&(#field_access).1, (#field_access).span()); - }; - } - } - } - "Box" => { - if let PathArguments::AngleBracketed(args) = &segment.arguments { - if let Some(GenericArgument::Type(inner_type)) = args.args.first() { - let inner_visit = - generate_field_visit(inner_type, quote! { (*#field_access) }); - return quote! { - #inner_visit - }; - } - } - } - "Option" => { - if let PathArguments::AngleBracketed(args) = &segment.arguments { - if let Some(GenericArgument::Type(inner_type)) = args.args.first() { - let inner_visit = - generate_field_visit(inner_type, quote! { inner }); - return quote! { - if let Some(inner) = #field_access.as_ref() { - #inner_visit - } - }; - } - } - } - "Vec" => { - if let PathArguments::AngleBracketed(args) = &segment.arguments { - if let Some(GenericArgument::Type(inner_type)) = args.args.first() { - let inner_visit = generate_field_visit(inner_type, quote! { item }); - return quote! { - for item in #field_access.iter() { - #inner_visit - } - }; - } - } - } - _ => {} - } - } - } - _ => {} - } - quote! {} -} - -fn generate_struct_walk_impl(data_struct: &syn::DataStruct) -> TokenStream { - let field_visits = data_struct - .fields - .iter() - .map(|field| { - let field_name = &field.ident; - generate_field_visit(&field.ty, quote!(node.1.#field_name)) - }) - .collect::>(); - - quote! { - #(#field_visits)* - } -} - -fn generate_enum_walk_impl(enum_name: &Ident, data_enum: &syn::DataEnum) -> TokenStream { - let variant_matches = data_enum - .variants - .iter() - .map(|variant| { - let variant_name = &variant.ident; - - match &variant.fields { - Fields::Unnamed(fields) if fields.unnamed.len() == 1 => { - let field_visit = generate_field_visit(&fields.unnamed[0].ty, quote!(value)); - quote! { - #enum_name::#variant_name(value) => { - #field_visit - } - } - } - _ => quote! { - #enum_name::#variant_name { .. } => {} - }, - } - }) - .collect::>(); - - quote! { - match &node.1 { - #(#variant_matches)* - } - } -} - -fn is_spanned_type(ty: &Type) -> bool { - if let Type::Path(TypePath { path, .. }) = ty { - if let Some(segment) = path.segments.last() { - return segment.ident == "Spanned"; - } - } - false -} - -fn is_box_type(ty: &Type) -> bool { - if let Type::Path(TypePath { path, .. }) = ty { - if let Some(segment) = path.segments.last() { - return segment.ident == "Box"; - } - } - false -} - -fn is_option_type(ty: &Type) -> bool { - if let Type::Path(TypePath { path, .. }) = ty { - if let Some(segment) = path.segments.last() { - return segment.ident == "Option"; - } - } - false -} - -fn is_vec_type(ty: &Type) -> bool { - if let Type::Path(TypePath { path, .. }) = ty { - if let Some(segment) = path.segments.last() { - return segment.ident == "Vec"; - } - } - false -} diff --git a/src/analyzer/mod.rs b/src/analyzer/mod.rs index 1d907d9..a459391 100644 --- a/src/analyzer/mod.rs +++ b/src/analyzer/mod.rs @@ -1,8 +1,7 @@ pub mod db; use crate::{ - compiler::text::{self, Position, SourceMap, SourceProgram, Span}, - lexer::Location, + compiler::text::{self, SourceProgram}, parser::{ ast::{self, Node}, span::{self, ByteOrLineColOrCoord, Spanned}, @@ -47,9 +46,9 @@ impl SyntaxTree { #[salsa::tracked] pub fn get_symbol( - db: &dyn Db, - src: text::SourceProgram, - pos: span::ByteOrLineColOrCoordInterned, + _db: &dyn Db, + _src: text::SourceProgram, + _pos: span::ByteOrLineColOrCoordInterned, ) -> Option> { None } diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 9416b2a..4f90bf9 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -1,6 +1,6 @@ use crate::lexer::Location; -use crate::ops; use crate::parser::span::Spanned; +use crate::{ops}; use src_derive::node; use std::fmt::Display; use std::ops::Range; @@ -28,6 +28,31 @@ pub enum Literal { String(String), } +#[derive(Debug)] +pub enum Kw { + None, + Some, + Let, + Public, + Private, + Fn, + If, + Else, + Match, + Arrow, + Struct, + SelfValue, + When, + Effect, + Impl, + Use, +} + +#[node] +pub struct Keyword { + kw: Kw, +} + #[derive(Debug)] /// An enum representing the visibility of a field or method. pub enum Visibility { diff --git a/src/compiler/errors.rs b/src/compiler/errors.rs index 82b2b4b..1fb3e06 100644 --- a/src/compiler/errors.rs +++ b/src/compiler/errors.rs @@ -68,8 +68,8 @@ fn handle_errors( "error: unexpected token {:?}, expected one of {:?}\n", token.1, expected )); - pretty.push_str(&line); - pretty.push_str("\n"); + pretty.push_str(line); + pretty.push('\n'); pretty.push_str(&" ".repeat(start_col)); pretty.push_str(&"^".repeat(end_col - start_col)); last_end = end; diff --git a/src/compiler/mod.rs b/src/compiler/mod.rs index 0e867e0..a1996f6 100644 --- a/src/compiler/mod.rs +++ b/src/compiler/mod.rs @@ -29,7 +29,7 @@ pub fn compile(db: &dyn Db, src: SourceProgram) -> ir::Program { } let modul = t.unwrap(); - let mut symbol_table = BTreeMap::new(); + let symbol_table = BTreeMap::new(); for toplevel in modul.0 { match toplevel.1 { ast::Node::Visibility(_) => todo!(), @@ -46,7 +46,7 @@ pub fn compile(db: &dyn Db, src: SourceProgram) -> ir::Program { } ast::Node::EffectDef(_) => todo!(), ast::Node::StructDef(_) => todo!(), - ast::Node::UseDef(usedef) => {} + ast::Node::UseDef(_usedef) => {} ast::Node::Keyword(_) => todo!(), ast::Node::ImplDef(_) => todo!(), ast::Node::Branch(_) => todo!(), @@ -54,9 +54,9 @@ pub fn compile(db: &dyn Db, src: SourceProgram) -> ir::Program { ast::Node::FieldAccess(_) => todo!(), } } - let program = ir::Program::new(db, vec![], symbol_table); + - program + ir::Program::new(db, vec![], symbol_table) } #[salsa::tracked] diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index 797cefd..d9bed4c 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -100,6 +100,9 @@ impl Spanned> { pub fn len(&self) -> usize { self.node.string_repr().chars().count() } + pub fn is_empty(&self) -> bool { + self.len() == 0 + } } // Position struct @@ -261,6 +264,7 @@ pub enum Token<'input> { impl<'input> Token<'input> { // deprecated #[deprecated(note = "to_chars is deprecated, use to_string instead")] + #[allow(unused)] fn to_chars(&'input self) -> Chars<'input> { match self { Token::Pipe => "|".chars(), @@ -356,7 +360,7 @@ impl<'input> Iterator for Token<'input> { type Item = char; fn next(&mut self) -> Option { - self.to_chars().next() + self.string_repr().chars().next() } } @@ -446,8 +450,8 @@ impl<'input> Lexer<'input> { fn push(&mut self) -> bool { let c = self.peekable.next().unwrap(); self.buffer.push(c); - let finished = (self.pos as i32) + self.buffer.len() as i32 >= self.input.len() as i32; - finished + + (self.pos as i32) + self.buffer.len() as i32 >= self.input.len() as i32 } fn ignore(&mut self) -> bool { @@ -467,8 +471,8 @@ impl<'input> Lexer<'input> { } else { self.col += 1; } - let finished = self.pos >= self.input.len(); - finished + + self.pos >= self.input.len() } fn peek(&mut self) -> Option { @@ -627,8 +631,8 @@ impl<'input> Lexer<'input> { .map_err(|_| LexicalError::InvalidNumberFormat)?; Ok(Token::Float(float)) - } else if number.starts_with("0x") { - let integer = i64::from_str_radix(&number[2..], 16) + } else if let Some(stripped) = number.strip_prefix("0x") { + let integer = i64::from_str_radix(stripped, 16) .map_err(|_| LexicalError::InvalidNumberFormat)?; Ok(Token::Integer(integer)) } else { @@ -744,17 +748,7 @@ impl<'input> Lexer<'input> { } } } - '/' => { - let state = if self.push() { State::Eof } else { State::Any }; - match self.peek() { - Some(' ') => { - return emit!(self, state => ?); - } - _ => { - return emit!(self, state => ?); - } - } - } // / and /directory/file + // / and /directory/file '!' => { let state = if self.push() { State::Eof } else { State::Any }; if let Some('#') = self.peek() { @@ -811,7 +805,7 @@ impl<'input> Lexer<'input> { } } } - return emit!(self, State::Any => ?); + emit!(self, State::Any => ?) } // consume number @@ -855,7 +849,7 @@ impl<'input> Lexer<'input> { } } // handle scientific notation - else if self.buffer.contains(".") && c == 'e' { + else if self.buffer.contains('.') && c == 'e' { if self.push() { debug!("buffer: {}", self.buffer); return emit!(self, State::Number => ?); @@ -870,17 +864,17 @@ impl<'input> Lexer<'input> { } } } - return emit!(self, State::Eof => ?); + emit!(self, State::Eof => ?) } fn consume_newline(&mut self) -> Result>> { match self.peek() { Some('\n') => { let state = if self.push() { State::Eof } else { State::Any }; - return emit!(self, state => ?); + emit!(self, state => ?) } _ => { - return emit!(self, State::Any => Token::NewLine); + emit!(self, State::Any => Token::NewLine) } } } @@ -911,7 +905,7 @@ impl<'input> Lexer<'input> { } } } - return Err(LexicalError::UnexpectedEndOfInput); + Err(LexicalError::UnexpectedEndOfInput) } fn consume_variable(&mut self) -> Result>> { @@ -929,7 +923,7 @@ impl<'input> Lexer<'input> { } } } - return emit!(self, State::Op => ?); + emit!(self, State::Op => ?) } } @@ -971,17 +965,12 @@ impl<'input> Iterator for Lexer<'input> { self.buffer.clear(); match res { Ok(token) => { - match token.node { - Token::Eof => { - return None; - } - _ => {} + if token.node == Token::Eof { + return None; } - return Some(token); - } - _ => { - return None; + Some(token) } + _ => None, } // Removed the panic! as it's now unreachable. } @@ -992,11 +981,7 @@ struct TokenStreamDisplay<'input>(Vec>>); impl Display for TokenStreamDisplay<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for token in &self.0 { - write!( - f, - "- {}, {}:{}\n", - token.node, token.pos.line, token.pos.col - )?; + writeln!(f, "- {}, {}:{}", token.node, token.pos.line, token.pos.col)?; } Ok(()) } diff --git a/src/ops/mod.rs b/src/ops/mod.rs index bce9c54..f4777d4 100644 --- a/src/ops/mod.rs +++ b/src/ops/mod.rs @@ -1,7 +1,8 @@ /// This module contains the srclang ops. pub mod traversal { /// The result of a traversal operation. - pub enum Result { + #[derive(Debug, PartialEq, Eq)] + pub enum Control { /// Continue the traversal. Continue, /// Stop the traversal. diff --git a/src/parser/ast.rs b/src/parser/ast.rs index 94016eb..eac604e 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -1,8 +1,5 @@ -use std::{fmt::Display, ops::Range}; +use std::fmt::Display; pub const ANON_FN_NAME: &str = "anonymous"; -use super::span; -use super::span::*; -use src_derive::node; use super::span::*; diff --git a/src/parser/errors.rs b/src/parser/errors.rs index c9a4f14..1f3de6c 100644 --- a/src/parser/errors.rs +++ b/src/parser/errors.rs @@ -1,7 +1,8 @@ use crate::lexer::Location; -pub fn pretty_errors<'input>( - src: &'input str, +#[allow(unused)] +pub fn pretty_errors( + src: &str, errors: Vec, &str>>, ) -> String { let mut pretty = String::new(); @@ -21,8 +22,8 @@ pub fn pretty_errors<'input>( "error: unexpected end of file, expected one of {:?}\n", expected )); - pretty.push_str(&line); - pretty.push_str("\n"); + pretty.push_str(line); + pretty.push('\n'); pretty.push_str(&" ".repeat(start_col)); pretty.push_str(&"^".repeat(end_col - start_col)); } @@ -44,8 +45,8 @@ pub fn pretty_errors<'input>( "error: unexpected token {:?}, expected one of {:?}\n", token.1, expected )); - pretty.push_str(&line); - pretty.push_str("\n"); + pretty.push_str(line); + pretty.push('\n'); pretty.push_str(&" ".repeat(start_col)); pretty.push_str(&"^".repeat(end_col - start_col)); } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 79eca7d..34f6881 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -1,5 +1,3 @@ -use crate::lexer::Location; - pub mod ast; mod errors; #[cfg(test)] @@ -7,20 +5,5 @@ mod parser_snap_tests; mod string; pub mod span; +#[allow(clippy::all)] pub mod src; - - -// pub fn parse( -// src: &str, -// ) -> Result< -// crate::parser::ast::Module, -// Vec>, -// > { -// let mut errors: Vec> = vec![]; -// let wrapper = crate::lexer::TripleIterator::new(src); -// let module = crate::parser::src::SourceParser::new().parse(&mut errors, wrapper); -// if !errors.is_empty() { -// return Err(errors); -// } -// Ok(module.unwrap()) -// } diff --git a/src/parser/span.rs b/src/parser/span.rs index fec8fdb..f2ce3f3 100644 --- a/src/parser/span.rs +++ b/src/parser/span.rs @@ -3,7 +3,7 @@ use hashbrown::HashMap; use okstd::prelude::*; use std::{fmt::Display, ops::Range}; -use super::ast::{self, BinaryOperation, Node}; +use super::ast::Node; #[derive(PartialEq, Debug, Clone, Eq, PartialOrd)] pub struct Spanned(pub Location, pub T, pub Location); @@ -27,7 +27,6 @@ impl GetSelf for Spanned { } } - impl Display for Spanned { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.1) @@ -110,6 +109,7 @@ impl Spanning for Spanned { impl Spanning for &Range { fn span(&self) -> Range { + #![allow(suspicious_double_ref_op)] self.clone().clone() } } diff --git a/src/parser/src.rs b/src/parser/src.rs index a3d6807..3d4d71a 100644 --- a/src/parser/src.rs +++ b/src/parser/src.rs @@ -3,7 +3,7 @@ use super::ast::*; use lalrpop_util::ErrorRecovery; use crate::lexer::{Token, Location}; -use crate::lexer::Word; + use crate::Db; use super::span::Spanned; use crate::span;