Skip to content

A toy scheme compiler and VM in rust. This is my take on crafting interpreters.

Notifications You must be signed in to change notification settings

certainty/braces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Braces

Build Status

Brace for impact

Usage

Start the REPL and play around with it

make repl 

State

This is beyond the toy state but the code is messy and experimental at times. However, the compiler and the VM is coming together and I will go on with this to see how fare I can bring it.

Language Support

  • literals
    • bool
    • symbol
    • char
    • number
    • vector
    • byte-vector
    • proper list
    • improper list
    • string
    • quoted constants
  • variables
  • conditionals
  • lambda expression
  • procedure call
  • assignment

Compiler

  • sexp parser
  • expression parser
  • basic code generator
  • collect all errors in sexp parser
  • collect all errors in expr parser
  • bytecode serialization
  • libraries
  • optimization pass
  • identify tail calls
  • quasi quote

Macros

  • add macro expansion phase
  • add syntactic closure macro system

Errors

  • fix backtraces
  • improve error reporting for sexp parser
  • improve error reporting for expressions

VM

  • optimise tail calls
  • closures
  • continuations
  • optimize stack

Debugger

  • generate DWARF debug information

Repl

  • command support
  • bracket matching
  • completion of bound identifiers

Continuations

  • figure out how to implement them

Problems

There are plenty :D

  • Runtime representation of values isn't at all optimised. It likely uses way too many allocations and holds the types wrong
  • The parser bails after the first error (you'd want to collect all)
  • I'm not sure if the custom ParseResult I use is really needed? (I will have to figure that out)
  • No proper macro expander yet. (There is an expansion phase which expands using rust code but that's very limited for now)
  • No support for internal defines (we might get away by adding an expansion to letrec*)
  • I'm not sure the location tracking works all the time

About

A toy scheme compiler and VM in rust. This is my take on crafting interpreters.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages