with Lines;
with Bounded_String;
with List_Generic;
package body Structured_Comments_Solution is

    function Define (Keyword : Comment_Keyword) return Structured_Comment is
        S_Comment : Structured_Comment;
    begin
        Bounded.Copy (S_Comment.Keyword, Keyword);
        return S_Comment;
    end Define;

    function Keyword (Comment : Structured_Comment) return Comment_Keyword is
    begin
        return Bounded.Image (Comment.Keyword);
    end Keyword;

    function Value_Field (Comment : Structured_Comment)
                         return Lines.Lines_Type is
    begin
        return Comment.Value;
    end Value_Field;

    function Initialize return Comment_Block is
    begin
        return Comment_Block (Comment_List.Nil);
    end Initialize;

    procedure Add_Structured_Comment
                 (To : in out Comment_Block; Comment : Structured_Comment) is
        Local_List : Comment_Block := To;
    begin
        if Is_Empty (Local_List) then
            To := Comment_Block (Comment_List.Make (Comment, Comment_List.Nil));
        else
            while not Is_Empty (Rest (Local_List)) loop
                Local_List := Rest (Local_List);
            end loop;
            Set_Rest (Local_List,
                      Comment_Block (Comment_List.Make
                                        (Comment, Comment_List.Nil)));
        end if;
    end Add_Structured_Comment;

    procedure Initialize (Iter : out Comment_Iterator;
                          From_Block : Comment_Block) is
        Local_Iter : Comment_Iterator := new Comment_List.Iterator;
    begin
        Comment_List.Init (Comment_List.Iterator (Local_Iter.all),
                           Comment_List.List (From_Block));
        Iter := Local_Iter;
    end Initialize;

    function Done (Iter : Comment_Iterator) return Boolean is
    begin
        return Comment_List.Done (Comment_List.Iterator (Iter.all));
    end Done;

    function Value (Iter : Comment_Iterator) return Structured_Comment is
    begin
        return Comment_List.Value (Comment_List.Iterator (Iter.all));
    end Value;

    procedure Next (Iter : in out Comment_Iterator) is
    begin
        Comment_List.Next (Comment_List.Iterator (Iter.all));
    end Next;

    procedure Parse (Comment_Lines : Lines.Lines_Type;
                     Block : in out Comment_Block) is separate;
end Structured_Comments_Solution;