Skip to content

A small interpreter for the Brainfuck language written in Haskell.

Notifications You must be signed in to change notification settings

nikhilJain17/haskell-brainfuck-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

haskell-brainfuck-interpreter

A small interpreter for the Brainfuck language written in Haskell.

About

Brainfuck is an esoteric programming language invented by Urban Müller in 1992. Although it is Turing-complete, Brainfuck's terse syntax makes it very challenging (and fun) to do anything meaningful with it.

Command Action
> increment pointer
< decrement pointer
+ increment data
- decrement data
, stdin (at current cell)
. stdout (at current cell)
[ if the current cell is 0, jump to the matching ]
] if the current cell is not 0, jump to the matching [

Brainfuck's memory model is an infinite tape of memory cells that each hold an integer in [0, 255]. Since Haskell's lazy evaluation makes infinite lists possible, the memory tape was implemented as an infinite zipper data structure. The interpreter dumps the state of memory at the end of execution, and in debug mode, the interpreter will dump memory after each instruction execution.

Usage

Building

Make sure you have GHC installed, and run ghc -o brainfuck interpreter.hs to build.

Running a program from source file

./brainfuck -f <filename.bf>

Running a program from command line

./brainfuck <program>

Running in debug mode

Debug mode dumps the state of memory after each instruction execution. ./brainfuck <program> -d" or ./brainfuck -f <filename.bf> -d

About

A small interpreter for the Brainfuck language written in Haskell.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published