package rebelsky.pal;

import java.util.Vector;

/**
 * A sequence of instructions in the Pseudo-Assembly Language (pal).
 * These instruction sequences are intended to ease the construction
 * of programs.  You should flatten them (by shoving them in a machine)
 * before executing the program.
 *
 * @author Samuel A. Rebelsky
 * @version 1.0 of November 2002
 */
public class InstructionSequence
  implements Instruction
{
  // +--------+------------------------------------------------------------
  // | Fields |
  // +--------+

  /** The instructions within the sequence. */
  Vector instructions;


  // +--------------+------------------------------------------------------
  // | Constructors |
  // +--------------+

  /**
   * Create a new sequence of instructions.
   */
  public InstructionSequence() {
    instructions = new Vector();
  } // InstructionSequence()
  
  // +---------+-----------------------------------------------------------
  // | Methods |
  // +---------+

  /**
   * Add a new instruction to the sequence.
   */
  public void add(Instruction next) {
    this.instructions.add(next);
  } // add(Instruction)

  /** 
   * Execute the instruction on a machine. 
   *
   * @exception Exception
   *   All the time: Instruction sequences are for building programs,
   *   not for executing them.
   */
  public void execute(Computer hal) 
    throws Exception
  {
    throw new Exception("Cannot execute InstructionSequence instructions.");
  } // execute(Machine)

  /** Convert the instruction to a string (usually for printing). */
  public String toString() {
    return "<SEQUENCE>";
  } // toString()

} // class InstructionSequence

