com.github.bloodshura.sparkium.brainfxck.action.Action Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sparkium-brainfxck Show documentation
Show all versions of sparkium-brainfxck Show documentation
A highly extensible, simple interpreter for the Brainfuck language.
The newest version!
package com.github.bloodshura.sparkium.brainfxck.action;
import com.github.bloodshura.sparkium.brainfxck.BrainfuckContext;
import com.github.bloodshura.sparkium.brainfxck.BrainfuckInterpreter;
import javax.annotation.Nonnull;
import java.io.IOException;
/**
* This class represents a Brainfuck action, which can be executed by some form of input in Brainfuck code.
* Actions are always called and processed from a single input character.
*/
public interface Action {
/**
* Acts when the specified character is interpreted on a Brainfuck code.
*
Note: Implementations must return TRUE if the character were processed/consumed by this action, or FALSE if it wasn't.
*
* @param ch The current character
* @param context The current interpreter context
* @return boolean indicating if the character was processed or not
* @throws IOException If an I/O exception occurs on this action; the exception will be directly thrown
* on the {@link BrainfuckInterpreter#interpret(CharSequence)} method
*/
boolean act(char ch, @Nonnull BrainfuckContext context) throws IOException;
}