next up previous contents
Next: Comments Up: Lexical Structure Previous: Integers, Identifiers, and Special   Contents

Strings

Strings are enclosed in double quotes "...". Within a string, a sequence `\c' denotes the two characters `\' and `c', with the exception of the following:

$\rm\backslash t$ tab
$\rm\backslash n$ newline


The two-character sequences \n and \t are called escape sequences. Other escape sequences like \r (carriage return) are not part of Cool. These two special escape sequences should not be interpreted or transformed by the lexer; they are handled by the IO module and the run-time system.

A newline character may not appear in a string:

"This is not
OK"
A string may contain embedded double quotes, so long as they are escaped. The following is a valid Cool string:
"David St. Hubbins said, \"It's such a fine line between stupid, and clever.\""

A string may not contain EOF; strings cannot cross file boundaries. A string may not contain NUL, the character with ASCII value 0. The lexer must reject source text that contains malformed strings.

A string may contain the two-character sequence \0, but the single character with converted integer value zero (the NUL) is not allowed. Any other character may be included in a string.