Skip to content

Latest commit

 

History

History
81 lines (61 loc) · 1.99 KB

README.md

File metadata and controls

81 lines (61 loc) · 1.99 KB

Tisp (Toy Lisp)

A Lisp-like programming language that is typed and compiled. It aims to support multiple processor architectures by being built upon LLVM. It takes inspiration from programming languages like Rust, Lisp and Elixir.

Current working example

A program to compute first 5 fibonacci numbers:

(let first 0)
(let second 1)
(let fib)
(let n 0)

(while (< n 5)
    (let fib (+ first second))
    (let second first)
    (let first fib)

    (let n (+ n 1))
    (print fib)
)

Features to build

  • Convert raw code into token stream
  • Convert token stream into Expression tree
  • Handle multiple levels of nested expressions
  • Have multiple (independent) expressions per file
  • Generate LLVM IR for the currently supported features
  • add CLI flag to emit llvm
  • add while loop
  • Declare variables
  • add nested while loops
  • Add types for function and variable declaration
  • Define functions
  • Support types in code

Setup working environment

This project uses the following requirements:

How to build and run Tisp compiler

  1. Download and install all dependencies.
  2. Clone the repo and cd into it
  3. Run cargo build to build it from source
  4. Then you execute the compiled binary using the command below:
target/debug/tispc -h

Compiling a Tisp source file

Write some valid Tisp code like the following:

(let x 300)
(print "Hello world" (+ 2 (- 1 x)))

and save it in a file somewhere, for eg. ~/test.tp. Now compile it using

target/debug/tispc -i ~/test.tp

Then you can run the output generated using lli command, like so:

lli ~/output.ll

NOTE: Tisp doesn't generate executable binaries yet, it generates LLVM IR in a file called output.ll in the same folder as the source file that you can run with the lli command that comes with your LLVM installation.