katana.units.esoteric.brainfuck
— Brainfuck¶
Unit for brainfuck esoteric language.
Given target data, this unit will ignore everything that is NOT valid Brainfuck characters and exclude them.
This unit includes a evaluate_brainfuck
function that is often
used by other units like Ook and Pikalang.
-
class
katana.units.esoteric.brainfuck.
Unit
(manager: katana.manager.Manager, target: katana.target.Target) Bases:
katana.unit.Unit
-
GROUPS
= ['esoteric', 'brainfuck'] These are “tags” for a unit. Considering it is a Esoteric unit, “esoteric” is included, as well as the unit name “brainfuck”.
-
PRIORITY
= 50 Priority works with 0 being the highest priority, and 100 being the lowest priority. 50 is the default priorty. This unit has a defualt priority.
-
evaluate
(case: Any) → None Evaluate the target. Run the target as Brainfuck code and give the standard output results to Katana.
Parameters: case – A case returned by enumerate
. For this unit, theenumerate
function is not used.Returns: None. This function should not return any data.
-
-
katana.units.esoteric.brainfuck.
buildbracemap
(code: bytes) → dict This is used for the Brainfuck operations. It will match opening and closing braces for use within the Brainfuck program.
Parameters: code – A byte string of the Brainfuck code. Returns: a bracemap dictionary
-
katana.units.esoteric.brainfuck.
cleanup
(code: bytes) → str This is used for the Brainfuck operations. It will clean the provided code to only find the appropriate Brainfuck operators.
Parameters: code – A byte string of the Brainfuck code. Returns: Only the bytes of appropriate Brainfuck operators.
-
katana.units.esoteric.brainfuck.
evaluate_brainfuck
(code: bytes, input_file, timeout: int = 1) This function actually runs the provided Brainfuck operations and returns the standard output.
Parameters: - code – The code to run as Brainfuck.
- input_file – A file to for the Brainfuck program to read as standard input. If this is not provided, it will yield a newline.
- timeout – A timeout value in seconds. After this time has elapsed, the Brainfuck code will stop executing.
Returns: The standard output for the Brainfuck program.