smithers.extras
Class Brainfuck

java.lang.Object
  extended by smithers.extras.Brainfuck
All Implemented Interfaces:
java.lang.Runnable

public class Brainfuck
extends java.lang.Object
implements java.lang.Runnable

Implementer for the brainfuck programming language. This implementation defaults to the following:
The program is 30000 chars, the memory is 30000 bytes. The program is read from a file, input and output are on System.in and System.out. The data cells are 1 byte in size, and wrap around.
This version adds an extra command, '#', which dumps the memory to output in hexadecimal.
Some of the previous can be changed however. See the contructor documentation for details.


Constructor Summary
Brainfuck(int progLen, int dataLen, boolean useDump, java.lang.String sourceFile)
          Creates a new instance with the program from a file and some of the options changed.
Brainfuck(java.lang.String sourceFile)
          Creates a new instance with the program from a file.
 
Method Summary
static void main(java.lang.String[] args)
          Main method, evaluates the arguments and runs the program in the specified file.
 void run()
          Runs the program until it finishes.
 void step()
          Executes a single step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Brainfuck

public Brainfuck(int progLen,
                 int dataLen,
                 boolean useDump,
                 java.lang.String sourceFile)
          throws java.io.IOException
Creates a new instance with the program from a file and some of the options changed.

Parameters:
progLen - the length of the program array
dataLen - the length of the data array
useDump - whether to use '#' to dump the data array
sourceFile - the file to read the program from
Throws:
java.io.IOException

Brainfuck

public Brainfuck(java.lang.String sourceFile)
          throws java.io.IOException
Creates a new instance with the program from a file.

Parameters:
sourceFile - the file to read the program from
Throws:
java.io.IOException
Method Detail

run

public void run()
Runs the program until it finishes.

Specified by:
run in interface java.lang.Runnable

step

public void step()
Executes a single step.


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Main method, evaluates the arguments and runs the program in the specified file. The arguments are as follows:

Argument Meaning
-pN Sets the length of the program array to N.
-dN Sets the length of the data array to N.
--nodump Turns off the use of '#' to dump the data array.
(Anything else) Sets the file name.

Parameters:
args - the arguments
Throws:
java.io.IOException