Git Product home page Git Product logo

brainfuck-interpreter's Introduction

brainfuck-interpreter

Interpreter for the esoteric programming language, brainfuck.

What is Brainfuck?

Brainfuck is an esoteric programming language in which there is an array of ascii characters (with a size of at least 30,000 cells), and a pointer which can move from cell to cell one at a time. The pointer can also increment or decrement the values in each cell one at a time. The language consists of only 8 commands as follows:

Command Action
> move to next cell
< move to previous cell
+ increment the value of the current cell by 1
- decrement the value of the current cell by 1
. print the ascii character of the current cell to stdout
, get a character from stdin and store it in the current cell
[ if the current cell is 0, jump to the matching ]
] if the current cell is not 0, jump to the matching [

Note: My implementation of Brainfuck is memory safe. In other words, using < from cell 0 will wrap around to the last cell, and using > from the last cell will wrap around to the first cell, eliminating the possibility of dangling pointers.

If you would like to learn more about the brainfuck language, you can check out the esolangs wiki.

If you would like to try to master the language, feel free to build my interpreter on your system (instructions below) or try out this nifty brainfuck visualizer.

Language Extensions

The following are extra brainfuck commands added in my own language extension to brainfuck. These commands are not part of the core brainfuck language, and will not work in compilers or interpreters other than mine.

Command Action
! set the value of the current cell to 0
& move the pointer to the index in the tape defined by the value at the current cell
? output a debug message

Note: If you want to disable the language extensions, you can pass the -s or --strict flags to the interpeter when you run the program.

Flags

Flag Action
-s/--strict Disables the language extension, so only official bf commands work.

Build Instructions

$ git clone https://github.com/fabiocolacio/brainfuck-interpreter
$ cd brainfuck-interpreter
$ mkdir build
$ cd build
$ cmake ..
$ make

Installation Instructions

After building, run:

$ sudo make install

brainfuck-interpreter's People

Contributors

fabiocolacio avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.