with Io;
with Mapping_Context;
with Directory_Tools;
procedure Form_Abbreviation (Abbreviation : in String := "";
                             Full_Name : in String := "") is
    --
    Abbrev_File : Io.File_Type;
    --
    Object : Directory_Tools.Object.Handle :=
       Directory_Tools.Naming.Resolution (Full_Name);
    --
    Simple_Chars : array (Character) of Boolean := (Ascii.Nul .. '/' => False,
                                                    '0' .. '9' => True,
                                                    ':' .. '@' => False,
                                                    'A' .. 'Z' => True,
                                                    '[' .. '`' => False,
                                                    'a' .. 'z' => True,
                                                    '{' .. Ascii.Del => False);
    --
    function Is_Simple (This_Name : in String) return Boolean is
        --
        Result : Boolean := True;
        --
    begin
        for Current_Character in This_Name'First .. This_Name'Last loop
            if (not Simple_Chars (This_Name (Current_Character))) then
                Result := False;
                exit;
            end if;
        end loop;  
        return (Result);
    end Is_Simple;
    --
begin
    if (Directory_Tools.Object.Is_Bad (Object)) then
        Io.Put_Line (Io.Current_Error,
                     "Unable to resolve '" & Full_Name & "'.");
    elsif (not Is_Simple (Abbreviation)) then
        Io.Put_Line (Io.Current_Error, "Abbreviation is not simple name.");
    else
        Io.Create (Abbrev_File, Io.Out_File, Mapping_Context & Abbreviation);
        Io.Put_Line (Abbrev_File, Directory_Tools.Naming.Full_Name (Object));
        Io.Close (Abbrev_File);
        Io.Put_Line (Io.Current_Error, "Abbreviation formed successfully.");
    end if;
end Form_Abbreviation;
