Giter Site home page Giter Site logo

lillyprogrammingincorprated / brainfuck_but_useful Goto Github PK

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

This an interpreter for my own take on Brainfuck. It has all the usual Brainfuck stuff with the additions of cool stuff.

License: GNU Affero General Public License v3.0

C 100.00%

brainfuck_but_useful's Introduction

This is my take on brainfuck. It isn't anything special, it's just a general improvement to make it from a jokey challange language to an actually useful challange language. The added features are thus: 1- "If pointed cell nonzero" statements 2- File I/O 3- Generic I/O (as in, ability to input numbers as numbers and not as ASCII characters) 4- Functions with an optional argument 5- Error messages in case you fuck up

1- If statements: They work the same as the loops but instead of looping it executes the code it has in the block. It uses the '(' and ')' as its beginning and end respectively. EXAMPLE:

+(>++++++++++++++++++++++++++++++++++++++++++++++++++++++++.)
Output: 8

EXAMPLE 2:

(>++++++++++++++++++++++++++++++++++++++++++++++++++++++++.)
OUTPUT: NULL

2- File I/O: This allows for very basic file reading & writing as such: Open file with '%'. Second call of '%' closes the file. Use '^' to write the ASCII value of the current cell to the file and advance the position indicator for the stream. Use 'v' to get ASCII value of character from file & copy it to currently pointed cell, and advance the position indicator for the stream. EXAMPLE:

%
++++++++++++++++++++++++++++++++++++++++++++++++++++++++^>v.
%
OUTPUT: 8
FILE: 8

You have to add the location of the file as the second argument after the file you have your code in. EXAMPLE:

./BFI *brainfuck_file* *file_to_be_edited*

3- Generic I/O You can use ':' to print the numeric value of the currently pointed cell. You can use ';' to get the numeric value of user input EXAMPLE:

++++++++:
OUTPUT: 8

EXAMPLE 2:

;.
INPUT: 97
OUTPUT: a

4- Functions You can now make functions to be later called! You can only have 1 function at a time and can't overwrite it till called, and it can only be called once. This encourages thinking ahead and using functions only when absolutely necessary. (Also it fits BF's style, and it's much easier to code) To create a function, you use 'f'. Then, if you want it to take an argument, you put 'a' after it with no space between them. The argument it takes will be the cell pointed to. When it takes an argument, all operations that have to do with the tape will be done on the basis that it will start out with pointing to that cell. After f/fa you put '{' to start the block of code to be executed upon function call. If an accompanying '}' is not found, it will give an error. If any character is put between the 'a' or '{' then it will give a Syntax Error. EXAMPLE:

fa{+++++++++++++++++++++++++++++++++++++++++++++++++++.}
f
f{[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]}
f
f{
+++++++++++++++++++++++++++++++++++++++++++++++++.[-]}
f
OUTPUT: 3Z1

Installation & Use

gcc brainfuck.c -o BFI

./BFI filename.bf (optional) /file to be edited

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.