Last active
June 3, 2017 19:42
-
-
Save FlorianCassayre/25235cb21fc6b5202c33574bbe8b6bb5 to your computer and use it in GitHub Desktop.
A basic Brainf*** interpreter in java (with uncensored class names).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum BrainfuckInstruction | |
{ | |
INCREMENT('+'), | |
DECREMENT('-'), | |
CURSOR_RIGHT('>'), | |
CURSOR_LEFT('<'), | |
LOOP_START('['), | |
LOOP_END(']'), | |
INPUT(','), | |
OUTPUT('.'); | |
private final char character; | |
BrainfuckInstruction(char character) | |
{ | |
this.character = character; | |
} | |
public char getCharacter() | |
{ | |
return character; | |
} | |
@Override | |
public String toString() | |
{ | |
return Character.toString(character); | |
} | |
public static BrainfuckInstruction fromCharacter(char c) | |
{ | |
for(BrainfuckInstruction instruction : values()) | |
{ | |
if(instruction.character == c) | |
return instruction; | |
} | |
throw new IllegalArgumentException("Illegal character: " + (int) c); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class BrainfuckInterpreter | |
{ | |
private final BrainfuckInstruction[] program; | |
private final Map<Integer, Byte> memory = new HashMap<>(); | |
private final InputStream in; | |
private final OutputStream out; | |
private int pointer = 0; | |
private int cursor = 0; | |
public BrainfuckInterpreter(BrainfuckInstruction[] program, InputStream in, OutputStream out) | |
{ | |
if(!isValidBrainfuck(program)) | |
throw new IllegalArgumentException("Invalid Brainfuck"); | |
this.program = new BrainfuckInstruction[program.length]; | |
System.arraycopy(program, 0, this.program, 0, program.length); | |
this.in = in; | |
this.out = out; | |
} | |
public BrainfuckInterpreter(String string, InputStream in, OutputStream out) | |
{ | |
this(fromString(string), in, out); | |
} | |
public boolean isFinished() | |
{ | |
return pointer == program.length; | |
} | |
public void step() | |
{ | |
if(isFinished()) | |
throw new IllegalStateException("Program has already terminated"); | |
final BrainfuckInstruction instruction = program[pointer]; | |
switch(instruction) | |
{ | |
case INCREMENT: | |
increment(); | |
break; | |
case DECREMENT: | |
decrement(); | |
break; | |
case CURSOR_RIGHT: | |
cursor++; | |
break; | |
case CURSOR_LEFT: | |
cursor--; | |
break; | |
case INPUT: | |
assert in != null; | |
try | |
{ | |
final int read = in.read(); | |
if(read == -1) | |
throw new IllegalStateException("Nothing to read"); | |
setMemory((byte) read); | |
} | |
catch(IOException e) | |
{ | |
throw new IllegalStateException(e); | |
} | |
break; | |
case OUTPUT: | |
assert out != null; | |
try | |
{ | |
out.write(getMemory()); | |
out.flush(); | |
} | |
catch(IOException e) | |
{ | |
throw new IllegalStateException(e); | |
} | |
break; | |
case LOOP_START: | |
if(getMemory() == 0) | |
{ | |
int level = 1; | |
do | |
{ | |
pointer++; | |
final BrainfuckInstruction statement = program[pointer]; | |
if(statement == BrainfuckInstruction.LOOP_START) | |
level++; | |
else if(statement == BrainfuckInstruction.LOOP_END) | |
level--; | |
} | |
while(level != 0); | |
} | |
break; | |
case LOOP_END: | |
int level = -1; | |
do | |
{ | |
pointer--; | |
final BrainfuckInstruction statement = program[pointer]; | |
if(statement == BrainfuckInstruction.LOOP_START) | |
level++; | |
else if(statement == BrainfuckInstruction.LOOP_END) | |
level--; | |
} | |
while(level != 0); | |
break; | |
} | |
if(instruction != BrainfuckInstruction.LOOP_END) | |
pointer++; | |
} | |
public Map<Integer, Byte> dump() | |
{ | |
return new HashMap<>(memory); | |
} | |
public InputStream getInputStream() | |
{ | |
return in; | |
} | |
public OutputStream getOutputStream() | |
{ | |
return out; | |
} | |
public void setMemory(int i, int b) | |
{ | |
memory.put(i, (byte) b); | |
} | |
private byte getMemory() | |
{ | |
final Byte b = memory.get(cursor); | |
if(b == null) | |
return 0; | |
return b; | |
} | |
private void setMemory(byte b) | |
{ | |
memory.put(cursor, b); | |
} | |
private void increment() | |
{ | |
byte b = getMemory(); | |
setMemory((byte) (b + 1)); | |
} | |
private void decrement() | |
{ | |
byte b = getMemory(); | |
setMemory((byte) (b - 1)); | |
} | |
private static boolean isValidBrainfuck(BrainfuckInstruction[] program) | |
{ | |
int opened = 0; | |
for(BrainfuckInstruction instruction : program) | |
{ | |
if(instruction == null) | |
return false; | |
if(instruction == BrainfuckInstruction.LOOP_START) | |
opened++; | |
else if(instruction == BrainfuckInstruction.LOOP_END) | |
{ | |
if(opened <= 0) | |
return false; | |
opened--; | |
} | |
} | |
return opened == 0; | |
} | |
@Override | |
public String toString() | |
{ | |
StringBuilder builder = new StringBuilder(); | |
for(BrainfuckInstruction instruction : program) | |
builder.append(instruction); | |
return builder.toString(); | |
} | |
public static BrainfuckInstruction[] fromString(String string) | |
{ | |
BrainfuckInstruction[] program = new BrainfuckInstruction[string.length()]; | |
for(int i = 0; i < program.length; i++) | |
program[i] = BrainfuckInstruction.fromCharacter(string.charAt(i)); | |
return program; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayInputStream; | |
public class Example | |
{ | |
public static void main(String[] args) | |
{ | |
final ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]); | |
final BrainfuckInterpreter interpreter = new BrainfuckInterpreter(MANDELBROT, in, System.out); | |
final long t0 = System.currentTimeMillis(); | |
long steps = 0; | |
while(!interpreter.isFinished()) | |
{ | |
interpreter.step(); | |
steps++; | |
} | |
final long t1 = System.currentTimeMillis(); | |
System.out.println("End."); | |
System.out.println("Execution of " + steps + " steps in " + (t1 - t0) + "ms."); | |
} | |
// Test program by Erik Bosman | |
private static final String MANDELBROT = ( | |
"+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[\n" + | |
">>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<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<<<<<\n" + | |
"<<<]>>>>>>>>-<<<<<[-]+<<<]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>->[>>>\n" + | |
">>>[->>+<<]>>>]<<<<<<<<<[>[-]<->>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<\n" + | |
"<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>\n" + | |
"+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+<\n" + | |
"<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<\n" + | |
"<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>\n" + | |
"-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>\n" + | |
">>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++\n" + | |
"+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<\n" + | |
"<<<<<]]>>>]").replace("\n", ""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment