--
-- @filename stack_asm.ads
-- @author Julien Burdy & Vincent Decorges
-- @date 10.4.02
-- @brief An Abstract State Machine of stack
-- History  :
-- Date     Modification               Author
--
generic

   --Type of the information in the stack
   type T_Information is private;

package Stack_ASM is

   type T_Stack is private;

   --An empty stack!
   Empty_Stack : constant T_Stack;

   --Add an element at the beginning of the stack
   --Stack_Full_Error is raise if the stack is full
   procedure Push (Element : in T_Information);

   procedure Pop;

   --Empty a stack
   procedure Empty;

   generic

      --Treatment to do
      with procedure Treat (Information : in T_Information);

   --Run through the stack and call treat for each Information
   procedure Run_Through;

   --Return true if the stack is empty
   function Empty return Boolean;

   --Return the length of the stack
   function Length return Natural;

   --Return the element at the head of the stack
   function Head return T_Information;

   --Return the element under head of the stack
   function Sub_Head return T_Information;

   Stack_Full_Error  : exception;
   Stack_Empty_Error : exception;

private

   --One element of the stack
   type T_Element;

   type T_Stack is access T_Element;

   type T_Element is
      record
         Information : T_Information;
         Next_Element: T_Stack;
      end record;

   Empty_Stack : constant T_Stack := null;

end Stack_ASM;
