From 0f2df8be6083244c6bc65462fde167398ab2c08d Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:12:52 +0000 Subject: [PATCH 01/12] Restructured code --- CONTRIBUTING.md | 56 -------------------------------- LICENSE | 4 +-- Makefile | 13 -------- build.rs | 42 ------------------------ {input => tests/input}/print.bsc | 0 5 files changed, 2 insertions(+), 113 deletions(-) delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 build.rs rename {input => tests/input}/print.bsc (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 90f3804..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,56 +0,0 @@ -# Contributing to bcomp - -Thank you for considering contributing to bcomp! Please follow these guidelines to help us maintain a high-quality project. - -## How to Contribute - -1. **Create a new branch** from `main` for your changes. - - Development branches must be named `dev/{branch-name}`. - - Bug fix branches must be named `bug/{branch-name}`. -2. **All changes must be submitted through Pull Requests (PRs)**. Direct pushes to `main` are not allowed. - - PRs need at least one reviewer before they can be merged to main -3. **Describe your changes** clearly in your pull request. -4. **Write clear, concise commit messages**. -5. **Test your code** before submitting. -6. **Follow the code style** used in the project. - -## Developing - -If working in some part of the proejct, and you complete something that has been unimplemented, please remove the compiler directive #[warn(dead_code)] associated with the code you just created. - -Additionally, please be sure to add unit tests to all new parts of the code you have developed! If these are not added the PR will not be approved. If you are reviewing code please be sure to not approve code without sufficient unit test coverage. - -## Running LLVM IR - -To work with LLVM IR, you need to have LLVM installed: - -- On Ubuntu/Debian: - `sudo apt-get install llvm` -- On macOS (with Homebrew): - `brew install llvm` -- For other platforms, see the [LLVM download page](https://llvm.org/). - -Ideally we are using llvm 19, so we can only guarantee operation with this version. - -### How to Run LLVM IR - -1. **Save your LLVM IR code** to a file, for example: `example.ll`. -2. **Use the `lli` tool** to execute the IR: - ``` - lli example.ll - ``` - This will interpret and run the LLVM IR file directly. -3. **Alternatively, compile IR to native code** using `llc` and `clang`: - ``` - llc example.ll -o example.s # Generate assembly - clang example.s -o example_binary # Compile to executable - ./example_binary # Run the executable - ``` - -For more details, refer to the [LLVM documentation](https://llvm.org/docs/CommandGuide/).` - -## Reporting Issues - -- Use the issue tracker to report bugs or request features. -- Provide as much detail as possible. - diff --git a/LICENSE b/LICENSE index 5150845..26c5f82 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright © [2021][zaszi] +Copyright © [2026][ngraf] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/Makefile b/Makefile deleted file mode 100644 index 56bb147..0000000 --- a/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -IMAGE_NAME = ngraf3/rust1.88-llvm19:latest -CONTAINER_NAME = bcomp-test-container - -.PHONY: build-image test clean - -build-image: - docker build -t $(IMAGE_NAME) . - -test: build-image - docker run --rm -v $(PWD):/app -w /app $(IMAGE_NAME) cargo test - -clean: - docker rmi $(IMAGE_NAME) || true \ No newline at end of file diff --git a/build.rs b/build.rs deleted file mode 100644 index 0167935..0000000 --- a/build.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::process::Command; -use std::str; - -fn main() { - let include = String::from_utf8( - Command::new("llvm-config-19") - .arg("--includedir") - .output() - .unwrap() - .stdout, - ) - .unwrap() - .trim() - .to_string(); - - let libdir = str::from_utf8( - &Command::new("llvm-config-19") - .arg("--libdir") - .output() - .unwrap() - .stdout, - ) - .unwrap() - .trim() - .to_string(); - - cc::Build::new() - .file("src/emitter/llvm.cpp") - .cpp(true) - .include(&include) - .flag("-Wno-unused-parameter") - .flag("-Wno-unused-local-typedefs") - .flag("-Wno-sign-compare") - .flag("-Wno-missing-field-initializers") - .flag("-Wno-cast-function-type") - .flag("-Wno-unknown-pragmas") - .compile("llvm_emitter"); - - println!("cargo:rerun-if-changed=src/emitter/llvm.cpp"); - println!("cargo:rustc-link-lib=dylib=LLVMCore"); - println!("cargo:rustc-link-search=native={libdir}"); -} diff --git a/input/print.bsc b/tests/input/print.bsc similarity index 100% rename from input/print.bsc rename to tests/input/print.bsc From b67f304d21fe567ac169774c4028f5b96f150f70 Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:14:02 +0000 Subject: [PATCH 02/12] Removed cpp --- src/emitter/llvm.cpp | 25 ------------------------- src/emitter/llvm.h | 9 --------- 2 files changed, 34 deletions(-) delete mode 100644 src/emitter/llvm.cpp delete mode 100644 src/emitter/llvm.h diff --git a/src/emitter/llvm.cpp b/src/emitter/llvm.cpp deleted file mode 100644 index 0504894..0000000 --- a/src/emitter/llvm.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "llvm/ADT/APFloat.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/IR/BasicBlock.h" -#include "llvm/IR/Constants.h" -#include "llvm/IR/DerivedTypes.h" -#include "llvm/IR/Function.h" -#include "llvm/IR/IRBuilder.h" -#include "llvm/IR/LLVMContext.h" -#include "llvm/IR/Module.h" -#include "llvm/IR/Type.h" -#include "llvm/IR/Verifier.h" - -#include "llvm.h" - -static std::unique_ptr Context; -static std::unique_ptr Module; -static std::unique_ptr> Builder; -static std::unordered_map NamedValues; - -//** Initializes the needed LLVM modules */ -int init_llvm() { - - - return 0; -} \ No newline at end of file diff --git a/src/emitter/llvm.h b/src/emitter/llvm.h deleted file mode 100644 index c560ade..0000000 --- a/src/emitter/llvm.h +++ /dev/null @@ -1,9 +0,0 @@ -// emitter/llvm.h -// Template header for LLVM emitter - -#ifndef EMITTER_LLVM_H -#define EMITTER_LLVM_H - -int init_llvm(); - -#endif // EMITTER_LLVM_H \ No newline at end of file From 72ccef98016f4f027774c6cf076f6a6f8dda0a9a Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:14:32 +0000 Subject: [PATCH 03/12] Cleaned up deps --- Cargo.lock | 16 ---------------- Cargo.toml | 3 --- 2 files changed, 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8dd95b7..1e41b7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,19 +6,9 @@ version = 4 name = "bcomp" version = "0.1.0" dependencies = [ - "cc", "ntest", ] -[[package]] -name = "cc" -version = "1.2.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" -dependencies = [ - "shlex", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -107,12 +97,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "syn" version = "1.0.109" diff --git a/Cargo.toml b/Cargo.toml index 3f0ad78..2bc469e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,3 @@ edition = "2024" [dependencies] ntest = "0.9.3" - -[build-dependencies] -cc = "1.0" From ffbc17239ca68315fd4c02232df48cf48621aeee Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:17:34 +0000 Subject: [PATCH 04/12] Added cranelift --- Cargo.lock | 326 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + 2 files changed, 324 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e41b7a..9121944 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,25 +2,245 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + [[package]] name = "bcomp" version = "0.1.0" dependencies = [ + "cranelift", "ntest", ] +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +dependencies = [ + "allocator-api2", +] + +[[package]] +name = "cranelift" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1066593fdf4b6d44cd851d2324b24bc0faa94f44c18c8dc65e182ceae318d1b" +dependencies = [ + "cranelift-codegen", + "cranelift-frontend", + "cranelift-module", +] + +[[package]] +name = "cranelift-assembler-x64" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edb5bdd1af46714e3224a017fabbbd57f70df4e840eb5ad6a7429dc456119d6" +dependencies = [ + "cranelift-assembler-x64-meta", +] + +[[package]] +name = "cranelift-assembler-x64-meta" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a819599186e1b1a1f88d464e06045696afc7aa3e0cc018aa0b2999cb63d1d088" +dependencies = [ + "cranelift-srcgen", +] + +[[package]] +name = "cranelift-bforest" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36e2c152d488e03c87b913bc2ed3414416eb1e0d66d61b49af60bf456a9665c7" +dependencies = [ + "cranelift-entity", + "wasmtime-internal-core", +] + +[[package]] +name = "cranelift-bitset" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6559d4fbc253d1396e1f6beeae57fa88a244f02aaf0cde2a735afd3492d9b2e" +dependencies = [ + "wasmtime-internal-core", +] + +[[package]] +name = "cranelift-codegen" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d9315d98d6e0a64454d4c83be2ee0e8055c3f80c3b2d7bcad7079f281a06ff" +dependencies = [ + "bumpalo", + "cranelift-assembler-x64", + "cranelift-bforest", + "cranelift-bitset", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.16.1", + "libm", + "log", + "regalloc2", + "rustc-hash", + "serde", + "smallvec", + "target-lexicon", + "wasmtime-internal-core", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89c00a88081c55e3087c45bebc77e0cc973de2d7b44ef6a943c7122647b89f5" +dependencies = [ + "cranelift-assembler-x64-meta", + "cranelift-codegen-shared", + "cranelift-srcgen", + "heck", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f77c497a1eb6273482aa1ac3b23cb8563ff04edb39ed5dfcfd28c8deff8f5" + +[[package]] +name = "cranelift-control" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498dc1f17a6910c88316d49c7176d8fa97cf10c30859c32a266040449317f963" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2acba797f6a46042ce82aaf7680d0c3567fe2001e238db9df649fd104a2727f" +dependencies = [ + "cranelift-bitset", + "wasmtime-internal-core", +] + +[[package]] +name = "cranelift-frontend" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dca3df1d107d98d88f159ad1d5eaa2d5cdb678b3d5bcfadc6fc83d8ebb448ea" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f62dd18116d88bed649871feceda79dad7b59cc685ea8998c2b3e64d0e689602" + +[[package]] +name = "cranelift-module" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5ca0d214ecee44405ea9f0c65a5318b41ac469e8258fd9fe944e564c1c1b0b" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-control", +] + +[[package]] +name = "cranelift-srcgen" +version = "0.131.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090ee5de58c6f17eb5e3a5ae8cf1695c7efea04ec4dd0ecba6a5b996c9bad7dc" + [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "gimli" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7f043f89559805f8c7cacc432749b2fa0d0a0a9ee46ce47164ed5ba7f126c" +dependencies = [ + "fnv", + "hashbrown 0.16.1", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "hashbrown" version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "indexmap" version = "2.10.0" @@ -28,9 +248,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.4", ] +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + [[package]] name = "memchr" version = "2.7.5" @@ -55,7 +287,7 @@ checksum = "16d0d3f2a488592e5368ebbe996e7f1d44aa13156efad201f5b4d84e150eaa93" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -67,7 +299,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -97,6 +329,67 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regalloc2" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de2c52737737f8609e94f975dee22854a2d5c125772d4b1cf292120f4d45c186" +dependencies = [ + "allocator-api2", + "bumpalo", + "hashbrown 0.17.0", + "log", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "syn" version = "1.0.109" @@ -108,6 +401,23 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" + [[package]] name = "toml_datetime" version = "0.6.11" @@ -131,6 +441,16 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +[[package]] +name = "wasmtime-internal-core" +version = "44.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816a61a75275c6be435131fc625a4f5956daf24d9f9f59443e81cbef228929b3" +dependencies = [ + "hashbrown 0.16.1", + "libm", +] + [[package]] name = "winnow" version = "0.7.12" diff --git a/Cargo.toml b/Cargo.toml index 2bc469e..5ff71cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,4 @@ edition = "2024" [dependencies] ntest = "0.9.3" +cranelift = "0.131.0" From 5bb9b3deb9ec50e9f32e75d6f7341f8d2569f925 Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:21:54 +0000 Subject: [PATCH 05/12] Added requirements --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index 886cb74..0cc132e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +#![deny(clippy::all)] +#![deny(clippy::pedantic)] +#![deny(warnings)] + mod emitter; mod lexer; mod parser; From 5eb5d47a20339e1e7467fcf66e1619c2b05255f4 Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:22:29 +0000 Subject: [PATCH 06/12] added docs requirement --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.rs b/src/main.rs index 0cc132e..063ca5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,9 @@ #![deny(clippy::all)] #![deny(clippy::pedantic)] #![deny(warnings)] +#![deny(missing_docs)] + +//! A compiler for the basic language mod emitter; mod lexer; From ada5e3e0e218e0d224b865af453160a39b9c6dc6 Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:24:33 +0000 Subject: [PATCH 07/12] Patched ci --- .github/workflows/bcom.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bcom.yml b/.github/workflows/bcom.yml index fc371dc..7f463cd 100644 --- a/.github/workflows/bcom.yml +++ b/.github/workflows/bcom.yml @@ -7,7 +7,7 @@ jobs: lint: runs-on: ubuntu-latest container: - image: ngraf3/rust1.88-llvm19:latest + image: rust:latest steps: - name: Checkout Code uses: actions/checkout@v4 @@ -25,7 +25,7 @@ jobs: needs: [lint] runs-on: ubuntu-latest container: - image: ngraf3/rust1.88-llvm19:latest + image: rust:latest steps: - name: Checkout Code uses: actions/checkout@v4 From ae15fa4ffca9075687e361a6d83e6b056ea710ca Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:26:59 +0000 Subject: [PATCH 08/12] Patched ci --- .github/workflows/bcom.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/bcom.yml b/.github/workflows/bcom.yml index 7f463cd..c97648c 100644 --- a/.github/workflows/bcom.yml +++ b/.github/workflows/bcom.yml @@ -14,6 +14,8 @@ jobs: # Linter uses git history with: fetch-depth: 0 + - name: Install Rust components + run: rustup component add clippy rustfmt - name: Pass linter run: | cargo clippy -- -Dwarnings @@ -31,6 +33,8 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Install Rust components + run: rustup component add clippy rustfmt - name: Build source run: cargo build --all-targets - name: Test source From 29278eecd972ec43529ee904c5d99865032d9af5 Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:29:15 +0000 Subject: [PATCH 09/12] Added caching --- .github/workflows/bcom.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/bcom.yml b/.github/workflows/bcom.yml index c97648c..3cfb9a1 100644 --- a/.github/workflows/bcom.yml +++ b/.github/workflows/bcom.yml @@ -14,6 +14,8 @@ jobs: # Linter uses git history with: fetch-depth: 0 + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 - name: Install Rust components run: rustup component add clippy rustfmt - name: Pass linter @@ -33,6 +35,8 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 - name: Install Rust components run: rustup component add clippy rustfmt - name: Build source From 5a9bd3914ba7422ecff5300853f18af01b3e382c Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:33:19 +0000 Subject: [PATCH 10/12] Addressed shitty lints --- src/emitter.rs | 2 +- src/lexer/token.rs | 6 +++++- src/parser.rs | 8 +++++--- src/parser/ast.rs | 6 ++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/emitter.rs b/src/emitter.rs index 93805b2..72e425c 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -12,7 +12,7 @@ pub struct Emitter<'ctx> { } #[allow(unused_variables, dead_code)] -impl<'ctx> Emitter<'ctx> { +impl Emitter<'_> { pub fn new(module_name: &str) -> Self { unimplemented!() } diff --git a/src/lexer/token.rs b/src/lexer/token.rs index 4a93282..d548c87 100644 --- a/src/lexer/token.rs +++ b/src/lexer/token.rs @@ -60,6 +60,10 @@ pub enum Token { #[allow(dead_code)] impl Token { + #[expect( + clippy::cast_precision_loss, + reason = "numeric literals are currently represented as f64 in the AST" + )] pub fn get_number(&self) -> f64 { match self { Token::Float(num) => *num, @@ -69,7 +73,7 @@ impl Token { } pub fn get_ident(&self) -> String { match self { - Token::Identifier(ident) => ident.to_string(), + Token::Identifier(ident) => ident.clone(), _ => panic!("Not Identifier!"), } } diff --git a/src/parser.rs b/src/parser.rs index 2925ef7..a426ea8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -86,6 +86,10 @@ impl Parser { kind.map(|kind: ASTBinaryOperatorKind| ASTBinaryOperator::new(kind, token.clone())) } + #[expect( + clippy::cast_precision_loss, + reason = "numeric literals are currently represented as f64 in the AST" + )] fn parse_primary_expression(&mut self) -> Option { let token: Token = self.current()?; // match basic expression types @@ -98,9 +102,7 @@ impl Parser { self.position += 1; let expr: ASTExpression = self.parse_expression()?; let token: Token = self.current()?; - if token != token::Token::RParen { - panic!("Expected Right Parentheses"); - } + assert_eq!(token, token::Token::RParen, "Expected Right Parentheses"); self.position += 1; Some(ASTExpression::paren(expr)) } diff --git a/src/parser/ast.rs b/src/parser/ast.rs index cb1d872..fca82d0 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -61,10 +61,8 @@ impl ASTBinaryOperator { pub fn precedence(&self) -> u8 { match self.kind { - ASTBinaryOperatorKind::Plus => 1, - ASTBinaryOperatorKind::Minus => 1, - ASTBinaryOperatorKind::Divide => 2, - ASTBinaryOperatorKind::Mult => 2, + ASTBinaryOperatorKind::Plus | ASTBinaryOperatorKind::Minus => 1, + ASTBinaryOperatorKind::Divide | ASTBinaryOperatorKind::Mult => 2, } } } From 1954388d41e1c6d7cd955a700f7eceb55fec27e7 Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:37:14 +0000 Subject: [PATCH 11/12] fixed test --- src/lexer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lexer.rs b/src/lexer.rs index aeade86..abf6180 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -359,7 +359,7 @@ mod test { #[test] #[timeout(100)] fn test_print() { - let file_path = "./input/print.bsc"; + let file_path = "./tests/input/print.bsc"; // Attempt to read the file contents into a String let contents = std::fs::read_to_string(file_path).unwrap(); From 0f3c6ad4022d2f2ad09cc43dfb45016ccc5f3071 Mon Sep 17 00:00:00 2001 From: Noah Graf Date: Sat, 25 Apr 2026 03:37:37 +0000 Subject: [PATCH 12/12] Fixed yaml --- .github/workflows/bcom.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcom.yml b/.github/workflows/bcom.yml index 3cfb9a1..43d090c 100644 --- a/.github/workflows/bcom.yml +++ b/.github/workflows/bcom.yml @@ -1,5 +1,5 @@ name: Build Test and deploy -run-name: ${{ github.actor }} is building and testing the emulator! 🚀 +run-name: ${{ github.actor }} is building and testing the emulator! on: [push] env: CARGO_TERM_COLOR: always # I like the colors