Skip to content

nsdigirolamo/nbi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nick's Brainfuck Interpreter (NBI)

An interpreter for brainfuck, the (in)famous esolang created by Urban Müller in 1993. This is meant to be a personal learning exercise so I can develop my understanding of how interpreters work. This interpreter has been tested on a variety of brainfuck source code files, and works without issue.

Language Design

brainfuck programs consist of eight instructions, which manipulate a sequential number of cells using a pointer. From Wikipedia:

Character Description
> Increment the data pointer by one (to point to the next cell to the right).
< Decrement the data pointer by one (to point to the next cell to the left).
+ Increment the byte at the data pointer by one.
- Decrement the byte at the data pointer by one.
. Output the byte at the data pointer.
, Accept one byte of input, storing its value in the byte at the data pointer.
[ If the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
] If the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.

Using the Interpreter

Prerequisites

First, ensure the following tools are installing on your machine:

  1. The GNU Compiler Collection
  2. GNU Make
  3. Git

Run the following in your terminal to clone this repository, navigate to its root directory, and compile nbi:

git clone https://github.com/nsdigirolamo/nbi.git && cd nbi && make

Running

After compiling nbi, you can run it on any file that contains brainfuck source code. Brainfuck source code typically uses the .b file extension:

./nbi samples/hello_world.b

References:

Releases

No releases published

Packages

 
 
 

Contributors