Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.

2.6. String Literals


A string literal is formed by a sequence of graphic characters (possibly none) enclosed between two quotation characters used as string brackets.

    string_literal ::= "{graphic_character}" 

A string literal has a value that is a sequence of character values corresponding to the graphic characters of the string literal apart from the quotation character itself. If a quotation character value is to be represented in the sequence of character values, then a pair of adjacent quotation characters must be written at the corresponding place within the string literal. (This means that a string literal that includes two adjacent quotation characters is never interpreted as two adjacent string literals.)

The length of a string literal is the number of character values in the sequence represented. (Each doubled quotation character is counted as a single character.)


    "Message of the day:"   

    ""                     --  an empty string literal
    " "   "A"   """"       --  three string literals of length 1 

    "Characters such as $, %, and } are allowed in string literals"                                                   


A string literal must fit on one line since it is a lexical element (see 2.2). Longer sequences of graphic character values can be obtained by catenation of string literals. Similarly catenation of constants declared in the package ASCII can be used to obtain sequences of character values that include nongraphic character values (the so-called control characters). Examples of such uses of catenation are given below:

    "sequence that includes the" & ASCII.ACK & "control character" 

References: package, catenation operation, character value, constant, declaration, end of a line, graphic character, lexical element.

Rationale references: 2.1 Lexical Structure

Style Guide references: 2.1.1 Horizontal Spacing, 2.1.2 Indentation, 2.1.4 Alignment of Declarations, 3.2.5 Constants and Named Numbers


[Ada Information Clearinghouse]

Address any questions or comments to