Skip to content

A functional Brainfuck interpreter written in Scala

License

Notifications You must be signed in to change notification settings

Mee-Tree/brainfuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brainfuck Scala CI

A simple Brainfuck interpreter implemented in Scala, built primarily for the purpose of trying out Scala CLI.

Usage

Running the Project

# Run the interpreter
scala-cli run . -- "program"

# Run tests
scala-cli test .

Example Programs

You can find example programs in the examples/ directory and run them using:

scala-cli run . -- "$(< path-to-example)"

All examples are sourced from wikipedia.org and brainfuck.org.

Commands

The language consists of eight single-character commands:

Command 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.

All other characters are ignored and can be used for comments.

About

A functional Brainfuck interpreter written in Scala

Resources

License

Stars

Watchers

Forks

Languages