o
odin.langpkg.dev
packages / library / brainfuck

brainfuck

d06cbd3library

No description provided.

No license · updated 4 months ago

This is a general project for experimenting with brainfuck and Odin.
Right now, there's a compiler that transpiles brainfuck to fasm and a brainfuck interpreter repl that supports stepping by token, until next break (denoted by #), or until the end of the current loop.

There is also a brainfuck to fasm transpiler being built in brainfuck, that will be referred to as the brainfuck transpiler.

TODO:

  • support start_loop and end_loop tokens in brainfuck transpiler
  • POTENTIAL: we can potentially recreate the brainfuck repl in brainfuck too by manually feeding ansi codes to stdout (PAIN AHEAD)
  • POTENTIAL: optimize the brainfuck transpiler and the odin transpiler
    • tokenization step using a queue
    • collapse repeated <,>,-,+,,, and .
    • [-] -> and byte [rsp + rbx], 0
    • [->+<] and similar constructs to mov al, byte [rsp + rbx]; mov byte [rsp + rbx + 1], al or similar (essentially understanding duplicating/moving constructs)
  • provide more usability in the repl
    • more move commands
      • move by number
      • move until breakpoint (tries to center)
      • scroll by page or half page
      • scroll to min or max
    • fix "next loop" command so that it works at [ and not just the tokens after
    • multiple page help command to reduce message height
    • reload also retokenizing the file, allowing for hot reloading
    • allow for CTRL+C when repl requires input, so that you don't need a break before a looping read
    • allow for CTRL+0 (or some other key combo) to feed in a NULL Byte '\x00'
  • provide flags for interpret/repl mode vs compile mode, so we don't have to swap between main and main1
  • develop brainfuck based language brainhandholding (bhh): the usability of c with all the ergonomics and lovability of brainfuck