A string literal represents zero, two, or more characters and can take one of two different forms:
String literals can be formed by enclosing, the characters being represented, in single quotes. NOTE: Single quote characters, in string literals enclosed in single quotes, are represented by a pair of single quote characters. So
'Hello' represents the characters Hello
and
'Don''t' represents the characters Don't
String literals are case-sensitive so 'Hello' is not equal to 'hello'.
NOTE: In Standard Pascal (ISO/IEC 7185) string literals must be enclosed in single quotes (').
String Literals Enclosed By Double Quotes
String literals can be formed by enclosing, the character being represented, in double quotes. NOTE: Double quote characters, in string literals enclosed by double quotes, are represented as a pair of double quote characters. So
"Hello" represents the characters Hello
and
"""Hello""" represents the characters "Hello"
This second form of string literals, is an extension to Standard Pascal, and is provided mainly to make it easy to represent characters containing single quotes (i.e. you can enclose string literals containing single quotes with double quotes without using double single quotes like "'" instead of ''')'.
Examples
'' ' ' 'Don''t' 'Say "Hello"' '!@#$%^&*()'
"" " " "Don't" "Say ""Hello""" "!@#$%^&*()"
Syntax
string-literal = empty-string | non-empty-string
empty-string = '''' | '""'
non-empty-string =
''' string-element-one string-element-one { string-element-one } ''' |
'"' string-element-two string-element-two { string-element-two } '"'
printable-character = any character (including a space) that has a visual representation.
string-element-one = '''' | printable-character
string-element-two = '""' | printable-character
NOTE: The production for printable-character doesn't use the usual notation because: