Skip to content
A Brainfuck to WebAssembly compiler written in Haskell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Makefile
README.md
Setup.hs
brainass.cabal
brainass.hs
hello.bf
play.html
play.js

README.md

Brainfuck to WebAssembly compiler

This is a Brainfuck to WebAssembly compiler.

To use it, you'll need a recent GHC and wat2wasm installed in your environment.

Run make compile-compiler (or ghc brainass.hs) to compile the compiler.

Run ./brainass (or whatever you compiled brainass.hs to) to read how to use the compiler. It should print the following.

Usage: compile IMPORTED_INPUT IMPORTED_OUTPUT EXPORT
where
  IMPORTED_INPUT  is imported Javascript function for Brainfuck's ,
  IMPORTED_OUTPUT is imported Javascript function for Brainfuck's .
  EXPORT is the exported Javascript function from the WASM module

Brainfuck source is read fro STDIN and text wasm is written to STDOUT
(similar to `cat`)

Example:
  cat source.bf > compile bf.getchar bf.putchar bf > main.wat
  makes wasm module import bf.getchar as "," and bf.putchar as "."
  and the wasm module exports a function named bf.

Running make build-and-run-helloworld will:

  1. build the compiler in local directory as ./compile.
  2. compile a hello world program in Brainfuck to main.wasm
  3. launch a server at http://localhost:8000/play.html which runs the wasm program

You can read this make command, as well as play.{js,html} to learn how to use the compiler as well.

You can’t perform that action at this time.