Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

jonathanhefner/kaleidoscope__llvm_parslet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kaleidoscope

A simple programming language loosely following the Kaleidoscope tutorial. Implemented in Ruby using Parslet for parsing and LLVM for JIT compilation.

Installation

First, install LLVM 3.5 from source (this requires Python 2):

$ wget -qO- http://llvm.org/releases/3.5.2/llvm-3.5.2.src.tar.xz | tar -xJ

$ cd llvm-3.5.2.src

$ ./configure --enable-shared --enable-jit --prefix=/usr/lib/llvm-3.5

# This will take a while...
$ make

$ sudo make install

Next, run bundle install with a pointer to LLVM:

$ cd /path/to/kaleidoscope

$ LLVM_CONFIG=/usr/lib/llvm-3.5/bin/llvm-config bundle install

Finally, run the tests:

$ LD_LIBRARY_PATH=/usr/lib/llvm-3.5/lib bundle exec rake test

Usage

Compile and run a script using the run task:

$ LD_LIBRARY_PATH=/usr/lib/llvm-3.5/lib bundle exec rake run[path/to/script]

Try it with the scripts in the examples directory:

$ LD_LIBRARY_PATH=/usr/lib/llvm-3.5/lib bundle exec rake run[examples/factorial.kal]
39916800.0

$ LD_LIBRARY_PATH=/usr/lib/llvm-3.5/lib bundle exec rake run[examples/fibonacci.kal]
89.0
Contents of examples/factorial.kal:
def factorial(n)
  if n <= 1 then
    1
  else
    n * factorial(n - 1)


factorial(11)
Contents of examples/fibonacci.kal:
def fibonacci(n)
  if n <= 2 then
    1
  else
    fibonacci(n - 1) + fibonacci(n - 2)


fibonacci(11)

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages