Warning
This project is a W.I.P. The functionality and features may change or be incomplete.
Warning
This Project is only tested on linux.
If you use linux, dev tools for llvm can be installed from your package manager. For example, on Arch:
pacman -S llvm
For more information, click here
On linux:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
For more information, click here
git clone https://github.com/vishruth-thimmaiah/sloppee.git
cd sloppee
cargo build --release -p stdlib
cargo build --release
The compiler executable will be located at target/release/sloppee
.
cargo test
sloppee [COMMAND] <file> [OPTIONS]
sloppee --help
Examples can be found at examples/
.
import std:io
func main() i32 {
io:println("Hello World")
return 0
}
the 'let' keyword is used, followed by the type, variable name and value.
import std:io
func main() i32 {
let i32 num = 5
io.printint(num)
return 0
}
variable are immutable unless declared otherwise.
A '!' after the type makes a variable mutable.
import std:io
func main() i32 {
let i32! num = 5
num = 10
io.printint(num)
return 0
}
Basic math operations are supported.
import std:io
func main() i32 {
let i32 num = 5
let i64 num2 = 10
io.printint(num+num2)
return 0
}
In the above example, num is implicitly type casted to i64. Implicict type casts are done between two similar data types. For non similar type casts, (ex: f32 to i32) use explicict type casting.
Use '->' for explicict type casting.
import std:io
func main() u32 {
let f32 a = 34.1
let u32 b = a -> u32
io:printint(b)
return 0
}
func main() u32 {
let u32 a = 2
if a == 0 {
return 1
} else if a == 1 {
return 2
} else if a == 2 {
return 3
} else {
return 0
}
}
- An infinite Loop:
func main() u32 {
let u32! a = 0
loop {
a = a + 1
return a
}
return 0
}
- A conditional Loop:
func main() u32 {
let u32! a = 0
loop a < 10 {
a = a + 1
}
return a
}