package body Parserdeclarations is

    subtype Dump_String_Range_Plus_Zero is Standard.Natural range 0 .. 4000;

    Dump_String : String (1 .. Dump_String_Range_Plus_Zero'Last);

    Dump_String_Length : Dump_String_Range_Plus_Zero;
    -- must be set to zero before each use.

    ------------------------------------------------------------------
    -- Subprograms Local to Package ParserDeclarations
    ------------------------------------------------------------------

    procedure Append_To_Dump_String ( --| Add In_String to Dump_String
                                     In_String : in String --| String to append
                                     );

    --| Effects

    --| This subprogram appends In_String to the package Body global
    --| Dump_String.

    --| Modifies
    --|
    --| Dump_String
    --| Dump_String_Length

    ------------------------------------------------------------------
    -- Subprogram Bodies Global to Package ParserDeclarations
    -- (declared in package specification).
    ------------------------------------------------------------------

    function Get_Source_Text (In_Source_Text : in Source_Text) return String is

    begin

        if (In_Source_Text = Null_Source_Text) then
            return "";
        else
            return In_Source_Text.all;
        end if;

    end Get_Source_Text;

    ------------------------------------------------------------------

    procedure Put_Source_Text (In_String : in String;
                               In_Out_Source_Text : in out Source_Text) is

    begin

        In_Out_Source_Text := new String'(In_String);

    end Put_Source_Text;

    ------------------------------------------------------------------

    function Dump_Parse_Stack_Element
                (In_Pse : in Parsestackelement) return String is

        --| Notes

        --| Abbreviations used in this compilation unit
        --|
        --| PSE : ParseStackElement
        --|

    begin

        Dump_String_Length := 0;

        -- Output data common to all ParseStackElements
        Append_To_Dump_String ("Element Kind:  " &
                               Pt.Get_Grammar_Symbol (In_Pse.Gram_Sym_Val) & " "

                               -- give extra space to help highlight delimiters
                               );

        -- Output data common to all lexed_tokens
        Append_To_Dump_String
           (" Token - Line: " &
            Hd.Source_Line'Image (In_Pse.Lexed_Token.Srcpos_Line) &
            " Column: " &
            Hd.Source_Column'Image (In_Pse.Lexed_Token.Srcpos_Column));

        Append_To_Dump_String (" Text: %" &
                               Get_Source_Text (In_Pse.Lexed_Token.Text) & "%");

        -- Finally, finish up the message
        Append_To_Dump_String ("");

        return Dump_String (1 .. Dump_String_Length);

    end Dump_Parse_Stack_Element;

    ------------------------------------------------------------------
    -- Subprogram Bodies Local to Package ParserDeclarations
    ------------------------------------------------------------------

    procedure Append_To_Dump_String (In_String : in String --| String to append
                                     ) is

    begin

        Dump_String ((Dump_String_Length + 1) ..
                        (Dump_String_Length + In_String'Last)) := In_String;

        Dump_String_Length := Dump_String_Length + In_String'Length;

    end Append_To_Dump_String;

    ------------------------------------------------------------------

end Parserdeclarations;