go-brainfuck-yourself

A Brainfuck interpreter that I wrote myself in Go
git clone git@abtrout.com:go-brainfuck-yourself.git
Log | Files | Refs | README

README.md (1167B)


      1 # `gbfy`
      2 
      3 A [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) interpreter that I wrote myself in Go. 
      4 
      5 It can run programs in files and read binary input data for those programs to consume.
      6 
      7 
      8 ```
      9 $ ./gbfy --help
     10 Usage of ./gbfy:
     11   -d string
     12         Path to file containing input data for program
     13   -f string
     14         Path to Brainfuck program to execute
     15   -i    Launch interactive interpreter before exit
     16 $ cat test_sum.bf 
     17 ## Reads 2 bytes of input and adds them together
     18 ,>,<[->+<]>.
     19 $ hexdump -C input.bytes 
     20 00000000  01 02                                             |..|
     21 00000002
     22 $ ./gbfy -d input.bytes -f test.bf
     23 2024/01/02 05:22:36 Output from execution: [3]
     24 ```
     25 
     26 It can also run commands that are piped, and be used as an interactive REPL.
     27 
     28 ```
     29 $ echo "+>++<[->+<]>." | ./gbfy -i
     30 2024/01/02 05:23:25 Starting interactive REPL ...
     31 Go Brainfuck Yourself!
     32  :d[ump] to dump interpreter state
     33  :f[uck] to reset interpreter state
     34  :q[uit] to exit REPL loop
     35 gbfy> :d
     36 CELLS d:   1, current cell value: 3
     37 CMDS  i:  13, current command: '.'
     38 OUT   [3]
     39 gbfy> ++++.
     40 gbfy> :d
     41 CELLS d:   1, current cell value: 7
     42 CMDS  i:  18, current command: '.'
     43 OUT   [3 7]
     44 gbfy> 
     45 ```