Git Product home page Git Product logo

brainfuch's Introduction

Brainfuch - A Haskell Brainfuck interpreter

Brainfuch is a Brainfuck interpreter library written in Haskell shipped with different executable interpreters.

CURRENT FLAWS:

  • None known :P

Note: Stack means here the virtual tape used by Brainfuck; a piece of Brainfuck code is called script.

BFexec

The standard interpreter. Reads code, evaluates it, prints any outputs made by the program and the final state of the stack.

Example session, interpretation only (text after # is a comment):

++>-->,. # User input
[EOF]; Interpreting code
78 # User input
78 # The script's output
Current stack:
([2,-2],78,[])

BFdbg

BFdbg not only evaluates a script but also prints every step made on the way to the final result.

Columns: <Command> <Stack after this command>

Stack format: [x] = inactive cell; {x} = current cell

Example session, with debugging (text after # is a comment):

++>-->,.><<< # Code from stdin

Output of script:
99 # User input
99 # Script output

Stack states during interpretation:
   {0}
+  {1}
+  {2}
>  [2]{0}
-  [2]{-1}
-  [2]{-2}
>  [2][-2]{0}
,  [2][-2]{99}
.  [2][-2]{99}
>  [2][-2][99]{0}
<  [2][-2]{99}[0]
<  [2]{-2}[99][0]
<  {2}[-2][99][0]

BFdbgIA

BFdbgIA stands for "BrainFuck DeBuGger InterActive". That means the interpreter prints the successive steps not as a list as BFdbg does but sequentially on one line which is updated every second.

++++[>++++<-]

Output of script:


Stack states during interpretation:
+  [4]{2}   (/)

and a second later

++++[>++++<-]

Output of script:


Stack states during interpretation:
+  [4]{3}   (-)

(looks a bit like what wget does)

BFdbgBreakpoint

This version uses the new symbol '|' to set breakpoints at which the current state is saved and printed after execution:

++++|[>+>+<<-|]

Output of script:


Stack states during interpretation:
{4}
{3}[1][1]
{2}[2][2]
{1}[3][3]
{0}[4][4]

brainfuch's People

Contributors

dermesser avatar

Watchers

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