Silk is a practice language based on LLVM which respect to cotton.
git clone
opam install omake menhir llvm
omake
./silk
- mehir
- llvm
If you run ./silk
without any parameters, the binary will read silk program from stdin until EOF. And will output LLVM IR to stdout.
Also ./silk
can run with oen parameter that filename to output LLVM bitcode.
A simple factorial program from examples.
def fact(n:I32):I32 = {
if n == 0 {
1
}
else {
n * fact(n-1)
}
}
def main() = {
print(fact(5))
}
this program will output 120
.
- program starts with
main
function - integer literals have
int32_t
type - function returns last evaluated value
- if/else are expression
- type inference is available
- fully typed recursive function is available
- mutual recursive function is not available even fully typed
- nested function available (not closure! so could not capture variables)
- make blocks as expr
- specify type
- boolean
- float type
- create function scope
and so on
- type inference
- closure
theoldmoon0602
This repository does not have any licenses (any problems?).