GithubHelp home page GithubHelp logo

matteocampinoti94 / brainfuck-interpreter Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 39 KB

Small brainfuck interpreter written in C++

License: GNU General Public License v3.0

C++ 86.49% Brainfuck 13.51%
brainfuck-interpreters brainfuck cpp

brainfuck-interpreter's Introduction

brainfuck-interpreter

Small brainfuck interpreter written in C++

COMPILING

Only requirements to compile the program are a C++11 compiler and Linux system. g++ std=c++11 main.cpp parser.cpp interpreter.cpp functions.cpp

USAGE

binary [OPTIONS -pn] [FILE]

Options: -p : Plain text output. The interpreter output won't contain bold characters -n : No output. The interpreter will not output the content of the used cells at each instruction run.

Both options and file can be omitted.

If options are omitted the interpreter will run outputting the content of the used cells for each instruction run. The current evaluated cell will be written in bold. If the current instruction is a print . then the output will be showed beside the cells. Only ASCII values from 33 to 255 (127 DEL excluded) will be shown as characters, the others will be shown with their integer value.

If the file is omitted the interpreter will ask the user to input the code directly. In this mode the only recognized instructions are brainfuck standards and @

To stop the program at input (for example in cat programs ,[.,]) the user can type !@. If need to input !@ the user can type \!@ and keep adding \ to consider them as input (e.g. \\\\!@ will output \\\!@)

CODE

The interpreter follows brainfuck original standard.

Symbol Instruction
> Move to cell on the right (pointer ++)
< Move to cell on the left (pointer --)
+ Increment the value of the current cell
- Decrement the value of the current cell
. Output the character signified by the current cell
, Input a character and store it in the current cell
[ Jump past the matching ] if the current cell is 0
] Jump back to the matching [ if the current cell is not zero

It uses 8bit cells in an array of 30000 cells. Wrapping of the array and cells is implemented.

The following extra symbols are also recognized:

Symbol Instruction
! or # Consider the line as comment
@ Terminate execution here

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.