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

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Braces (the tiny scheme compiler and VM)

Brace for impact

State

This is beyond the state where it's just dabbling around. However at this point I don't have any intentions to turn it into something for real world usage (I'm not sure I could even if I tried). It will likely remain a play ground where I just try out ideas. I'll just see where it takes me.

Usage

Start the REPL and play around with it

make repl 

Language Support

  • literals
    • bool
    • symbol
    • char
    • number
    • vector
    • byte-vector
    • proper list
    • improper list
    • string
    • quoted constants
  • variables
  • conditionals
  • lambda expressions
  • procedure calls
  • assignments
  • quasi-quoted expression

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

GC

Well there is none :D I probably should build one or maybe not.

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