Skip to content

jochasinga/ml-brainfuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:
$ ocamlc -c brainfuck.mli; ocamlopt -c brainfuck.ml

Usage

sample.bf:


Below calculates  100

+++++ [ > +++++ +++++ < - ] > .

run as a command line tool:

# 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.


hello.txt

> +++++++ [ > +++++ +++++ < - ] > ++ .
> +++++ +++++ [ > +++++ +++++ < - ] > + .
> +++++ +++++ [ > +++++ +++++ + < - ] > -- .
> +++++ +++++ [ > +++++ +++++ + < - ] > -- .
> +++++ +++++ [ > +++++ +++++ + < - ] > + .
# Prints 'Hello'.
$ ocaml brainfuck.ml hello.txt

To use in another Ocaml project:

Brainfuck.interpret "++++ [ > +++++ +++++ < - ] > ."

About

Brainfuck interpreter written in Ocaml

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages