morey.spore
Class SporeAction
java.lang.Object
|
+--morey.spore.SporeAction
- Direct Known Subclasses:
- Claim, Exist, Flip, Left, Repeater, Right, Sequence, Spawn, Type
- public abstract class SporeAction
- extends java.lang.Object
- implements java.lang.Cloneable
The actions are closely tied to Processor but all of the
functionality the real action will be in the subclasses. The parsing is a
ugly but I believe that is unavoidable.
Here
is a link to the source code
- See Also:
Processor,
Left,
Right,
Claim,
Flip,
Spawn,
Repeater,
Sequence
|
Method Summary |
static void |
addSpore(javax.swing.tree.DefaultMutableTreeNode root,
Spore spore)
|
protected static void |
addSporeCommands(javax.swing.tree.DefaultMutableTreeNode root,
java.util.Stack commands,
java.lang.String pad)
|
boolean |
executeAction(Spore s,
Processor cpu)
Do nothing |
abstract double |
getExecutionTime(Spore s,
Processor cpu)
sets up the time of execution for the next command. |
static int |
parseCommand(java.io.StreamTokenizer stream,
java.util.Stack stack)
procedure helps parse a program (and a list of commands) |
static Spore |
parseSpore(java.io.StreamTokenizer stream)
turn the String code into the proper Spore template (stack form). |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
NO_COMPLEXITY
public static final int NO_COMPLEXITY
SporeAction
public SporeAction()
getExecutionTime
public abstract double getExecutionTime(Spore s,
Processor cpu)
- sets up the time of execution for the next command.
- Parameters:
s - the spore wanting to execute the actioncpu - that executes this action (and required info...)
executeAction
public boolean executeAction(Spore s,
Processor cpu)
- Do nothing
- Parameters:
s - the spore wanting to execute the actioncpu - that executes this action (and required info...)- Returns:
- true
parseSpore
public static Spore parseSpore(java.io.StreamTokenizer stream)
throws BadSporeCodeException
- turn the String code into the proper Spore template (stack form).
c:= Right | Left | Flip | Spawn arg | Claim | { Sequence } | number c
Sequence := c | c Sequence
- Parameters:
s - the String containing the program- Returns:
- the Spore template that the String defines
- Throws:
- BadSporeCodeException - is thrown when it has trouble parsing
the code
parseCommand
public static int parseCommand(java.io.StreamTokenizer stream,
java.util.Stack stack)
throws BadSporeCodeException,
java.io.IOException
- procedure helps parse a program (and a list of commands)
- Parameters:
stream - the source to be parsedstack - the place for the parsed SporeActions- Returns:
- the complexity of the List (Sequence of SporeActions)
- Throws:
- BadSporeCodeException - is thrown when it has trouble parsing
the code
addSpore
public static void addSpore(javax.swing.tree.DefaultMutableTreeNode root,
Spore spore)
addSporeCommands
protected static void addSporeCommands(javax.swing.tree.DefaultMutableTreeNode root,
java.util.Stack commands,
java.lang.String pad)