diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..21182b3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +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 new file mode 100644 index 0000000..a5ff07f --- /dev/null +++ b/.gitignore @@ -0,0 +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/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/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 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 +}