- Author: Ethan Turkeltaub
- License: MIT License
Here I am, brain the size of a planet, and they ask me to compile code. Call that job satisfaction? 'Cause I don't.
Marvin is a toy language written in Ruby using RLTK. It's not meant for production use, but just as a way to explore writing compilers and interpreters.
Here's an quick example of a Marvin program that takes a width and a height, computes the area of those two measurements, and prints the result:
fun area(width, height) {
return width * height
}
a = area(4, 8)
print(a) # => 32
Marvin requires two external dependencies:
It's highly recommended that you install Homebrew, if you haven't already:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Next, install rbenv and ruby-build using Homebrew:
$ brew install rbenv ruby-build
You'll need to add to your $PATH
to get rbenv to work globally. Head into your ~/.bash_profile
file using the text editor of your choice and add the following snippet:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
If you don't use Bash, something similar will work for ZSH and Fish, at least.
Restart your current shell:
$ exec $SHELL -l
Finally, you can go ahead and install Ruby:
$ rbenv install 2.3.1
All you need to do is install the dependencies using Bundler.
$ bundle install
Then you’ll need to install LLVM. The version of LLVM that we use is a bit tempermental to install, so we need to install the HEAD
development versions of some its dependencies as well:
$ brew install --HEAD isl
$ brew install --HEAD cloog
$ brew install --rtti --with-clang --with-libcxx --with-shared --HEAD llvm35
Grab a coffee, this will take a while.
There is an open issue with FFI (a dependency of RCGTK) that prevents it from finding dylib without an absolute path. It also ignores the environment variables that tell it the paths to look in. To avoid this, manually copy the LLVM 3.5 dylib to the correct directory.
$ cp /usr/local/lib/llvm-3.5/lib/libLLVM-3.5.dylib /usr/local/lib/
After this, you're (finally) all set!