- PHP: 7.4+
- Composer: 1.10+
- Download
- Run
composer install --no-dev
orcomposer install
if you want to run CI tools - Could also be used as dependency if needed
+
add 1 to the current register-
substract 1 from the current register>
move to the next register<
move to the prev register.
write current register value to output,
read current register value from output[
go into code if current value is not 0]
go to matching opening bracket if current value is not 0
- Write the brainfuck code Be creative or google for examples
$code = '...';
- Create the config
$config = new berbeflo\Brainfuck\Config();
- Create the interpreter and run it
$interpreter = new berbeflo\Brainfuck\Interpreter($code, $config);
$interpreter->execute();
The interpreter can be executed multiple times. It's also possible to change the values of the Config object between the executions. But not the code. For different code, create a different Interpreter instance.
setInputObject
define the object that provides the input values; has to implementberbeflo\Brainfuck\Definition\Input
setOutputObject
define the object that provides the output values; has to implementberbeflo\Brainfuck\Definition\Output
setMinRegisterValue
the default min value is0
setMaxRegisterValue
the default max value is255
setMinPointerValue
the minimum register address; default is0
setMaxPointerValue
the maximum register address; default is255
setMaximumIterations
prevent endless loops; default is255
setWrapOnRegisterOverflow
defaults tofalse
setWrapOnPointerOverflow
defaults tofalse
setAllowUnknownTokens
defaults totrue