GithubHelp home page GithubHelp logo

goururk / brainfuck-interpreter Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 64 KB

Brainfuck interpreter made in C

License: GNU General Public License v3.0

C 97.68% Makefile 2.32%
brainfuck brainfuck-interpreter c

brainfuck-interpreter's Introduction

Brainfuck Interpreter


Brainfuck encoder, decoder and compiler made in C.

Install

To download the repo, you can either download the .zip file for this project, or use git commands as bellow :

git clone https://github.com/GouruRK/brainfuck-interpreter.git

Run

Compile it using the make command which produce "bin/brainfuck":

cd brainfuck-interpreter
make

Once compile, use the following command to show the runtime options

./bin/brainfuck --help

Such as bellow

Brainfuck interpreter

./brainfuck [OPTIONS ...] <FILE | INPUT>
        -d, --decode    Decode the brainfuck code to ASCII
        -e, --encode    Encode the ASCII input into brainfuck code
        -c, --compile   Compile the brainfuck code to C
        -h, --help      Print this message

Note

This program always print out in stdout. Remember that to create file with the output you can use redirections as explained below or chain programms using xargs
See in the Examples section

Examples

Remember that brainfuck only allow the following characters : '<', '>', ',', '.', '+', '-', '[' and ']'. Spaces and some other separators are allowed but skipped, as they don't belong to brainfuck's characters.

  • Encode
$ ./brainfuck -e "Hello World"
+++++++[>++++++++++<-]>++.<++[>++++++++++<-]>+++++++++.+++++++..+++.>+++[>++++++++++<-]>++.<+++++[>++++++++++<-]>+++++.<++[>++++++++++<-]>++++.+++.------.--------.
$ ./brainfuck -e examples/hello_world.txt
+++++++[>++++++++++<-]>++.<++[>++++++++++<-]>+++++++++.+++++++..+++.>+++[>++++++++++<-]>++.<+++++[>++++++++++<-]>+++++.<++[>++++++++++<-]>++++.+++.------.--------.
  • Decode
$ ./brainfuck -d "+++++++[>++++++++++<-]>++.<++[>++++++++++<-]>+++++++++.+++++++..+++.>+++[>++++++++++<-]>++.<+++++[>++++++++++<-]>+++++.<++[>++++++++++<-]>++++.+++.------.--------."
Hello World
$ ./brainfuck -d examples/hello_world.bf
Hello World
$ ./bin/brainfuck -e examples/hello_world.txt | xargs ./bin/brainfuck -d 
Hello World
  • Compile
$ ./brainfuck -c examples/hello_world.bf > temp.c
$ make temp
$ ./temp
Hello World

brainfuck-interpreter's People

Contributors

goururk avatar

Watchers

 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.