Atoms Next: An Example Up: Basic InstructionsPrevious: Parallelism

Atoms

The Atom  abstract class extends Instruction and defines reactive instructions that execute an action and terminate immediately.

abstract public class Atom extends Instruction
{
  abstract protected void action(Machine machine);

  final protected byte activation(Machine machine)
  {
      action(machine);
      return TERM;
  }
}

PrintAtom  extends Atom to print strings.

 
public final class PrintAtom extends Atom
{
  private String msg;
  public PrintAtom(String msg) { this.msg = msg; }

  final public String toString(){ 
    return "System.out.print(\"" + msg + "\");"; 
  }

  final protected void action(Machine machine){ 
     System.out.print(msg); 
  }
}