Content of this repository is a copy of (https://github.com/chumer/bf).
Thanks to Christian Humer, who kindly agreed that i could reuse this at MI-RUN seminar in CTU.
See (https://www.youtube.com/watch?v=FJY96_6Y3a4) for a nice Truffle tutorial by Christian Wimmer.
A Brainfuck (short BF) implementation using Truffle for the GraalVM.
BF is a famous esoteric language invented by the Swiss Urban Müller in 1993, in an attempt to make a language for which he could write the smallest possible compiler for the Amiga OS, version 2.0. Instead of beeing as small as possible, this implementations aims to be as fast as possible by leveraging dynamic speculation with Truffle and Graal.
This repository is licensed under the permissive UPL licence. Feel free to fork an extend it.
Brainfuck operates on an array of memory cells, also referred to as the tape, each initially set to zero. There is a pointer, initially pointing to the first memory cell. The commands are:
Command | Description |
---|---|
> | Move the pointer to the right |
< | Move the pointer to the left |
+ | Increment the memory cell under the pointer |
- | Decrement the memory cell under the pointer |
. | Output the character signified by the cell at the pointer |
, | Input a character and store it in the cell at the pointer |
[ | Jump past the matching ] if the cell under the pointer is 0 |
] | Jump back to the matching [ if the cell under the pointer is nonzero |
All characters other than ><+-.,[] should be considered comments and ignored.
For more information see the reference on Esolangs.
- JDK 8
- maven3
- Clone BF repository using
git clone https://github.com/japod/bf
- Download Graal VM Development Kit from http://www.oracle.com/technetwork/oracle-labs/program-languages/downloads select GraalVM preview, Development Kit (http://download.oracle.com/otn/utilities_drivers/oracle-labs/graalvm-0.17-linux-x86_64-dk.tar.gz)
- Unpack the downloaded
graalvm_*.tar.gz
intobf/graalvm
. - Verify that the file
bf/graalvm/bin/java
exists and is executable - Execute
mvn package
- Tested with Netbeans 8.2
- Open Netbeans
- File -> Open Project -> Select
bf
folder -> Open Project
- Tested with Eclipse Mars SR2
- Open Eclipse with a new workspace
- Install
m2e
andm2e-apt
plugins from the Eclipse marketplace (Help -> Eclipse Marketplace...) - File -> Import... -> Existing Maven Projects -> Select
bf
folder -> Finish
- Tested with IntelliJ 2016.1.3 Community Edition
- Open IntelliJ IDEA
- File -> New -> Project from existing Sources -> Select
bf
folder -> Click next and keep everything default on several screens -> Finish
- Execute
./bf hello.bf
to run a simple language source file.
- Download the Ideal Graph Visualizer (IGV) from https://lafo.ssw.uni-linz.ac.at/pub/idealgraphvisualizer/
- Unpack the downloaded
.zip
file - Execute
bin/idealgraphvsiualizer
to start IGV - Execute
./bf -dump tests/SumPrint.sl
to dump graphs to IGV.
- Execute
./bf -debug tests/HelloWorld.sl
. - Attach a Java remote debugger (like Eclipse) on port 8000.
Truffle BF is compatible to:
- Truffle-Version: 0.18
- GraalVM-Version: 0.17
- Truffle JavaDoc
- Truffle on Github
- Graal on Github
- Graal VM on the Oracle Technology Network
- Publications on Truffle
- Publications on Graal
The Truffle framework is licensed under the GPL 2 with Classpath exception. Truffle BF is licensed under the Universal Permissive License (UPL).