Skip to content

A toy programming language written to explore compilers, type systems theory and virtual machines

License

Notifications You must be signed in to change notification settings

mrandri19/test-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My programming language

TEST-LANG, badly handwritten

This is an experimental programming language used for learning, written in OCaml 4.06.1.

Current features

  • Simple arithmetics (+, -, *, /, >, <) with precences
  • int and bool types
  • let bindings and if expressions
  • Closures fun x: int -> x*x
  • Strict, static typechecker
  • Partial evaluation:
  • Multiple argument functions
  • Print type of arbitrary expressions
  • Unit type
  • Tuples
  • REPL
$ dune build repl.exe && dune exec ./repl.exe
> let a = ((fun x:(int) -> fun y:(int) -> x+y) 12) in a 122
int :: (Eval.Int 134)
> (fun x:(int->int->int) -> x 4 5) (fun x:(int) y:(int) -> x+y)
int :: (Eval.Int 9)
> (fun x:(int->int*int->int) -> (x 1 (1,1))+1) (fun x:(int) y:(int*int) -> 99)
int :: (Eval.Int 100)

Planned features

Usability

  • Better syntax errors, OMG PLEASE, especially in * (Kleene star) rules
  • Better typechecking errors

Syntax Sugar

  • Recursive functions

Typesystem

  • Use a typed AST to build the base for type inference
  • Records
  • Sum types
  • Lists

Recusive types

  • Recusive types

Polymorphism

  • Hindley-Milner type system on System F

Long term goals

  • Explore structural vs nominal typing
  • Linear types
  • Typeclasses
  • Algebaic effects
  • Concurrency and Parallelism (API via algebraic effects, monads)
  • Dependent types
  • Compilation to:
    • Assembly
    • LLVM
    • C
    • Go
    • JS
  • Virtual machine (maybe written in rust)

Resources

  • Types and programming languages (Benjamin C. Pierce)
  • Programming language Zoo
  • Modern Compiler implementation in ML (Andrew Appel)

About

A toy programming language written to explore compilers, type systems theory and virtual machines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages