Git Product home page Git Product logo

bfint's Introduction

bfint

Simple interpreter for brainfuck

Usage

To set up, run:

$ mkdir bin/ && make compile

This will create the main executable under ./bin/compile. Then, interpret your code with:

$ ./bin/compile your_code.bf

Examples

There are some examples under input/ you can try out (some stolen from wikipedia).

Add two numbers

Here's a program that adds 6 to 3 and outputs the result:

$ cat input/add_nums.bf
+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++<[->+<]>.

Breakdown: we do 51 increments to get to ASCII '3', then 6 increments in the next slot to get to 6 (decimal). So our memory looks like:

data     51 6
location 0  1

Then we enter a loop, continuously decrementing at location 0 and incrementing at location 1 until location 0 is 0 (char \0), at which point location 1 should have '9'.

$ ./bin/compile ./input/add_nums.bf
9

Print "hello world"

Another program that prints "hello world" - this one's a bit harder to trace through.

$ ./bin/compile input/hello_world.bf
H
e
l
l
o

W
o
r
l
d
!

User input

Prompt user for 5 input characters and echos it back to you:

$ ./bin/compile input/user_in.bf
a
b
c
d
e

a
b
c
d
e

bfint's People

Contributors

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