Skip to content

theoremoon/silk

Repository files navigation

silk

Silk is a practice language based on LLVM which respect to cotton.

try it

  1. git clone
  2. opam install omake menhir llvm
  3. omake
  4. ./silk

requirements

  • mehir
  • llvm

usage

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.

syntax

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.

features

  • 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)

future works

  • make blocks as expr
  • specify type
  • boolean
  • float type
  • create function scope

and so on

  • type inference
  • closure

Author

theoldmoon0602

LICENSE

This repository does not have any licenses (any problems?).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages