Skip to content

kode-tar-gz/bfi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple brainfuck interpreter

bfi is a simple brainfuck interpreter, created as an experiment in interpreter and compiler design.

bfi is intended not as a stand-alone application, but as a building block for an eventual compiler. It parses the entire source and creates an Intermediate Representation before interpreting said IR, as a compiler would. It implements simple peephole optimizations (truncating repeated + and - operations) and "brief format" error messages (the same format used in gcc and other compilers, for compatibility with Emacs' compilation-mode.

Compilation

bfi is written as a single file of pure C, and depends only on libc. Thus, all you need to build it is a C compiler and make. For a regular build, simply run:

make

For a build that logs the Intermediate Representation array to a file for debugging, run:

make debug_ir

The debug log file will be automatically created as "ir.log" if it doesn't already exist. By default, it will be created in the working directory. To change that, alter LOGPATH in main.c to your directory of choice.

Usage

Simply run:

bfi -f file.bf

where file.bf is your Brainfuck source file. For an example Hello World program, use the provided hello.bf file. For verbose output, add the -v argument.

About

Simple brainfuck interpreter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors