- Learning about llvm ir by building a lisp compiler.
- Currently supports an interpret and compile mode.
- Interpret runs a tree walking interpreter on the AST.
- Compiler generates LLVM IR thats compiled using LLVM's
llc
to generate an executable
- Handwritten lexer+parser
- Supports the write syscall for Mac M2 AArch64 platform (Others to be added in due course)
- A golang compiler
- LLVM toolchain(
llc
should be in path) - GCC/Clang(For assembling)
go build
./lisp-compiler interpret <name-of-file> # For running the interpreter
./lisp-compiler compile <name-of-file># Compiles to an executable called output
- Function expressions
- If expressions
- Integer data structures & arithmetic and comparision operators on them
- Interpret and compile modes
- Write Syscall support
Write syscall does'nt work with the interpret mode, since references are implemented only for LLVM IR. Instead to print just return the value from the function and subsequently main.
Screen.Recording.2023-09-19.at.1.06.45.PM.mov
Warning
Using an If expression without an else expression will implicitly assume the else block expression to be 0.