Skip to content

eigenhombre/lll

Repository files navigation

build

Experiments in LLVM, probably leading to some sort of simple, low-level Lisp language implementation.

Right now I'm working on building a small compiler that parses Lisp expressions to do integer math only.

Eventually, it might become something like a backend for this other Lisp.

For the moment, see compiler_test.go to get an idea of the direction.

$ go build .

$ echo 42 > fortytwo

$ ./lll fortytwo > answer.ll

$ cat answer.ll
declare void @_print_int(i32 %x)

define i32 @main() {
0:
	call void @_print_int(i32 42)
	ret i32 0
}

$ clang answer.ll _print.c -o answer

$ ls -l answer
-rwxr-xr-x  1 jacobsen  staff  49464 Feb 19 20:52 answer

$ ./answer
42

Use Cases

For the moment, I want to support the following use cases.

  • Compile and execute expressions from the REPL.
  • Compile a program to disk and execute it later, or on another machine.

License

MIT

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.