This repository contains two different Brainfuck interpreters written in OCaml:
- A Naive Brainfuck Interpreter that simply follows the rules of the language directly.
- An Optimized Brainfuck Interpreter that includes intermediate representation and optimizations.
The Naive Brainfuck Interpreter executes the Brainfuck program directly according to the rules without any optimization or intermediate representation. It is simple to understand but inefficient.
The Optimized Brainfuck Interpreter works by first converting the Brainfuck program into an intermediate representation, which is then executed. This representation reduces redundant operations (such as set a cell to a certain value), resulting in better performance.
You can run the interpreter by either providing a filename with the Brainfuck code:
./interpreter filename.bf
or by passing the Brainfuck source code directly as a command-line argument:
./interpreter "source_code"