commit 95adca93024128834464c55876fda58676697b23
parent a2f90706e8525a8187835bc566f3f22b378c6c27
Author: david cochran <about.trout@gmail.com>
Date: Tue, 2 Jan 2024 05:24:53 -0800
update README with examples
Diffstat:
| M | README.md | | | 52 | ++++++++++++++++++++++++++++++++++------------------ |
1 file changed, 34 insertions(+), 18 deletions(-)
diff --git a/README.md b/README.md
@@ -2,29 +2,44 @@
A [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) interpreter that I wrote myself in Go.
+It can run programs in files and read binary input data for those programs to consume.
+
```
-$ cat test.bf
-,>,<[>+<-]>.
-$ hexdump -C input.bytes
+$ ./gbfy --help
+Usage of ./gbfy:
+ -d string
+ Path to file containing input data for program
+ -f string
+ Path to Brainfuck program to execute
+ -i Launch interactive interpreter before exit
+$ cat test_sum.bf
+## Reads 2 bytes of input and adds them together
+,>,<[->+<]>.
+$ hexdump -C input.bytes
00000000 01 02 |..|
00000002
-$ ./gbfy -f test.bf -i input.bytes -repl
-2023/12/02 18:41:06 Output from execution: [3]
-2023/12/02 18:41:06 Starting interactive REPL
-Welcome!
- :q[uit] to exit REPL loop
+$ ./gbfy -d input.bytes -f test.bf
+2024/01/02 05:22:36 Output from execution: [3]
+```
+
+It can also run commands that are piped, and be used as an interactive REPL.
+
+```
+$ echo "+>++<[->+<]>." | ./gbfy -i
+2024/01/02 05:23:25 Starting interactive REPL ...
+Go Brainfuck Yourself!
:d[ump] to dump interpreter state
:f[uck] to reset interpreter state
+ :q[uit] to exit REPL loop
gbfy> :d
-cmds: ",>,<[>+<-]>."
-i: 12, current cmd: '.'
-cells: [0 3 0 0 0 0 0 0 0 0]
-d: 1, current cell: 3
-gbfy> +++++
+CELLS d: 1, current cell value: 3
+CMDS i: 13, current command: '.'
+OUT [3]
+gbfy> ++++.
gbfy> :d
-cmds: ",>,<[>+<-]>.+++++"
-i: 17, current cmd: '+'
-cells: [0 8 0 0 0 0 0 0 0 0]
-d: 1, current cell: 8
-```
+CELLS d: 1, current cell value: 7
+CMDS i: 18, current command: '.'
+OUT [3 7]
+gbfy>
+```
+\ No newline at end of file