Git Product home page Git Product logo

procedural-brainfuck's Introduction

procedural-brainfuck

Description

Version of brainfuck interpreter with procedures. Usual brainfuck description: https://en.wikipedia.org/wiki/Brainfuck
Tested only on Mac OS X Mojave.

Building it

$ ./build.sh all

Now the pbf interpreter should be inside of `bin/` directory.

Running your code

To run your code:

$ cd bin/ 
$ ./pbf path/to/your/code.pbf

Command table

Command Description
> Move array ptr right.
< Move array ptr left.
+ Add 1 to current array value
- Substract 1 from current array value
[ Begin loop
] End loop
! Exit procedure
?* ! if current value is 0
; States the end of name that should be called
, Read char from stdin
. Put char to stdout

* โ€“ Not yet tested

Procedures

Procedure contains some brainfuck code which will be executed when procedure called. Procedure name could containt letters, numbers and underscores. To call porcedure you should put it name and ; after it. Procedures could call other procedures. You are free to define procedure inside a loop, but this could lead to a severe memory leak.
Definition example:

procedure_name{...}

Call example:
procedure_name;

Arguments

General usage:
./bin/pbf [--help -h] <filename> [--security none|loop|die]

Argument Description
-h --help Display help message
<filename> Path to filename with code
--security <arg> Set security mode

Security mode

Security mode defines what to do when array index is out of range. To set a security mode put it's name after --security argument.

Mode Description
none Do none when program exceeds array size.
loop Cycle over array
die Print an error and exit

Hello, world!

Here is code of "Hello, world!" app with use of procdeures.

h{++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++
 .>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.
 ------.--------.>+.>.}h;

To test this code:

$ cd bin/
$ ./pbf ../examples/hello_world.pbf
Hello world!
$

You could check out some more examples here

ToDo

  • Implement server mode which will allow to put a sequence of files to run

procedural-brainfuck's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

procedural-brainfuck's Issues

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.