theoremoon / silk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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


Languages

Language:OCaml 91.8%Language:Shell 7.2%Language:C 0.7%Language:Standard ML 0.3%