From fb5788c16a4351857ee62c6d51300664af6826ac Mon Sep 17 00:00:00 2001 From: pbaekgaard Date: Thu, 12 Feb 2026 11:10:12 +0100 Subject: [PATCH 1/3] init for self written compiler --- .gitignore | 1 + README.md | 4 ++-- test.sl | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 test.sl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/README.md b/README.md index ee91f74..a4ccd5f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# masterthesis -Our Master Thesis +# Master Thesis (TriviLang) +Trivilang is a custom toy language for demonstrating the ease of adding hardening capabilities to compilers. diff --git a/test.sl b/test.sl new file mode 100644 index 0000000..6af6c8d --- /dev/null +++ b/test.sl @@ -0,0 +1,32 @@ +# Test file for small_lang compiler + +func is_greater_than_44(params : Integer) -> Integer { + let x : Integer = params; + if x > 44 is True then { + 1 + } + else if not { + 0 + } +} + + +func otherFunction() -> Boolean { + let number : Integer = 20; + let is_greater : Integer = is_greater_than_44(number); + if is_greater == 0 is True then { + print("Didnt work the first time!"); + } + while is_greater == 0 do { + number = number + 1; + is_greater = is_greater_than_44(number); + } + True +} + +func main() -> Boolean { + let result : Boolean = otherFunction(); + print(result); + print("Finished"); + result +} From 07dcd7909285fe1ff171af9961fab905525effb5 Mon Sep 17 00:00:00 2001 From: Aasmundur Date: Thu, 12 Feb 2026 11:41:09 +0100 Subject: [PATCH 2/3] started the stuffs --- .github/workflows/ci.yml | 55 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 7 +++++ Cargo.lock | 32 +++++++++++++++++++++++ Cargo.toml | 14 ++++++++++ src/main.rs | 12 +++++++++ 5 files changed, 120 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..00e6444 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI + +on: + pull_request: + branches: [main, master] + push: + branches: [main, master] + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run tests + run: cargo test --verbose + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Build release + run: cargo build --release --verbose diff --git a/.gitignore b/.gitignore index ea8c4bf..a5ff07f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,8 @@ /target + + +# Added by cargo +# +# already existing elements were commented out + +#/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..cc5f216 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,32 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "trivilang" +version = "0.1.0" +dependencies = [ + "pretty_assertions", +] + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..23d8030 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "trivilang" +version = "0.1.0" +edition = "2024" + +[[bin]] +name = "trivic" +path = "src/main.rs" + +[dependencies] + + +[dev-dependencies] +pretty_assertions = "1.4.1" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c97fc64 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,12 @@ +fn main() { + println!("Hello, world!"); +} + +#[cfg(test)] +mod tests{ + use pretty_assertions::{assert_eq}; + #[test] + fn zero_eq_zero(){ + assert_eq!(0,0); + } +} \ No newline at end of file From 75a070a9e3fd7a1f951818fd8fd6a8930e6b005a Mon Sep 17 00:00:00 2001 From: Aasmundur Date: Thu, 12 Feb 2026 11:44:30 +0100 Subject: [PATCH 3/3] No name for CI --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00e6444..21182b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,3 @@ -name: CI - on: pull_request: branches: [main, master]