Lua library for writing Scheme interpreters/compilers

$ luarocks install lure

Lua library for writing Scheme interpreters and compilers.

This is still very much in flux. I'm going to keep replacing the 0.1-1 rockspec as there's currently no point to track versions. The rockspeck points to a github v1.0 branch that is regularly updated. For pull requests, please use the original 'uc_tools' repository, the 'lure-lua' repository is just an exceprt to support the rockspec.

To run the test suite:

require('lure.test').run()

So what is this? Started as an experiment to create a small DSL for designing state machines that would run as part of an ISR on a small microcontroller programmed in C (see 'lure.test_smc'). I did not want to introduce a large dependency in the project this was supposed to fit in, which was already using Lua. I had some experience writing DSLs in Racket Scheme, so I started out with a subset of Scheme. The DSL is called SMC: Scheme to state Machine Compiler. In the process of developing the DSL it became apparent that I also needed a Scheme interpreter, and I had built an incomplete Scheme to Lua compiler (SLC) using the same library. So I continued refactoring, split up the process into separate passes, discovered a simple way to do pattern matching and this is where we are now. The refactored language tower now looks like:

1. scheme_frontend + scheme_macros

These convert (almost standard) Scheme with macro facility into a block language that resembles a subset of Lua, but is encoded in s-expressions.

2. scheme_block_flatten + scheme_blockval + scheme_luapp

The simplification and transformation pipeline that terminates in a a Lua pretty printer for a variant of the block language.

3. a wrapper for this, so it is possible to write lua modules in scheme (see e.g. lib_scm.lua)

I plan to rework the SMC in the same way as the SLC, as a compiler using multiple passes, and complete SLC so it has a way to implement proper tail call handling.

Versions

0.1-12 years ago(revision: 13)44 downloads

Dependencies

lua >= 5.1

Manifests