📇 BF interpreter
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
etc
src
test
.gitignore
LICENSE
README.md
setup.py

README.md

pynterpreter

forthebadge made-with-python

Brainfuck interpreter in Python3.X

about this interpreter

Brainfuck

You can use this interpreter to run 'classic' brainfuck, which means use those 8 instructions: + - > < [ ] . and ,. All other symbols will be considered as comments.

If you never heard of brainfuck, you can start now here.

changes

pynterpreter brings one new operation symbol. When the debug mode is activated (see CLI example bellow), use % to print your cells while running a code.

For example, this code:

++%+++%

will result as:

pynterpreter> ++%+++%
| [2] | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| [5] | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
pynterpreter> 

pynterpreter usage

For simplicity, I strongly recommend you to set an alias into your bash.rc:

alias brainfuck='path/src/brainfuck.py'

from a source file

~$ python3 path/src/brainfuck.py -f etc/hello_world.bf
Output:
    Hello World!
Finished in 0.003 ms.

raw code as parameter

~$ python3 path/src/brainfuck.py -c "+++[>++++++++++<-]>+++."
Output:
    !
Finished in 0.002 ms.

cli

CLI example

improvements

  • arg parser for source file
  • better exception/error handling
  • comments
  • debug symbol
  • debug status in spec for CLI
  • interpreter in CLI
  • nested loops
  • unit testing

contributions

All contributions are welcome !