Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jochasinga/ml-brainfuck
Brainfuck interpreter written in Ocaml
https://github.com/jochasinga/ml-brainfuck
brainfuck brainfuck-interpreter ocaml
Last synced: 3 months ago
JSON representation
Brainfuck interpreter written in Ocaml
- Host: GitHub
- URL: https://github.com/jochasinga/ml-brainfuck
- Owner: jochasinga
- Created: 2017-09-20T19:04:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-22T13:41:07.000Z (over 3 years ago)
- Last Synced: 2024-10-07T20:10:46.637Z (4 months ago)
- Topics: brainfuck, brainfuck-interpreter, ocaml
- Language: OCaml
- Homepage:
- Size: 7.81 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ml-brainfuck
Simple Brainfuck parser that reads text file or stdin and prints out the byte value or ASCII character.## Setup
+ Install Ocaml and OPAM
+ Compile to use in another Ocaml project:```bash
$ ocamlc -c brainfuck.mli; ocamlopt -c brainfuck.ml
```
## Usage
sample.bf:
```brainfuck
Below calculates 100
+++++ [ > +++++ +++++ < - ] > .
```
run as a command line tool:
```bash
# Prints '100'.
$ ocaml brainfuck.ml sample.bf -fmt integer
$ echo '++++ [> +++++ +++++ < - ] > .' | ocaml brainfuck.ml -fmt integer```
Leave out `-fmt` option to print out ASCII characters as a default.
```brainfuck
hello.txt
> +++++++ [ > +++++ +++++ < - ] > ++ .
> +++++ +++++ [ > +++++ +++++ < - ] > + .
> +++++ +++++ [ > +++++ +++++ + < - ] > -- .
> +++++ +++++ [ > +++++ +++++ + < - ] > -- .
> +++++ +++++ [ > +++++ +++++ + < - ] > + .```
```bash
# Prints 'Hello'.
$ ocaml brainfuck.ml hello.txt```
To use in another Ocaml project:
```ocaml
Brainfuck.interpret "++++ [ > +++++ +++++ < - ] > ."
```