Skip to content

Learning about llvm ir by building a lisp compiler

Notifications You must be signed in to change notification settings

RS2007/Lisp-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lisp-compiler

Go Tests

  • 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)

Prerequisites

  • A golang compiler
  • LLVM toolchain(llc should be in path)
  • GCC/Clang(For assembling)

Usage

  go build
  ./lisp-compiler interpret <name-of-file> # For running the interpreter
  ./lisp-compiler compile <name-of-file># Compiles to an executable called output

Current progress

Features

  • 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.

Demo

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.

About

Learning about llvm ir by building a lisp compiler

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages