https://github.com/dduan/brainass
A Brainfuck to WebAssembly compiler written in Haskell
https://github.com/dduan/brainass
brainfuck haskell wasm wasm-example webassembly
Last synced: 16 days ago
JSON representation
A Brainfuck to WebAssembly compiler written in Haskell
- Host: GitHub
- URL: https://github.com/dduan/brainass
- Owner: dduan
- Created: 2018-10-13T06:47:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-27T21:48:12.000Z (over 6 years ago)
- Last Synced: 2025-03-26T21:22:05.763Z (about 1 month ago)
- Topics: brainfuck, haskell, wasm, wasm-example, webassembly
- Language: Haskell
- Homepage:
- Size: 8.79 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# *Brain*fuck to Web*Ass*embly compiler
This is a Brainfuck to WebAssembly compiler.
To use it, you'll need a recent [GHC][0] and [wat2wasm][1] 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 moduleBrainfuck 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
programYou can read this make command, as well as `play.{js,html}` to learn how to use
the compiler as well.[0]: https://www.haskell.org/ghc/
[1]: https://github.com/WebAssembly/wabt#running-wat2wasm-and-wast2json