--
-- @filename adadoc_tree-comment.ads
-- @author Julien Burdy & Vincent Decorges
-- @date 17.6.02
-- @brief Abstract machin to stock the comment
--
-- History  :
-- Date     Modification               Author
--
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Dict_TDA;

package AdaDoc_Tree.Comment is

   --The comment could be before instruction or after
   --!!After is not yet implemented!!
   type Mode_Type is (Before, After);

   --
   -- Purpose : Initalize the abstract machine
   --
   -- in      : Mode : Functional mode of the abstract machine
   --                  when before : the comment are before the instruction
   --                  when after : the comment are after the instuction
   -- in      : Dict_Tag : Dictonary of possible tags in the header
   -- in      : Extract : Try to extract only the header if false
   --
   procedure Init(Mode : in Mode_Type := Before;
                  Dict_Tag : Dict_TDA.Dict_Type;
                  Extract : Boolean := False);

   --
   -- Purpose : Add a comment to the buffer
   --
   -- in      : Item : String to add
   --
   procedure Add_To_Buffer (Item : in String);

   --
   -- Purpose : Clear the buffer
   --
   procedure Clear_Buffer;

   --
   -- Purpose : Call when an instruction occur
   --
   -- in      : Key : line where the occurance is
   --
   procedure Mark_Instruction (Key : String);

   --
   -- Purpose : True if a comment exist for the key
   --
   -- in      : Key : line where the occurance is
   -- return  : True if exist
   --
   function Exist (Key : String) return Boolean;

   --
   -- Purpose : Return the comment associate to the key
   --
   -- in      : Key : line where the occurance is
   -- return  : The comment
   --
   function Return_Comment (Key : String) return String;

   --
   -- Purpose : return the comment associate to the tags in the header
   -- return  : a dico with the comment associate to the tags
   --
   function Return_Header_Comment return Dict_TDA.Dict_Type;

   --
   -- Purpose : Clean the abstract machine
   --
   procedure Delete;

private

   type Object is tagged record

      Mode : Mode_Type := Before;

      Buffer : Unbounded_String := Null_Unbounded_String;
      --For General Comment
      Dict_Comment : Dict_TDA.Dict_Type;

      --For Header Comment
      Dict_Header : Dict_TDA.Dict_Type;

      --Tag To use
      Dict_Tag : Dict_TDA.Dict_Type;

      --The treatement is different if we are in the header
      --or not (tags possible in the header)
      In_Header : Boolean := True;

      --If false extract only the header
      Extract : Boolean;

      Current_Instruction_Line : Natural := 0;
   end record;

   --The main instance for the abstract machine
   Comment_Machine : Object;

end AdaDoc_Tree.Comment;