with Source_Instrumenter_Declarations;
use Source_Instrumenter_Declarations;
with Parserdeclarations;

package Change_Text is
    --| Subprograms for the manipulation of source text

    --| Overview

    --| This package provides several subprograms which manipulate source text
    --| in various ways.
    --|
    --| Change_Case alters the case of the text passed in,
    --| Change_Sharp changes the extended delimiter character '#' to the basic
    --|     character ':' in the text of a based literal.
    --| String_Value returns the text of a string with the extended and basic
    --|     string delimiters represented appropriately within the string.

    package Pd renames Parserdeclarations;

    type Case_Name is (Uppercase, Lowercase);

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

    function Change_Case (Token_Text : Pd.Source_Text;     --| text to be changed
                          To_Case : Case_Name        --| case in which to
                                                     --| represent Token_Text
                          ) return String;
    --| Changes the case of Token_Text

    --| Effects

    --| The Token_Text is changed according to the To_Case passed in.  When
    --| To_Case is SID.Bold, the return value is the same as if lowercase
    --| had been requested.  The actual bold printing is handled in procedure
    --| Bold_Print rather than here for two reasons:
    --|
    --|      1.  Tokens which would ordinarily be bold printed should be only
    --|          lowercased when bold printing is selected with
    --|          Paginated_Format off.  This is to prevent control characters
    --|          from being inserted into a file which is supposed to be
    --|          valid Ada.
    --|
    --|      2.  In determining the length of a token for placement in the
    --|          output, control characters which have no printable form,
    --|          and therefore do not take up any columns on the page, should
    --|          not be counted.
    --|

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

    function Change_Sharp (Token_Text : Pd.Source_Text) return String;
    --| Changes the extended character '#' to the basic character ':'

    --| Effects

    --| This function changes all of the '#' characters in the passed-in
    --| Token_Text to ':' characters.  Its primary use should be for changing
    --| these characters in the text of a based literal.


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

    function String_Value (Token_Text : Pd.Source_Text) return String;
    --| Returns the correct text for a string, based on its delimiters

    --| Effects

    --| This function returns a string with the correct delimiters (basic
    --| or extended) and embedded delimiter characters represented correctly.
    --| For example, the input string "Here is a % character" when output
    --| with Basic Delimiters must be converted to %Here is a %% character"
    --| with the embedded delimiter character doubled.  This ensures that
    --| valid Ada strings are reproduced.

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

    function Convert_Periods_To_Underscores
                (Input_String : in String) return String;
    --| Effects
    --|
    --| This procedure will convert all periods in a string to underscores.

end Change_Text;