Package brainfuck
implements a Brainfuck interpreter in Go.
Default brainfuck interpreter implements 8 commands defined here wiki
but this library also provides a mechanism to add
/remove
commands.
brainfuck.AddInstruction(<instructionType>, <Handler to be executed>)
brainfuck.RemoveInstruction(<instructionType>)
$ go get github.com/shani1998/brainfuck
// create new io.Reader from inputs
code := strings.NewReader("++[>++.<-]>+")
// Standards interface to io
input := new(bytes.Buffer)
output := new(bytes.Buffer)
// initialize the brainfuck interpreter
bf := brainfuck.NewInterpreter(input, output)
// Store the result in output interface
_ = bf.Run(code)
// print the result
fmt.Println (output.String())
To run all tests in the root of the project
$ make test
To run cli that uses brainfuck library
$ make run-cli