Tokens in Mercury are the same as in ISO Prolog. The only differences are the ‘#line’ token, which is used as a line number directive (see below) and the backquote (‘`’) token.
The different tokens are as follows. Tokens may be separated by whitespace or line number directives.
").
Within a string, two adjacent double quotes stand for a single double quote. For example, the string ‘ """" ’ is a string of length one, containing a single double quote: the outermost pair of double quotes encloses the string, and the innermost pair stand for a single double quote.
Strings may also contain backslash escapes. ‘\a’ stands for “alert” (a beep character), ‘\b’ for backspace, ‘\r’ for carriage-return, ‘\f’ for form-feed, ‘\t’ for tab, ‘\n’ for newline, ‘\v’ for vertical-tab. An escaped backslash, single-quote, or double-quote stands for itself.
The sequence ‘\x’ introduces a hexadecimal escape; it must be followed by a sequence of hexadecimal digits and then a closing backslash. It is replaced with the character whose character code is identified by the hexadecimal number. Similarly, a backslash followed by an octal digit is the beginning of an octal escape; as with hexadecimal escapes, the sequence of octal digits must be terminated with a closing backslash.
The sequence ‘\u’ or ‘\U’ can be used to escape Unicode characters. ‘\u’ must be followed by the Unicode character code expressed as four hexadecimal digits. ‘\U’ must be followed by the Unicode character code expressed as eight hexadecimal digits. The highest allowed value is ‘\U0010FFFF’.
A backslash followed immediately by a newline is deleted; thus an
escaped newline can be used to continue a string over more than one
source line. (String literals may also contain embedded newlines.)
').
Within a quoted name, two adjacent single quotes stand for a single
single quote. Quoted names can also contain
backslash escapes of the same form as for strings.
$)
followed by an unquoted name.