separate (AdaDoc)

function Read_Tags_File (File_Name : String) return Dict_TDA.Dict_Type is

   File : FIle_Type;
   Dico_Tags : Dict_TDA.Dict_Type;

   Tags_File_Error : exception;
   Tags_File_Format_Error : exception;

   --The tag in the spec
   Tag :  Unbounded_String;

   --How to show the tag in the documentation
   Tag_Out : Unbounded_String;

   --Buffer
   Char : Character;


begin

   Open(File, In_File, File_Name);

   while not End_Of_File(File) loop

      Tag := Null_Unbounded_String;
      Tag_Out := Null_Unbounded_String;

      --Empty the space before the tag
      loop
         Get(File, Char);
         exit when Char = '@';
      end loop;

      --Read the tag
      loop
         Get(File, Char);
         exit when char = ' ';
         Tag := Tag & Char;
      end loop;

      --Read the Tag_Out
      loop
         Get(File, Char);
         exit when char = ';';
         Tag_Out := Tag_Out & Char;
      end loop;

      --Put the tag in the dico
      Dict_TDA.Insert(Dico_Tags, To_String(Tag), To_String(Tag_Out));

      --To the next line one tag per line only
      Skip_Line(File);
   end loop;
   Close(File);

   return Dico_Tags;

exception

   when Name_Error  =>

      Put_Line("File adadoc_tags.cfg not found, using default tags");

      --Default tags
      Dict_TDA.Insert(Dico_Tags, "author", "Author");
      Dict_TDA.Insert(Dico_Tags, "date", "Date");
      Dict_TDA.Insert(Dico_Tags, "brief", "Description");
      Dict_TDA.Insert(Dico_Tags, "version", "Version");
      Dict_TDA.Insert(Dico_Tags, "revision", "Revision");
      Dict_TDA.Insert(Dico_Tags, "filename", "File name");
      return Dico_Tags;

   when End_Error => raise Tags_File_Format_Error;

end Read_Tags_File;

   