diff --git a/Cargo.lock b/Cargo.lock index b0c8c7063..1d4a26116 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,28 +19,18 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] -[[package]] -name = "annotate-snippets" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36" -dependencies = [ - "unicode-width", - "yansi-term", -] - [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", @@ -58,30 +48,47 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" + +[[package]] +name = "ariadne" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd002a6223f12c7a95cdd4b1cb3a0149d22d37f7a9ecdb2cb691a071fe236c29" +dependencies = [ + "concolor", + "unicode-width", + "yansi", ] [[package]] @@ -114,12 +121,73 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "beef" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.4.1", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.48", + "which", +] + +[[package]] +name = "bindgen" +version = "0.68.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" +dependencies = [ + "bitflags 2.4.1", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.48", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -143,9 +211,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "cc" @@ -156,6 +230,15 @@ dependencies = [ "libc", ] +[[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" @@ -163,10 +246,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "clap" -version = "4.4.6" +name = "clang-sys" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "4.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e54881c004cec7895b0068a0a954cd5d62da01aef83fa35b1e594497bf5445" dependencies = [ "clap_builder", "clap_derive", @@ -174,33 +268,34 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "59cb82d7f531603d2fd1f507441cdd35184fa81beff7bd489570de7f773460bb" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", + "terminal_size", ] [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "color-eyre" @@ -219,9 +314,9 @@ dependencies = [ [[package]] name = "color-spantrace" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" dependencies = [ "once_cell", "owo-colors", @@ -235,12 +330,164 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "comrak" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f18e72341e6cdc7489cffb76f993812a14a906db54dedb020044ccc211dcaae" +dependencies = [ + "clap", + "derive_builder", + "entities", + "memchr", + "once_cell", + "regex", + "shell-words", + "slug", + "syntect", + "typed-arena", + "unicode_categories", + "xdg", +] + +[[package]] +name = "concolor" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b946244a988c390a94667ae0e3958411fa40cc46ea496a929b263d883f5f9c3" +dependencies = [ + "bitflags 1.3.2", + "concolor-query", + "is-terminal", +] + +[[package]] +name = "concolor-query" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" +dependencies = [ + "windows-sys 0.45.0", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "crunchy" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + +[[package]] +name = "deunicode" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae2a35373c5c74340b79ae6780b498b2b183915ec5dacf263aac5a099bf485a" + [[package]] name = "diff" version = "0.1.13" @@ -272,19 +519,64 @@ dependencies = [ name = "edlang" version = "0.1.0" dependencies = [ - "annotate-snippets", + "edlang_driver", +] + +[[package]] +name = "edlang_ast" +version = "0.1.0" + +[[package]] +name = "edlang_check" +version = "0.1.0" +dependencies = [ + "ariadne", + "edlang_ast", + "tracing", +] + +[[package]] +name = "edlang_codegen_mlir" +version = "0.1.0" +dependencies = [ + "edlang_ast", + "edlang_parser", + "edlang_session", + "llvm-sys", + "melior", + "mlir-sys", +] + +[[package]] +name = "edlang_driver" +version = "0.1.0" +dependencies = [ "clap", "color-eyre", - "inkwell", - "itertools 0.11.0", - "lalrpop", - "lalrpop-util", - "logos", - "regex", + "edlang_ast", + "edlang_check", + "edlang_codegen_mlir", + "edlang_parser", + "edlang_session", "tracing", "tracing-subscriber", ] +[[package]] +name = "edlang_parser" +version = "0.1.0" +dependencies = [ + "edlang_ast", + "lalrpop", + "lalrpop-util", + "logos", + "tracing", +] + +[[package]] +name = "edlang_session" +version = "0.1.0" + [[package]] name = "either" version = "1.9.0" @@ -300,6 +592,12 @@ dependencies = [ "log", ] +[[package]] +name = "entities" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "equivalent" version = "1.0.1" @@ -308,41 +606,50 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.4" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] name = "eyre" -version = "0.6.8" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" dependencies = [ "indenter", "once_cell", ] +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -351,9 +658,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -362,15 +669,21 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -384,6 +697,21 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +[[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 = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indenter" version = "0.3.3" @@ -392,48 +720,23 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown", ] -[[package]] -name = "inkwell" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f4fcb4a4fa0b8f7b4178e24e6317d6f8b95ab500d8e6e1bd4283b6860e369c1" -dependencies = [ - "either", - "inkwell_internals", - "libc", - "llvm-sys", - "once_cell", - "parking_lot", -] - -[[package]] -name = "inkwell_internals" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b185e7d068d6820411502efa14d8fbf010750485399402156b72dd2a548ef8e9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ "hermit-abi", "rustix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -446,13 +749,10 @@ dependencies = [ ] [[package]] -name = "itertools" -version = "0.11.0" +name = "itoa" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "lalrpop" @@ -465,7 +765,7 @@ dependencies = [ "diff", "ena", "is-terminal", - "itertools 0.10.5", + "itertools", "lalrpop-util", "petgraph", "pico-args", @@ -493,35 +793,78 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "libc" -version = "0.2.148" +name = "lazycell" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "libloading" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] + +[[package]] +name = "line-wrap" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +dependencies = [ + "safemem", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "llvm-sys" -version = "160.1.3" +version = "170.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf51981ac0622b10fe4790763e3de1f3d68a0ee4222e03accaaab6731bd508d" +checksum = "eed90f72df5504c0af2e3a08ee7762a4a3e42ec2605811fc19f64879de40c50a" dependencies = [ + "anyhow", "cc", "lazy_static", "libc", - "regex", + "regex-lite", "semver", ] [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -553,7 +896,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.6.29", - "syn", + "syn 2.0.48", ] [[package]] @@ -575,10 +918,45 @@ dependencies = [ ] [[package]] -name = "memchr" -version = "2.6.4" +name = "melior" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "634f33663d2bcac794409829caf83a08967249e5429f34ec20c92230a85c025a" +dependencies = [ + "dashmap", + "melior-macro", + "mlir-sys", + "once_cell", +] + +[[package]] +name = "melior-macro" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac9339fd6934926500d5a5f378bb5cda44efe33c74e4c300f083bf89b1544005" +dependencies = [ + "comrak", + "convert_case", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.48", + "tblgen", + "unindent", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" @@ -589,12 +967,31 @@ dependencies = [ "adler", ] +[[package]] +name = "mlir-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e19a5391ed2759fd9060f538330b9b89191e7b13503d7499a4f9580af6699a" +dependencies = [ + "bindgen 0.68.1", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -607,18 +1004,40 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] [[package]] name = "overload" @@ -644,17 +1063,29 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "petgraph" version = "0.6.4" @@ -686,6 +1117,32 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "pkg-config" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" + +[[package]] +name = "plist" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" +dependencies = [ + "base64", + "indexmap", + "line-wrap", + "quick-xml", + "serde", + "time", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "precomputed-hash" version = "0.1.1" @@ -693,62 +1150,72 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] -name = "proc-macro2" -version = "1.0.67" +name = "prettyplease" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +dependencies = [ + "proc-macro2", + "syn 2.0.48", +] + +[[package]] +name = "proc-macro2" +version = "1.0.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] -name = "quote" -version = "1.0.33" +name = "quick-xml" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall 0.2.16", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.9.6" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.9", - "regex-syntax 0.7.5", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -762,15 +1229,21 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] +[[package]] +name = "regex-lite" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -783,6 +1256,12 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -790,16 +1269,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] -name = "rustix" -version = "0.38.15" +name = "rustc-hash" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -808,6 +1293,27 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -816,19 +1322,62 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.19" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" + +[[package]] +name = "serde" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "serde_json" +version = "1.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +dependencies = [ + "itoa", + "ryu", + "serde", +] [[package]] name = "sharded-slab" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + [[package]] name = "siphasher" version = "0.3.11" @@ -836,10 +1385,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] -name = "smallvec" -version = "1.11.1" +name = "slug" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + +[[package]] +name = "smallvec" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "string_cache" @@ -862,15 +1421,60 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.37" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syntect" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" +dependencies = [ + "bincode", + "bitflags 1.3.2", + "fancy-regex", + "flate2", + "fnv", + "once_cell", + "onig", + "plist", + "regex-syntax 0.7.5", + "serde", + "serde_json", + "thiserror", + "walkdir", + "yaml-rust", +] + +[[package]] +name = "tblgen" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d19c09266feb8b16718d1183044d14703a0b4b59e55ce8beb4d6e21dd066b1b" +dependencies = [ + "bindgen 0.66.1", + "cc", + "paste", + "thiserror", +] + [[package]] name = "term" version = "0.7.0" @@ -883,23 +1487,33 @@ dependencies = [ ] [[package]] -name = "thiserror" -version = "1.0.49" +name = "terminal_size" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "thiserror" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -912,6 +1526,35 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +dependencies = [ + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -923,11 +1566,10 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -935,20 +1577,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -966,20 +1608,20 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -993,12 +1635,24 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-width" version = "0.1.11" @@ -1011,6 +1665,18 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "utf8parse" version = "0.2.1" @@ -1023,12 +1689,88 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.48", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" + +[[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" @@ -1045,19 +1787,61 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -1066,51 +1850,144 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -1118,10 +1995,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "yansi-term" -version = "0.1.2" +name = "windows_x86_64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "xdg" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ - "winapi", + "linked-hash-map", ] + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" diff --git a/Cargo.toml b/Cargo.toml index 46157a5ff..256d30d58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,27 +1,19 @@ -[package] -name = "edlang" -version = "0.1.0" -authors = ["Edgar Luque "] -description = "A experimental language using LLVM." -edition = "2021" -readme = "README.md" -keywords = ["llvm", "compiler"] -license = "AGPL-3.0-only" -categories = ["compilers"] +[workspace] +resolver = "2" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +members = [ "bin/edlang", "lib/edlang_ast", "lib/edlang_check", "lib/edlang_codegen_mlir", "lib/edlang_driver","lib/edlang_parser", "lib/edlang_session"] -[dependencies] -clap = { version = "4.3.3", features = ["derive"] } -color-eyre = "0.6.2" -itertools = "0.11" -lalrpop-util = { version = "0.20.0", features = ["lexer"] } -regex = "1.9" -tracing = "0.1.37" -tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } -inkwell = { version = "0.2.0", features = ["llvm16-0"] } -annotate-snippets = { version = "0.9.1", features = ["color"] } -logos = "0.13.0" +[profile.release] +lto = true +codegen-units = 1 -[build-dependencies] -lalrpop = "0.20.0" +# Set the settings for build scripts and proc-macros. +[profile.dev.build-override] +opt-level = 3 + +# On dev optimize dependencies a bit so it's not as slow. +[profile.dev.package."*"] +opt-level = 1 + +[workspace.dependencies] +tracing = "0.1.40" diff --git a/bin/edlang/Cargo.toml b/bin/edlang/Cargo.toml new file mode 100644 index 000000000..81d3731e0 --- /dev/null +++ b/bin/edlang/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "edlang" +version = "0.1.0" +authors = ["Edgar Luque "] +description = "A experimental language using LLVM." +edition = "2021" +readme = "README.md" +keywords = ["llvm", "compiler"] +license = "AGPL-3.0-only" +categories = ["compilers"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +edlang_driver = { version = "0.1.0", path = "../../lib/edlang_driver" } diff --git a/bin/edlang/src/main.rs b/bin/edlang/src/main.rs new file mode 100644 index 000000000..7ea0b107a --- /dev/null +++ b/bin/edlang/src/main.rs @@ -0,0 +1,5 @@ +use std::error::Error; + +fn main() -> Result<(), Box> { + edlang_driver::main() +} diff --git a/lib/edlang_ast/Cargo.toml b/lib/edlang_ast/Cargo.toml new file mode 100644 index 000000000..9c4f18795 --- /dev/null +++ b/lib/edlang_ast/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "edlang_ast" +version = "0.1.0" +authors = ["Edgar Luque "] +description = "edlang AST" +edition = "2021" +keywords = ["llvm", "compiler"] +license = "AGPL-3.0-only" +categories = ["compilers"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/lib/edlang_ast/src/lib.rs b/lib/edlang_ast/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/lib/edlang_ast/src/lib.rs @@ -0,0 +1 @@ + diff --git a/lib/edlang_check/Cargo.toml b/lib/edlang_check/Cargo.toml new file mode 100644 index 000000000..eb841b47c --- /dev/null +++ b/lib/edlang_check/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "edlang_check" +version = "0.1.0" +authors = ["Edgar Luque "] +description = "edlang check" +edition = "2021" +keywords = ["llvm", "compiler"] +license = "AGPL-3.0-only" +categories = ["compilers"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ariadne = { version = "0.4.0", features = ["auto-color"] } +edlang_ast = { version = "0.1.0", path = "../edlang_ast" } +tracing = { workspace = true } diff --git a/lib/edlang_check/src/lib.rs b/lib/edlang_check/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/lib/edlang_check/src/lib.rs @@ -0,0 +1 @@ + diff --git a/lib/edlang_codegen_mlir/Cargo.toml b/lib/edlang_codegen_mlir/Cargo.toml new file mode 100644 index 000000000..0b88d5b66 --- /dev/null +++ b/lib/edlang_codegen_mlir/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "edlang_codegen_mlir" +version = "0.1.0" +authors = ["Edgar Luque "] +description = "edlang MLIR codegen" +edition = "2021" +keywords = ["llvm", "compiler"] +license = "AGPL-3.0-only" +categories = ["compilers"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +edlang_ast = { version = "0.1.0", path = "../edlang_ast" } +edlang_parser = { version = "0.1.0", path = "../edlang_parser" } +edlang_session = { version = "0.1.0", path = "../edlang_session" } +llvm-sys = "170.0.1" +melior = { version = "0.15.0", features = ["ods-dialects"] } +mlir-sys = "0.2.1" diff --git a/lib/edlang_codegen_mlir/src/lib.rs b/lib/edlang_codegen_mlir/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/lib/edlang_codegen_mlir/src/lib.rs @@ -0,0 +1 @@ + diff --git a/lib/edlang_driver/Cargo.toml b/lib/edlang_driver/Cargo.toml new file mode 100644 index 000000000..7f407feda --- /dev/null +++ b/lib/edlang_driver/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "edlang_driver" +version = "0.1.0" +authors = ["Edgar Luque "] +description = "edlang compiler driver library" +edition = "2021" +keywords = ["llvm", "compiler"] +license = "AGPL-3.0-only" +categories = ["compilers"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { version = "4.4.16", features = ["derive"] } +color-eyre = "0.6.2" +edlang_ast = { version = "0.1.0", path = "../edlang_ast" } +edlang_check = { version = "0.1.0", path = "../edlang_check" } +edlang_codegen_mlir = { version = "0.1.0", path = "../edlang_codegen_mlir" } +edlang_parser = { version = "0.1.0", path = "../edlang_parser" } +edlang_session = { version = "0.1.0", path = "../edlang_session" } +tracing = { workspace = true } +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } diff --git a/lib/edlang_driver/src/lib.rs b/lib/edlang_driver/src/lib.rs new file mode 100644 index 000000000..0769462e9 --- /dev/null +++ b/lib/edlang_driver/src/lib.rs @@ -0,0 +1,5 @@ +use std::error::Error; + +pub fn main() -> Result<(), Box> { + Ok(()) +} diff --git a/lib/edlang_parser/Cargo.toml b/lib/edlang_parser/Cargo.toml new file mode 100644 index 000000000..ca06f68bf --- /dev/null +++ b/lib/edlang_parser/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "edlang_parser" +version = "0.1.0" +authors = ["Edgar Luque "] +description = "edlang parser" +edition = "2021" +keywords = ["llvm", "compiler"] +license = "AGPL-3.0-only" +categories = ["compilers"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +edlang_ast = { version = "0.1.0", path = "../edlang_ast" } +lalrpop-util = { version = "0.20.0", features = ["lexer"] } +logos = "0.13.0" +tracing = { workspace = true } + +[build-dependencies] +lalrpop = "0.20.0" diff --git a/lib/edlang_parser/src/lib.rs b/lib/edlang_parser/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/lib/edlang_parser/src/lib.rs @@ -0,0 +1 @@ + diff --git a/lib/edlang_session/Cargo.toml b/lib/edlang_session/Cargo.toml new file mode 100644 index 000000000..d5d43790d --- /dev/null +++ b/lib/edlang_session/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "edlang_session" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/lib/edlang_session/src/lib.rs b/lib/edlang_session/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/lib/edlang_session/src/lib.rs @@ -0,0 +1 @@ + diff --git a/src/ast/mod.rs b/src/ast/mod.rs deleted file mode 100644 index 37313c7bd..000000000 --- a/src/ast/mod.rs +++ /dev/null @@ -1,178 +0,0 @@ -use std::collections::HashMap; - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct Spanned { - pub span: (usize, usize), - pub value: T, -} - -impl Spanned { - pub fn new(value: T, span: (usize, usize)) -> Self { - Self { value, span } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum OpCode { - Add, - Sub, - Mul, - Div, - Rem, - And, - Or, - Eq, - Ne, -} - -impl OpCode { - pub fn to_str(&self) -> &'static str { - match self { - OpCode::Add => "addi", - OpCode::Sub => "subi", - OpCode::Mul => "muli", - OpCode::Div => "divi", - OpCode::Rem => "remi", - OpCode::And => "and", - OpCode::Or => "or", - OpCode::Eq => "eq", - OpCode::Ne => "ne", - } - } -} - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum TypeExp { - Integer { - bits: u32, - signed: bool, - }, - Boolean, - Array { - of: Spanned>, - len: Option, - }, - Pointer { - target: Spanned>, - }, - Other { - id: String, - }, -} - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum LiteralValue { - String(String), - Integer { - value: String, - bits: u32, - signed: bool, - }, - Boolean(bool), -} - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum Expression { - Literal(LiteralValue), - Variable { - name: String, - }, - Call { - function: Spanned, - args: Vec>>, - }, - BinaryOp(Spanned>, OpCode, Spanned>), -} - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct Parameter { - pub ident: Spanned, - pub type_exp: Spanned, -} - -impl Parameter { - pub const fn new(ident: Spanned, type_exp: Spanned) -> Self { - Self { ident, type_exp } - } -} - -#[derive(Debug, Clone, PartialEq)] -pub struct Function { - pub name: Spanned, - pub params: Vec, - pub body: Vec>, - pub scope_type_info: HashMap>, - pub return_type: Option>, -} - -impl Function { - pub fn new( - name: Spanned, - params: Vec, - body: Vec>, - return_type: Option>, - ) -> Self { - Self { - name, - params, - body, - return_type, - scope_type_info: HashMap::new(), - } - } -} - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct StructField { - pub ident: Spanned, - pub field_type: Spanned, -} - -impl StructField { - pub const fn new(ident: Spanned, type_name: Spanned) -> Self { - Self { - ident, - field_type: type_name, - } - } -} - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct Struct { - pub name: Spanned, - pub fields: Vec, -} - -#[derive(Debug, Clone, PartialEq)] -pub enum Statement { - Let { - name: Spanned, - value: Spanned>, - value_type: Option>, - }, - Mutate { - name: Spanned, - value: Spanned>, - }, - If { - condition: Spanned>, - body: Vec>, - scope_type_info: HashMap>, - else_body: Option>>, - else_body_scope_type_info: HashMap>, - }, - Return(Option>>), - Function(Function), - Struct(Struct), -} - -#[derive(Debug, Clone)] -pub struct Program { - pub statements: Vec>, -} - -impl Program { - pub fn new(statements: Vec>) -> Self { - Self { statements } - } -} diff --git a/src/check.rs b/src/check.rs deleted file mode 100644 index 9ce5bf051..000000000 --- a/src/check.rs +++ /dev/null @@ -1,218 +0,0 @@ -use crate::{ - ast::{self, Statement}, - codegen::ProgramData, - lexer::LexicalError, - tokens::Token, - type_analysis::TypeError, -}; -use annotate_snippets::{ - display_list::{DisplayList, FormatOptions}, - snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation}, -}; -use lalrpop_util::ParseError; - -#[derive(Debug)] -pub enum Check<'a> { - Warning(DisplayList<'a>), - Error(DisplayList<'a>), -} - -/// Checks this is a valid edlang program. -pub fn check<'a>(data: &'a ProgramData, ast: &ast::Program) -> Vec> { - let mut errors = vec![]; - - for statement in &ast.statements { - match &statement.value { - Statement::Let { name, .. } => { - // can't have a top level assignment yet. - let snippet = Snippet { - title: Some(Annotation { - id: None, - label: Some("unexpected let at top level"), - annotation_type: AnnotationType::Error, - }), - footer: vec![], - slices: vec![Slice { - source: &data.source, - line_start: 1, - fold: true, - origin: None, - annotations: vec![SourceAnnotation { - label: "unexpected statement", - annotation_type: AnnotationType::Error, - range: name.span, - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - - let dl = DisplayList::from(snippet); - errors.push(Check::Error(dl)); - } - Statement::Mutate { name, .. } => { - // can't have a top level assignment yet. - let snippet = Snippet { - title: Some(Annotation { - id: None, - label: Some("unexpected assignment at top level"), - annotation_type: AnnotationType::Error, - }), - footer: vec![], - slices: vec![Slice { - source: &data.source, - line_start: 1, - fold: true, - origin: None, - annotations: vec![SourceAnnotation { - label: "unexpected statement", - annotation_type: AnnotationType::Error, - range: name.span, - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - - let dl = DisplayList::from(snippet); - errors.push(Check::Error(dl)); - } - _ => {} - } - } - errors -} - -pub fn print_error(source: &str, err: ParseError) { - match err { - ParseError::InvalidToken { location } => { - let snippet = Snippet { - title: None, - footer: vec![], - slices: vec![Slice { - source, - line_start: 1, - fold: true, - origin: None, - annotations: vec![SourceAnnotation { - label: "invalid token", - annotation_type: AnnotationType::Error, - range: (location, location), - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - let dl = DisplayList::from(snippet); - println!("{dl}"); - } - ParseError::UnrecognizedEof { - location: _, - expected: _, - } => todo!(), - ParseError::UnrecognizedToken { - token: _, - expected: _, - } => todo!(), - ParseError::ExtraToken { token: _ } => todo!(), - ParseError::User { error } => match error { - LexicalError::InvalidToken(err, range) => { - let title = format!("invalid token (lexical error): {:?}", err); - let snippet = Snippet { - title: Some(Annotation { - id: None, - label: Some(&title), - annotation_type: AnnotationType::Error, - }), - footer: vec![], - slices: vec![Slice { - source, - line_start: 1, - fold: false, - origin: None, - annotations: vec![SourceAnnotation { - label: "invalid token (lexical error)", - annotation_type: AnnotationType::Error, - range: (range.start, range.end), - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - let dl = DisplayList::from(snippet); - println!("{dl}"); - } - }, - }; -} - -pub fn print_type_error(source: &str, err: TypeError) { - match err { - TypeError::Mismatch { - found: _, - expected: _, - span, - } => { - let snippet = Snippet { - title: Some(Annotation { - id: None, - label: Some("type mismatch"), - annotation_type: AnnotationType::Error, - }), - footer: vec![], - slices: vec![Slice { - source, - line_start: 1, - fold: false, - origin: None, - annotations: vec![SourceAnnotation { - label: "type mismatch", - annotation_type: AnnotationType::Error, - range: span, - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - let dl = DisplayList::from(snippet); - println!("{dl}"); - } - TypeError::UndeclaredVariable { name: _, span } => { - let snippet = Snippet { - title: Some(Annotation { - id: None, - label: Some("undeclared variable"), - annotation_type: AnnotationType::Error, - }), - footer: vec![], - slices: vec![Slice { - source, - line_start: 1, - fold: false, - origin: None, - annotations: vec![SourceAnnotation { - label: "undeclared variable", - annotation_type: AnnotationType::Error, - range: span, - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - let dl = DisplayList::from(snippet); - println!("{dl}"); - } - }; -} diff --git a/src/codegen.rs b/src/codegen.rs deleted file mode 100644 index 02d995cae..000000000 --- a/src/codegen.rs +++ /dev/null @@ -1,585 +0,0 @@ -use std::{ - collections::HashMap, - path::{Path, PathBuf}, - todo, -}; - -use color_eyre::Result; -use inkwell::{ - builder::Builder, - context::Context, - module::Module, - targets::{CodeModel, InitializationConfig, RelocMode, Target, TargetMachine}, - types::{BasicMetadataTypeEnum, BasicType, BasicTypeEnum, StructType}, - values::{BasicMetadataValueEnum, BasicValue, BasicValueEnum, FunctionValue}, - IntPredicate, OptimizationLevel, -}; -use itertools::{Either, Itertools}; -use tracing::info; - -use crate::ast::{self, Expression, Function, LiteralValue, OpCode, Spanned, Statement, TypeExp}; - -#[derive(Debug, Clone)] -pub struct ProgramData { - pub filename: PathBuf, - pub source: String, -} - -impl ProgramData { - pub fn new(filename: &Path, source: &str) -> Self { - Self { - filename: filename.to_path_buf(), - source: source.to_string(), - } - } -} - -pub struct CodeGen<'ctx> { - context: &'ctx Context, - pub module: Module<'ctx>, - builder: Builder<'ctx>, - //types: TypeStorage<'ctx>, - struct_types: StructTypeStorage<'ctx>, - // function to return type - functions: HashMap, - _program: ProgramData, - ast: ast::Program, - target_machine: TargetMachine, -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct Variable<'ctx> { - pub value: BasicValueEnum<'ctx>, - pub type_counter: usize, - pub phi_counter: usize, -} - -pub type Variables<'ctx> = HashMap>; - -/// Holds the struct type and maps fields to types and the location within the struct. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct StructTypeInfo<'ctx> { - ty: StructType<'ctx>, - fields: HashMap, -} - -type StructTypeStorage<'ctx> = HashMap>; - -impl<'ctx> CodeGen<'ctx> { - pub fn new( - context: &'ctx Context, - module_name: &str, - _program: ProgramData, - ast: ast::Program, - ) -> Result { - let module = context.create_module(module_name); - Target::initialize_native(&InitializationConfig::default()) - .expect("Failed to initialize native target"); - let triple = TargetMachine::get_default_triple(); - - // https://thedan64.github.io/inkwell/inkwell/targets/struct.TargetMachine.html#method.write_to_memory_buffer - let opt = OptimizationLevel::Default; - let reloc = RelocMode::Default; - let model = CodeModel::Default; - let target = Target::from_name("x86-64").unwrap(); - let target_machine = target - .create_target_machine( - &triple, - "x86-64", - TargetMachine::get_host_cpu_features().to_str()?, - opt, - reloc, - model, - ) - .unwrap(); - - module.set_data_layout(&target_machine.get_target_data().get_data_layout()); - module.set_triple(&triple); - - let codegen = CodeGen { - context, - module, - builder: context.create_builder(), - _program, - ast, - struct_types: HashMap::new(), - functions: HashMap::new(), - target_machine, - }; - - Ok(codegen) - } - - pub fn compile_ast(&mut self) -> Result<()> { - let mut functions = HashMap::new(); - // let mut types: TypeStorage<'ctx> = HashMap::new(); - let mut struct_types: StructTypeStorage<'ctx> = HashMap::new(); - - // todo fix the grammar so top level statements are only functions and static vars. - - let target_data = self.target_machine.get_target_data(); - - // create struct types - for statement in &self.ast.statements { - if let Statement::Struct(s) = &statement.value { - let mut fields = HashMap::new(); - let mut field_types: Vec<(BasicTypeEnum<'_>, Option)> = vec![]; - - for (i, field) in s.fields.iter().enumerate() { - // todo: this doesnt handle out of order structs well - let ty = self.get_llvm_type(&field.field_type.value)?; - field_types.push((ty, Some(i))); - - fields.insert( - field.ident.value.clone(), - (i, field.field_type.value.clone()), - ); - } - - field_types.sort_by(|a, b| { - target_data - .get_bit_size(&b.0) - .cmp(&target_data.get_bit_size(&a.0)) - }); - - let total_byte_size: u32 = field_types - .iter() - .map(|x| (target_data.get_bit_size(&x.0) + 7) / 8) - .sum::() - .try_into() - .unwrap(); - - if !total_byte_size.is_power_of_two() { - let next = total_byte_size.next_power_of_two(); - let diff = next - total_byte_size; - let padding = self.context.i8_type().array_type(diff); - field_types.push((padding.as_basic_type_enum(), None)) - } - - for (current_i, ty) in field_types.iter().enumerate() { - for field in fields.values_mut() { - if let Some(i) = ty.1 { - if i == field.0 { - field.0 = current_i; - break; - } - } - } - } - - let ty = self - .context - .struct_type(&field_types.into_iter().map(|x| x.0).collect_vec(), false); - - let struct_type = StructTypeInfo { fields, ty }; - struct_types.insert(s.name.value.clone(), struct_type); - } - } - - self.struct_types = struct_types; - - // create the llvm functions first. - for statement in &self.ast.statements { - if let Statement::Function(function) = &statement.value { - functions.insert(function.name.value.clone(), function.clone()); - self.compile_function_signature(function)?; - } - } - self.functions = functions; - - info!("functions:\n{:#?}", self.functions); - - // implement them. - for function in self.functions.values() { - self.compile_function(function)?; - } - - Ok(()) - } - - pub fn generated_code(&self) -> String { - if let Err(err) = self.module.verify() { - eprintln!("error:\n{}", err); - } - // compile: - //let buffer = self.target_machine.write_to_memory_buffer(&self.module, FileType::Assembly).unwrap(); - //let mut x = buffer.as_slice(); - //let mut what = String::new(); - //x.read_to_string(&mut what); - //println!("{}", what); - self.module.print_to_string().to_str().unwrap().to_string() - } - - fn get_llvm_type(&self, id: &TypeExp) -> Result> { - Ok(match id { - TypeExp::Integer { bits, signed: _ } => self - .context - .custom_width_int_type(*bits) - .as_basic_type_enum(), - TypeExp::Boolean => self.context.bool_type().as_basic_type_enum(), - TypeExp::Array { of, len } => { - let ty = self.get_llvm_type(&of.value)?; - ty.array_type(len.unwrap()).as_basic_type_enum() - } - TypeExp::Pointer { target } => { - let ty = self.get_llvm_type(&target.value)?; - ty.ptr_type(Default::default()).as_basic_type_enum() - } - TypeExp::Other { id } => self - .struct_types - .get(id) - .expect("struct type not found") - .ty - .as_basic_type_enum(), - }) - } - - /// creates the llvm function without the body, so other function bodies can call it. - fn compile_function_signature(&self, function: &Function) -> Result<()> { - let args_types: Vec> = function - .params - .iter() - .map(|param| ¶m.type_exp) - .map(|t| self.get_llvm_type(&t.value)) - .try_collect()?; - - let args_types: Vec> = - args_types.into_iter().map(|t| t.into()).collect_vec(); - - let fn_type = match &function.return_type { - Some(id) => { - let return_type = self.get_llvm_type(&id.value)?; - return_type.fn_type(&args_types, false) - } - None => self.context.void_type().fn_type(&args_types, false), - }; - - self.module - .add_function(&function.name.value, fn_type, None); - - Ok(()) - } - - fn compile_function(&self, function: &Function) -> Result<()> { - let func = self.module.get_function(&function.name.value).unwrap(); - let entry_block = self.context.append_basic_block(func, "entry"); - - self.builder.position_at_end(entry_block); - - let mut variables: Variables = HashMap::new(); - - for (i, param) in function.params.iter().enumerate() { - let id = ¶m.ident; - let param_value = func - .get_nth_param(i.try_into().unwrap()) - .expect("parameter"); - variables.insert( - id.value.clone(), - Variable { - value: param_value, - phi_counter: 0, - type_counter: 0, - }, - ); - } - - let mut has_return = false; - - for statement in &function.body { - if let Statement::Return(_) = statement.value { - has_return = true - } - self.compile_statement(func, statement, &mut variables, &function.scope_type_info)?; - } - - if !has_return { - self.builder.build_return(None); - } - - Ok(()) - } - - fn compile_statement( - &self, - function_value: FunctionValue, - statement: &Spanned, - // value, assignments - variables: &mut Variables<'ctx>, - scope_info: &HashMap>, - ) -> Result<()> { - match &statement.value { - // Variable assignment - Statement::Let { - name, - value, - value_type: _, - .. - } => { - let value = self - .compile_expression(value, variables, scope_info)? - .expect("should have result"); - - variables.insert( - name.value.clone(), - Variable { - value, - phi_counter: 0, - type_counter: 0, - }, - ); - } - Statement::Mutate { name, value, .. } => { - let value = self - .compile_expression(value, variables, scope_info)? - .expect("should have result"); - - let var = variables - .get_mut(&name.value) - .expect("variable should exist"); - var.phi_counter += 1; - var.value = value; - } - Statement::Return(ret) => { - if let Some(ret) = ret { - let value = self - .compile_expression(ret, variables, scope_info)? - .expect("should have result"); - self.builder.build_return(Some(&value)); - } else { - self.builder.build_return(None); - } - } - Statement::If { - condition, - body, - else_body, - scope_type_info, - else_body_scope_type_info, - } => { - let condition = self - .compile_expression(condition, variables, scope_info)? - .expect("should produce a value"); - - let mut if_block = self.context.append_basic_block(function_value, "if"); - let mut else_block = self.context.append_basic_block(function_value, "else"); - let merge_block = self.context.append_basic_block(function_value, "merge"); - - self.builder.build_conditional_branch( - condition.into_int_value(), - if_block, - if else_body.is_some() { - else_block - } else { - merge_block - }, - ); - - let mut variables_if = variables.clone(); - self.builder.position_at_end(if_block); - for s in body { - self.compile_statement(function_value, s, &mut variables_if, scope_type_info)?; - } - self.builder.build_unconditional_branch(merge_block); - if_block = self.builder.get_insert_block().unwrap(); // update for phi - - let mut variables_else = variables.clone(); - if let Some(else_body) = else_body { - self.builder.position_at_end(else_block); - - for s in else_body { - self.compile_statement( - function_value, - s, - &mut variables_else, - else_body_scope_type_info, - )?; - } - self.builder.build_unconditional_branch(merge_block); - else_block = self.builder.get_insert_block().unwrap(); // update for phi - } - - self.builder.position_at_end(merge_block); - - let mut processed_vars = HashMap::new(); - for (name, new_var) in variables_if { - if variables.contains_key(&name) { - let old_var = variables.get(&name).unwrap(); - if new_var.phi_counter > old_var.phi_counter { - let phi = self - .builder - .build_phi(old_var.value.get_type(), &format!("{name}_phi")); - phi.add_incoming(&[(&new_var.value, if_block)]); - processed_vars.insert(name, phi); - } - } - } - - if else_body.is_some() { - for (name, new_var) in variables_else { - if variables.contains_key(&name) { - let old_var = variables.get(&name).unwrap(); - if new_var.phi_counter > old_var.phi_counter { - if let Some(phi) = processed_vars.get(&name) { - phi.add_incoming(&[(&new_var.value, else_block)]); - } else { - let phi = self.builder.build_phi( - old_var.value.get_type(), - &format!("{name}_phi"), - ); - phi.add_incoming(&[(&old_var.value, else_block)]); - processed_vars.insert(name, phi); - } - } - } - } - } - - for (name, phi) in processed_vars { - /* - variables.insert( - name, - Variable { - value: phi.as_basic_value(), - phi_counter: 0, - }, - ); - */ - let mut var = variables.get_mut(&name).unwrap(); - var.value = phi.as_basic_value(); - } - } - Statement::Function(_) => unreachable!(), - Statement::Struct(_) => unreachable!(), - }; - - Ok(()) - } - - pub fn compile_expression( - &self, - expr: &Spanned>, - variables: &mut Variables<'ctx>, - scope_info: &HashMap>, - ) -> Result>> { - Ok(match &*expr.value { - Expression::Variable { name } => Some(self.compile_variable(name, variables)?), - Expression::Literal(term) => Some(self.compile_literal(term)?), - Expression::Call { function, args } => { - self.compile_call(function, args, variables, scope_info)? - } - Expression::BinaryOp(lhs, op, rhs) => { - Some(self.compile_binary_op(lhs, op, rhs, variables, scope_info)?) - } - }) - } - - pub fn compile_call( - &self, - func_name: &Spanned, - args: &[Spanned>], - variables: &mut Variables<'ctx>, - scope_info: &HashMap>, - ) -> Result>> { - info!("compiling fn call: func_name={}", func_name.value); - let function = self - .module - .get_function(&func_name.value) - .expect("should exist"); - - let mut value_args: Vec = Vec::with_capacity(args.len()); - - for arg in args.iter() { - let res = self - .compile_expression(arg, variables, scope_info)? - .expect("should have result"); - value_args.push(res.into()); - } - - let result = self - .builder - .build_call(function, &value_args, &format!("{}_call", func_name.value)) - .try_as_basic_value(); - - Ok(match result { - Either::Left(val) => Some(val), - Either::Right(_) => None, - }) - } - - pub fn compile_binary_op( - &self, - lhs: &Spanned>, - op: &OpCode, - rhs: &Spanned>, - variables: &mut Variables<'ctx>, - scope_info: &HashMap>, - ) -> Result> { - let lhs = self - .compile_expression(lhs, variables, scope_info)? - .expect("should have result"); - let rhs = self - .compile_expression(rhs, variables, scope_info)? - .expect("should have result"); - - assert_eq!(lhs.get_type(), rhs.get_type(), "type mismatch"); - - let lhs = lhs.into_int_value(); - let rhs = rhs.into_int_value(); - - let result = match op { - OpCode::Add => self.builder.build_int_add(lhs, rhs, "add"), - OpCode::Sub => self.builder.build_int_sub(lhs, rhs, "sub"), - OpCode::Mul => self.builder.build_int_mul(lhs, rhs, "mul"), - OpCode::Div => self.builder.build_int_signed_div(lhs, rhs, "div"), - OpCode::Rem => self.builder.build_int_signed_rem(lhs, rhs, "rem"), - OpCode::And => self.builder.build_and(lhs, rhs, "and"), - OpCode::Or => self.builder.build_or(lhs, rhs, "or"), - OpCode::Eq => self - .builder - .build_int_compare(IntPredicate::EQ, lhs, rhs, "eq"), - OpCode::Ne => self - .builder - .build_int_compare(IntPredicate::NE, lhs, rhs, "eq"), - }; - - Ok(result.as_basic_value_enum()) - } - - pub fn compile_literal(&self, term: &LiteralValue) -> Result> { - let value = match term { - LiteralValue::String(s) => { - // todo: search string folding and interning. - // self.builder.build_global_string_ptr(s, "literal_str"); - todo!() - } - LiteralValue::Boolean(v) => self - .context - .bool_type() - .const_int((*v).into(), false) - .as_basic_value_enum(), - LiteralValue::Integer { - value, - bits, - signed: _, - } => { - let bits = *bits; - - self.context - .custom_width_int_type(bits) - .const_int(value.parse().unwrap(), false) - .as_basic_value_enum() - } - }; - - Ok(value) - } - - pub fn compile_variable( - &self, - variable: &str, - variables: &mut Variables<'ctx>, - ) -> Result> { - let var = variables.get(variable).expect("value").clone(); - Ok(var.value) - } -} diff --git a/src/grammar.lalrpop b/src/grammar.lalrpop deleted file mode 100644 index b4ff1c932..000000000 --- a/src/grammar.lalrpop +++ /dev/null @@ -1,265 +0,0 @@ -use crate::{ - ast::{self, Spanned}, - tokens::Token, - lexer::LexicalError, -}; - -grammar; - -extern { - type Location = usize; - type Error = LexicalError; - - enum Token { - "let" => Token::KeywordLet, - "print" => Token::KeywordPrint, - "struct" => Token::KeywordStruct, - "if" => Token::KeywordIf, - "else" => Token::KeywordElse, - "identifier" => Token::Identifier(), - "int literal" => Token::Integer(), - "string literal" => Token::String(), - "bool literal" => Token::Boolean(), - "return" => Token::KeywordReturn, - "fn" => Token::KeywordFn, - "ptr" => Token::KeywordPtr, - "_" => Token::KeywordUnderscore, - - "(" => Token::LeftParen, - ")" => Token::RightParen, - "{" => Token::LeftBracket, - "}" => Token::RightBracket, - "[" => Token::LeftSquareBracket, - "]" => Token::RightSquareBracket, - "<" => Token::LessThanSign, - ">" => Token::MoreThanSign, - "=" => Token::Assign, - ";" => Token::Semicolon, - ":" => Token::Colon, - "->" => Token::Arrow, - "," => Token::Coma, - "+" => Token::OperatorAdd, - "-" => Token::OperatorSub, - "*" => Token::OperatorMul, - "/" => Token::OperatorDiv, - "%" => Token::OperatorRem, - "&&" => Token::OperatorAnd, - "||" => Token::OperatorOr, - "==" => Token::OperatorEq, - "!=" => Token::OperatorNe, - - "bool" => Token::KeywordBool, - - "i8" => Token::Inti8, - "i16" => Token::Inti16, - "i32" => Token::Inti32, - "i64" => Token::Inti64, - "u8" => Token::Intu8, - "u16" => Token::Intu16, - "u32" => Token::Intu32, - "u64" => Token::Intu64, - } -} - -Comma: Vec = { - ",")*> => match e { - None => v, - Some(e) => { - v.push(e); - v - } - } -}; - -pub Program: ast::Program = { - Statements => ast::Program::new(<>) -} - -Statements: Vec> = { - => vec![<>], - => { - s.push(n); - s - }, -}; - -Statement: Spanned = { - BasicStatement, - => Spanned::new(ast::Statement::Function(f), (lo, hi)), - => Spanned::new(ast::Statement::Struct(s), (lo, hi)), -}; - -TypeInfo: Spanned = { - ":" => i -}; - -Identifier: Spanned = { - => Spanned::new(i, (lo, hi)) -} - -// statements not including function definitions -BasicStatement: Spanned = { - "let" "=" ";" => - Spanned::new(ast::Statement::Let { name: i, value: e, value_type: t }, (lo, hi)), - "=" ";" => - Spanned::new(ast::Statement::Mutate { name: i, value: e }, (lo, hi)), - "if" "{" "}" => - Spanned::new(ast::Statement::If { - condition: cond, - body: s, - else_body: e, - scope_type_info: Default::default(), - else_body_scope_type_info: Default::default(), - }, (lo, hi)), - "return" ";" => Spanned::new(ast::Statement::Return(e), (lo, hi)), -}; - -ElseExpr: Vec> = { - "else" "{" "}" => s -} - -Level0_Op: ast::OpCode = { - "&&" => ast::OpCode::And, - "||" => ast::OpCode::Or, -} - -Level1_Op: ast::OpCode = { - "==" => ast::OpCode::Eq, - "!=" => ast::OpCode::Ne, -} - -Level2_Op: ast::OpCode = { - "+" => ast::OpCode::Add, - "-" => ast::OpCode::Sub, -}; - -Level3_Op: ast::OpCode = { - "*" => ast::OpCode::Mul, - "/" => ast::OpCode::Div, - "%" => ast::OpCode::Rem, -} - -Tier: Spanned> = { - > => Spanned::new(Box::new(ast::Expression::BinaryOp(t, o, n)), (lo, hi)), - NextTier -}; - -Expr = Tier; -Expr2 = Tier; -Expr3 = Tier; -Expr4 = Tier; - -// Terms: variables, literals, calls -Term: Spanned> = { - => Spanned::new(Box::new(ast::Expression::Variable { - name: i - }), (lo, hi)), - => Spanned::new(Box::new(ast::Expression::Literal(n)), (lo, hi)), - => Spanned::new(Box::new(ast::Expression::Literal(n)), (lo, hi)), - => Spanned::new(Box::new(ast::Expression::Literal(n)), (lo, hi)), - "(" > ")" => Spanned::new(Box::new(ast::Expression::Call { function: i, args: values }), (lo, hi)), - "(" ")" -}; - -Number: ast::LiteralValue = { - "_"? "i8" => ast::LiteralValue::Integer { - value: n, - bits: 8, - signed: true, - }, - "_"? "i16" => ast::LiteralValue::Integer { - value: n, - bits: 16, - signed: true, - }, - "_"? "i32" => ast::LiteralValue::Integer { - value: n, - bits: 32, - signed: true, - }, - "_"? "i64" => ast::LiteralValue::Integer { - value: n, - bits: 64, - signed: true, - }, - "_"? "u8" => ast::LiteralValue::Integer { - value: n, - bits: 8, - signed: false, - }, - "_"? "u16" => ast::LiteralValue::Integer { - value: n, - bits: 16, - signed: false, - }, - "_"? "u32" => ast::LiteralValue::Integer { - value: n, - bits: 32, - signed: false, - }, - "_"? "u64" => ast::LiteralValue::Integer { - value: n, - bits: 64, - signed: false, - }, - => ast::LiteralValue::Integer { - value: n, - bits: 32, - signed: true, - }, -}; - -StringLit: ast::LiteralValue = => ast::LiteralValue::String(n[1..(n.len()-1)].to_string()); - -BoolLiteral: ast::LiteralValue = => ast::LiteralValue::Boolean(n); - -ArrayLen: u32 = { - ";" => i.parse().unwrap(), -} - -LangType: Spanned = { - "ptr" "<" ">" => Spanned::new(ast::TypeExp::Pointer { target: Spanned::new(Box::new(target.value), target.span) }, (lo, hi)), - "[" "]" => Spanned::new(ast::TypeExp::Array { of: Spanned::new(Box::new(of.value), of.span), len }, (lo, hi)), - "i8" => Spanned::new(ast::TypeExp::Integer { bits: 8, signed: true }, (lo, hi)), - "i16" => Spanned::new(ast::TypeExp::Integer { bits: 16, signed: true }, (lo, hi)), - "i32" => Spanned::new(ast::TypeExp::Integer { bits: 32, signed: true }, (lo, hi)), - "i64" => Spanned::new(ast::TypeExp::Integer { bits: 64, signed: true }, (lo, hi)), - "u8" => Spanned::new(ast::TypeExp::Integer { bits: 8, signed: false }, (lo, hi)), - "u16" => Spanned::new(ast::TypeExp::Integer { bits: 16, signed: false }, (lo, hi)), - "u32" => Spanned::new(ast::TypeExp::Integer { bits: 32, signed: false }, (lo, hi)), - "u64" => Spanned::new(ast::TypeExp::Integer { bits: 64, signed: false }, (lo, hi)), - "bool" => Spanned::new(ast::TypeExp::Boolean, (lo, hi)), - => Spanned::new(ast::TypeExp::Other { id }, (lo, hi)), -}; - -// Function handling -Param: ast::Parameter = { - ":" => ast::Parameter::new(<>) -}; - -Params = Comma; - -FunctionReturn: Spanned = { - "->" => i, -} - -Function: ast::Function = { - "fn" "(" ")" "{" "}" => ast::Function::new(i, a, s, r) -} - -// Structures - -StructField: ast::StructField = { - ":" => ast::StructField::new(<>) -}; - -StructFields = Comma; - -Struct: ast::Struct = { - "struct" "{" "}" => { - ast::Struct { - name: i, - fields - } - } -} diff --git a/src/lexer.rs b/src/lexer.rs deleted file mode 100644 index 8d4eda6f8..000000000 --- a/src/lexer.rs +++ /dev/null @@ -1,47 +0,0 @@ -use std::{fmt::Display, ops::Range}; - -use logos::{Logos, SpannedIter}; - -use crate::tokens::{LexingError, Token}; - -pub type Spanned = Result<(Loc, Tok, Loc), Error>; - -#[derive(Debug, Clone)] -pub enum LexicalError { - InvalidToken(LexingError, Range), -} - -impl Display for LexicalError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - LexicalError::InvalidToken(err, span) => { - write!(f, "lexical error at ({:?}): {:?}", err, span) - } - } - } -} - -pub struct Lexer<'input> { - // instead of an iterator over characters, we have a token iterator - token_stream: SpannedIter<'input, Token>, -} - -impl<'input> Lexer<'input> { - pub fn new(input: &'input str) -> Self { - // the Token::lexer() method is provided by the Logos trait - Self { - token_stream: Token::lexer(input).spanned(), - } - } -} - -impl<'input> Iterator for Lexer<'input> { - type Item = Spanned; - - fn next(&mut self) -> Option { - self.token_stream.next().map(|(token, span)| match token { - Ok(token) => Ok((span.start, token, span.end)), - Err(err) => Err(LexicalError::InvalidToken(err, span)), - }) - } -} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 3ca42dc33..000000000 --- a/src/main.rs +++ /dev/null @@ -1,198 +0,0 @@ -#![allow(clippy::too_many_arguments)] - -use check::print_error; -use clap::{Parser, Subcommand}; -use codegen::ProgramData; -use inkwell::{context::Context, execution_engine::JitFunction, OptimizationLevel}; -use lalrpop_util::lalrpop_mod; -use std::{fs, path::PathBuf, println}; - -use crate::{ - ast::Program, - check::{print_type_error, Check}, - lexer::Lexer, -}; - -pub mod ast; -pub mod check; -pub mod codegen; -pub mod lexer; -pub mod tokens; -pub mod type_analysis; - -lalrpop_mod!(pub grammar); - -#[derive(Parser)] -#[command( - author, - version, - about, - long_about = r#"A experimental language using LLVM."# -)] -struct Args { - #[command(subcommand)] - command: Commands, -} - -#[derive(Subcommand)] -enum Commands { - /// Check if the code is valid. - Check { - /// The input file. - input: PathBuf, - }, - /// Prints the code AST. - Ast { - /// The input file. - input: PathBuf, - }, - /// Compile the edlang source file. - Compile { - /// The input file. - input: PathBuf, - - /// Output optimized llvm ir. - #[arg(long)] - optimize: bool, - - /// The output file. If not specified its output will be stdout. - #[arg(short, long)] - output: Option, - - /// Turn on debug info. - #[arg(short, long)] - debug: bool, - }, - /// Compile and run a program. Main needs to return nothing. - Run { - /// The input file. - input: PathBuf, - }, -} - -fn check_program(program: &ProgramData, ast: &ast::Program) -> bool { - let errors = check::check(program, ast); - - let mut error_count = 0; - let mut warn_count = 0; - for error in errors { - match error { - Check::Warning(x) => { - warn_count += 1; - println!("{}", x) - } - Check::Error(x) => { - error_count += 1; - println!("{}", x) - } - } - } - - println!("Warnings: {warn_count}"); - println!("Errors: {error_count}"); - - error_count == 0 -} - -fn main() -> color_eyre::Result<()> { - color_eyre::install()?; - tracing_subscriber::fmt::init(); - let args = Args::parse(); - - match args.command { - Commands::Check { input } => { - let code = fs::read_to_string(&input)?; - let lexer = Lexer::new(code.as_str()); - let parser = grammar::ProgramParser::new(); - let mut ast = parser.parse(lexer)?; - if let Err(e) = type_analysis::type_check(&mut ast) { - print_type_error(&code, e); - return Ok(()); - } - let program = ProgramData::new(&input, &code); - check_program(&program, &ast); - } - Commands::Ast { input } => { - let code = fs::read_to_string(input)?; - let lexer = Lexer::new(code.as_str()); - let parser = grammar::ProgramParser::new(); - match parser.parse(lexer) { - Ok(mut ast) => { - if let Err(e) = type_analysis::type_check(&mut ast) { - print_type_error(&code, e); - return Ok(()); - } - println!("{ast:#?}"); - } - Err(e) => { - print_error(&code, e); - } - } - } - Commands::Compile { - input, - output, - debug: _, - optimize: _, - } => { - let code = fs::read_to_string(&input)?; - let lexer = Lexer::new(code.as_str()); - let parser = grammar::ProgramParser::new(); - let mut ast: Program = parser.parse(lexer)?; - if let Err(e) = type_analysis::type_check(&mut ast) { - print_type_error(&code, e); - return Ok(()); - } - - let program = ProgramData::new(&input, &code); - - let file_name = input.file_name().unwrap().to_string_lossy(); - - if !check_program(&program, &ast) { - return Ok(()); - } - - // println!("{:#?}", ast); - let context = Context::create(); - let mut codegen = codegen::CodeGen::new(&context, &file_name, program, ast)?; - codegen.compile_ast()?; - let generated_llvm_ir = codegen.generated_code(); - - if let Some(output) = output { - fs::write(output, generated_llvm_ir)?; - } else { - println!("{generated_llvm_ir}"); - } - } - Commands::Run { input } => { - let code = fs::read_to_string(&input)?; - let lexer = Lexer::new(&code[..]); - let parser = grammar::ProgramParser::new(); - let mut ast: Program = parser.parse(lexer)?; - if let Err(e) = type_analysis::type_check(&mut ast) { - print_type_error(&code, e); - return Ok(()); - } - - let program = ProgramData::new(&input, &code); - - let file_name = input.file_name().unwrap().to_string_lossy(); - - let context = Context::create(); - let mut codegen = codegen::CodeGen::new(&context, &file_name, program, ast)?; - codegen.compile_ast()?; - let execution_engine = codegen - .module - .create_jit_execution_engine(OptimizationLevel::Aggressive) - .unwrap(); - - unsafe { - let main: JitFunction ()> = - execution_engine.get_function("main")?; - main.call(); - }; - } - } - - Ok(()) -} diff --git a/src/tokens.rs b/src/tokens.rs deleted file mode 100644 index 3f22260f3..000000000 --- a/src/tokens.rs +++ /dev/null @@ -1,132 +0,0 @@ -use logos::Logos; -use std::{convert::Infallible, fmt}; - -// https://github.com/maciejhirsz/logos/issues/133 - -#[derive(Debug, PartialEq, Clone, Default)] -pub enum LexingError { - NumberParseError, - #[default] - Other, -} - -impl From for LexingError { - fn from(_: std::num::ParseIntError) -> Self { - LexingError::NumberParseError - } -} - -impl From for LexingError { - fn from(_: Infallible) -> Self { - LexingError::Other - } -} - -// todo: https://github.com/maciejhirsz/logos/issues/133#issuecomment-619444615 -#[derive(Logos, Debug, PartialEq, Clone)] -#[logos(error = LexingError, skip r"[ \t\n\f]+", skip r"#.*\n?")] -pub enum Token { - #[token("let")] - KeywordLet, - #[token("print")] - KeywordPrint, - #[token("fn")] - KeywordFn, - #[token("return")] - KeywordReturn, - #[token("struct")] - KeywordStruct, - #[token("ptr")] - KeywordPtr, - #[token("if")] - KeywordIf, - #[token("else")] - KeywordElse, - #[token("_")] - KeywordUnderscore, - - #[regex(r"_?\p{XID_Start}\p{XID_Continue}*", |lex| lex.slice().to_string())] - Identifier(String), - #[regex(r"\d+", |lex| lex.slice().to_string())] - Integer(String), - #[regex(r#""(?:[^"]|\\")*""#, |lex| lex.slice().to_string())] - String(String), - #[regex(r"(true|false)", |lex| lex.slice().parse::().unwrap())] - Boolean(bool), - - #[token("bool")] - KeywordBool, - #[token("i8")] - Inti8, - #[token("i16")] - Inti16, - #[token("i32")] - Inti32, - #[token("i64")] - Inti64, - #[token("u8")] - Intu8, - #[token("u16")] - Intu16, - #[token("u32")] - Intu32, - #[token("u64")] - Intu64, - - #[token("f32")] - Float32, - #[token("f64")] - Float64, - - #[token("(")] - LeftParen, - #[token(")")] - RightParen, - #[token("{")] - LeftBracket, - #[token("}")] - RightBracket, - #[token("[")] - LeftSquareBracket, - #[token("]")] - RightSquareBracket, - #[token("=")] - Assign, - #[token(";")] - Semicolon, - #[token(":")] - Colon, - #[token("->")] - Arrow, - #[token(",")] - Coma, - #[token("<")] - LessThanSign, - #[token(">")] - MoreThanSign, - - #[token("+")] - OperatorAdd, - #[token("-")] - OperatorSub, - #[token("*")] - OperatorMul, - #[token("/")] - OperatorDiv, - #[token("%")] - OperatorRem, - #[token("&&")] - OperatorAnd, - #[token("||")] - OperatorOr, - #[token("==")] - OperatorEq, - #[token("!=")] - OperatorNe, -} - -impl fmt::Display for Token { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{:?}", self) - } -} diff --git a/src/type_analysis.rs b/src/type_analysis.rs deleted file mode 100644 index cf08e398f..000000000 --- a/src/type_analysis.rs +++ /dev/null @@ -1,279 +0,0 @@ -use std::collections::{HashMap, HashSet}; - -use crate::ast::{self, Expression, Function, Spanned, Statement, TypeExp}; - -#[derive(Debug, Clone)] -pub enum TypeError { - Mismatch { - found: TypeExp, - expected: TypeExp, - span: (usize, usize), - }, - UndeclaredVariable { - name: String, - span: (usize, usize), - }, -} - -#[derive(Debug, Clone, Default)] -struct Storage { - structs: HashMap>, - functions: HashMap, -} - -type ScopeMap = HashMap>>; - -// this works, but need to find a way to store the found info + handle literal integer types (or not?) -// maybe use scope ids -pub fn type_check(ast: &mut ast::Program) -> Result<(), TypeError> { - let mut storage = Storage::default(); - - // gather global constructs first - for statement in ast.statements.iter_mut() { - match &mut statement.value { - Statement::Struct(st) => { - let fields = st - .fields - .iter() - .map(|x| (x.ident.value.clone(), x.field_type.value.clone())) - .collect(); - storage.structs.insert(st.name.value.clone(), fields); - } - Statement::Function(function) => { - storage - .functions - .insert(function.name.value.clone(), function.clone()); - } - // todo: find globals here too - _ => {} - } - } - - for statement in ast.statements.iter_mut() { - if let Statement::Function(function) = &mut statement.value { - let mut scope_vars: ScopeMap = HashMap::new(); - - for arg in &function.params { - scope_vars.insert( - arg.ident.value.clone(), - vec![Some(arg.type_exp.value.clone())], - ); - } - - let func_info = function.clone(); - let (new_scope_vars, _) = - type_inference_scope(&mut function.body, &scope_vars, &func_info, &storage)?; - // todo: check all vars have type info? - function.scope_type_info = new_scope_vars - .into_iter() - .map(|(a, b)| (a, b.into_iter().map(Option::unwrap).collect())) - .collect(); - } - } - Ok(()) -} - -/// Finds variable types in the scope, returns newly created variables to handle shadowing -fn type_inference_scope( - statements: &mut [Spanned], - scope_vars: &ScopeMap, - func: &Function, - storage: &Storage, -) -> Result<(ScopeMap, HashSet), TypeError> { - let mut scope_vars = scope_vars.clone(); - let mut new_vars: HashSet = HashSet::new(); - - for statement in statements { - match &mut statement.value { - Statement::Let { - name, - value, - value_type, - } => { - new_vars.insert(name.value.clone()); - - let exp_type = type_inference_expression(value, &mut scope_vars, storage, None)?; - - if !scope_vars.contains_key(&name.value) { - scope_vars.insert(name.value.clone(), vec![]); - } - - let var = scope_vars.get_mut(&name.value).unwrap(); - - if value_type.is_none() { - var.push(exp_type); - } else { - if exp_type.is_some() && exp_type != value_type.clone().map(|x| x.value) { - Err(TypeError::Mismatch { - found: exp_type.clone().unwrap(), - expected: value_type.clone().map(|x| x.value).unwrap(), - span: statement.span, - })?; - } - var.push(value_type.clone().map(|x| x.value)); - } - } - Statement::Mutate { name, value } => { - if !scope_vars.contains_key(&name.value) { - Err(TypeError::UndeclaredVariable { - name: name.value.clone(), - span: name.span, - })?; - } - - let exp_type = type_inference_expression(value, &mut scope_vars, storage, None)?; - let var = scope_vars.get_mut(&name.value).unwrap().last_mut().unwrap(); - - if var.is_none() { - *var = exp_type; - } else if exp_type.is_some() && &exp_type != var { - Err(TypeError::Mismatch { - found: exp_type.clone().unwrap(), - expected: var.clone().unwrap(), - span: statement.span, - })?; - } - } - Statement::If { - condition, - body, - else_body, - scope_type_info, - else_body_scope_type_info, - } => { - type_inference_expression( - condition, - &mut scope_vars, - storage, - Some(TypeExp::Boolean), - )?; - - let (new_scope_vars, new_vars) = - type_inference_scope(body, &scope_vars, func, storage)?; - - for (k, v) in new_scope_vars.iter() { - // not a new var within the scope (shadowing), so type info is valid - if scope_vars.contains_key(k) && !new_vars.contains(k) { - scope_vars.insert(k.clone(), v.clone()); - } - } - - *scope_type_info = new_scope_vars - .into_iter() - .map(|(a, b)| (a, b.into_iter().map(Option::unwrap).collect())) - .collect(); - - if let Some(body) = else_body { - let (new_scope_vars, new_vars) = - type_inference_scope(body, &scope_vars, func, storage)?; - - for (k, v) in new_scope_vars.iter() { - // not a new var within the scope (shadowing), so type info is valid - if scope_vars.contains_key(k) && !new_vars.contains(k) { - scope_vars.insert(k.clone(), v.clone()); - } - } - - *else_body_scope_type_info = new_scope_vars - .into_iter() - .map(|(a, b)| (a, b.into_iter().map(Option::unwrap).collect())) - .collect(); - } - } - Statement::Return(exp) => { - if let Some(exp) = exp { - type_inference_expression( - exp, - &mut scope_vars, - storage, - func.return_type.clone().map(|x| x.value), - )?; - } - } - Statement::Function(_) => unreachable!(), - Statement::Struct(_) => unreachable!(), - } - } - - Ok((scope_vars, new_vars)) -} - -fn type_inference_expression( - exp: &Spanned>, - scope_vars: &mut ScopeMap, - storage: &Storage, - expected_type: Option, -) -> Result, TypeError> { - Ok(match &*exp.value { - Expression::Literal(lit) => { - match lit { - ast::LiteralValue::String(_) => None, // todo - ast::LiteralValue::Integer { - value: _, - bits, - signed, - } => Some(TypeExp::Integer { - bits: *bits, - signed: *signed, - }), - ast::LiteralValue::Boolean(_) => Some(TypeExp::Boolean), - } - } - Expression::Variable { name } => { - let var = scope_vars - .get_mut(name) - .expect("to exist") - .last_mut() - .unwrap(); - - if expected_type.is_some() { - if var.is_none() { - *var = expected_type.clone(); - expected_type - } else if expected_type.is_some() { - if *var != expected_type { - Err(TypeError::Mismatch { - found: expected_type.clone().unwrap(), - expected: var.clone().unwrap(), - span: exp.span, - })?; - } - expected_type - } else { - var.clone() - } - } else { - var.clone() - } - } - Expression::Call { function, args } => { - let func = storage.functions.get(&function.value).cloned().unwrap(); - - for (i, arg) in args.iter().enumerate() { - let arg_type = func.params[i].type_exp.clone(); - // result is ignored, but need these to infer call arg types - type_inference_expression(arg, scope_vars, storage, Some(arg_type.value))?; - } - - func.return_type.map(|x| x.value) - } - Expression::BinaryOp(lhs, op, rhs) => match op { - ast::OpCode::Eq | ast::OpCode::Ne => Some(TypeExp::Boolean), - _ => { - let lhs_type = - type_inference_expression(lhs, scope_vars, storage, expected_type.clone())?; - let rhs_type = type_inference_expression(rhs, scope_vars, storage, expected_type)?; - - if lhs_type.is_some() && rhs_type.is_some() && lhs_type != rhs_type { - Err(TypeError::Mismatch { - found: rhs_type.clone().unwrap(), - expected: lhs_type.clone().unwrap(), - span: (0, 0), // todo - })?; - } - - lhs_type.or(rhs_type) - } - }, - }) -}