Skip to content

bmoneill/bfx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bfx: an interpreter, compiler, and REPL for brainfuck

CI status. clang-format status

This is an interpreter, compiler, and REPL for the Turing-complete esoteric programming language brainfuck, written in C89.

Building

Linux

cmake . -B build
cmake --build build

Usage

bfx [-cCdirsv] [-e eof_behavior] [-o output_file] [-t tape_size] [file]
  • -c: Compile to native binary.

  • -C: Compile to C.

  • -d: Print tape pointer, instruction pointer, and values of all previously accessed cells whenever a # is encountered.

  • -i: Separate code from input using !.

  • -r: Run in interactive REPL mode (can be reset with @ unless -s was provided).

  • -s: Disable interpretation of special characters (# and @).

  • -v: Print version information.

  • -e eof_behavior: Specify behavior when encountering EOF. Valid values are "zero" (the default, sets the current cell to zero), "decrement" (subtract one from the current cell), and "unchanged" (do not change the current cell).

  • -o output_file: Specify the output file (default: './a.out' for binaries, './a.out.c' for C source)

  • -t tape_size: Specify the size of the tape (default: 30000)

If file is not specified, bfx will read source code from standard input.

Screenshots

bfx running sierpinski.b

bfx sierpinski

Further Reading

Bugs

If you find a bug, submit an issue, PR, or email me with a description and/or patch.

License

Copyright (c) 2022-2025 Ben O'Neill ben@oneill.sh. This work is released under the terms of the MIT License. See LICENSE for the license terms.