aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-11-19 09:47:46 -0500
committerGravatar Peter McGoron 2024-11-19 09:47:46 -0500
commit3a716bb7004af068f46b67cfa7b8a033931e151b (patch)
tree5067fea9dae6af0261c7c98dfe079e076611cecc /README.md
parentbrainfuck->scheme (diff)
debugging
Diffstat (limited to 'README.md')
-rw-r--r--README.md14
1 files changed, 12 insertions, 2 deletions
diff --git a/README.md b/README.md
index c507d0c..3036594 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,22 @@
# Brainfuck2Scheme
A simple compiler from Brainfuck to R5RS. The compiler will output a Scheme
-list that is a lambda with two arguments:
+list that is a lambda with three arguments:
* `data`: The data vector.
* `dptr`: The initial data pointer.
+* `debugger`: Debugger function
To turn the list into an executable Scheme function, just give it to
-`eval`.
+`eval`. `(execute scheme len)` will run the Scheme code in `scheme`
+with a data vector of length `len`.
+
+This dialect of Brainfuck supports `#` to call the `debugger` procedure
+with `data` and `dptr` as arguments.
+
+Since Brainfuck programs become Scheme procedures, you can modularize
+Brainfuck code and (ab)use the debugger for things like procedure calls
+and foreign libraries.
## How It Works
@@ -24,6 +33,7 @@ Data access brainfuck instructions are translated like
* `<` -> `(set! dptr (- dptr 1))`
* `.` -> `(display (vector-ref data dptr))`
* `,` -> `(vector-set! data dptr (read-char))`
+* `#` -> `(debugger data dptr)`
Branches are trickier. Basically, all code that will be executed in a block
is in a lambda. Given `[code...]`, the `code...` will be compiled to a