The whitescape is a project that aims to transpile a custom high-order-language into the esoteric Whitespace programming language using Rust. I created it to familiarize myself with Rust 🦀 and challenge myself by building a complex program in an unfamiliar field.
- Clone the repository.
- Write your program within the
code
variable inside themain.rs
file. - Run
cargo run
. Upon successful compilation, the resulting whitespace code will be outputted to theout/a.out
file.
This project isn't about making a brand-new popular language. It's focused on building a basic yet complete high-level language that will be converted into whitespace code.
- Implement basic arithmetic and IO.
- Addition, subtraction.
- Integer input.
- Output for integers and strings.
- Multiplication, division, modulo.
- Input for arbitrary length strings.
- Implement basic flow control.
- While loop.
- Functions.
- Implement more advanced data types like strings.
- Add configuration options for code input and output.
- Improve project source code readability.
- Implement improved syntax checking with easily understandable errors.
Any contributions are more than welcome!
The transpiler supports basic arithmetic operations: addition, subtraction, multiplication, and division. Operations are executed from left to right, diverging from the conventional mathematical order. It's crucial to separate all operands by a space for valid expressions. For instance, instead of 1+2+3
, it should be written as 1 + 2 + 3
.
string[13] greeting = "Hello world!"
The code above defines a string with an initial value. String sizes are mandatory; the size must account for the null terminator placed at the end of the string (string[2] one_symbol = "a"
).
Concatenate the content of the source to the top of the target.
Hello world
print("Hello, world");
exit;
Print a number
print(101);
exit;
Read a number
int a;
read(a);
print(a + 1);
exit;
Print an integer variable
int m = 11;
print(m);
exit;
Basic while loop
int m = 8;
while (m < 11) {
print(m);
m = m + 1;
}
exit;
Great user
string[32] greeting = "Hello, ";
string[25] name;
read(name);
concat(greeting, name);
print(greeting);
exit;
Note: Please note that this project is a work in progress.