This is a hobby project to learn about compilers and language design. I've designed the language to be similar to C and Rust.
Heavily inspired by https://github.com/DoctorWkt/acwj
- Global Variables
- Functions
- Arrays
- Integers (signed and unsigned)
- Strings
- Binary Operations
- Code Generation (GNU Assembly)
- Print to Console (integers & ascii characters)
- If Statements
- While Statements
- For Statements
- Function Parameters
- Function Arguments
- Local Variables (Scopes)
- Function Hoisting
- Reading from console
- Dynamic Arrays
- Structs
- Unions
- Enums
- Break & Continue
- Variable Initialization
- Casting
- Sizeof
- Static
- Struct Methods
- Struct Traits
- LLVM
cargo run <input-file> # Compile the crust language to assembly, which will be written to out.s
cc -no-pie -z noexecstack -o bin out.s # Use the GNU C compiler to compile and link the assembly code to an executable file
./bin # Execute the produced binary
./runtests.sh
Some examples of the language
let c: char;
let str: *char;
fn main(): u8 {
c= '\n'; printint(c);
for (str= "Hello world\n"; *str != 0; str= str + 1) {
printchar(*str);
}
return 0;
}
let a: u8;
let b: u8[25];
fn main(): u32 {
b[3]= 12; a= b[3];
printint(a);
return 0;
}