Single Quoted Tokens

Geoff Sutcliffe
University of Miami

The BNF currently underspecifies the how single quoted tokens with escaped characters should be treated ...

<single_quoted>      ::- [']([^'\\]|[\\].)([^'\\]|[\\].])*[']
%----<single_quoted>s contain any characters. \ is the escape character, so
%----that a \ followed by a character is one character of the <single_quoted>,
%----e.g., if \' is encountered the ' is not the end of the <single_quoted>.
%----The token does not include the outer quotes, e.g., 'cat' and cat are the
%----same. See atomic_word> for information about stripping the quotes.
It is not specified whethere, e.g., 'abc' = 'a\bc', i.e., whether or not an escaped character is the same as an unescaped character. That means that different systems can currently give diferent answers, which is unpleasant. This dilemma also applies to double quoted distinct objects. There are some ways to resolve this issue:
  1. Escape only the quote. This might be hard to specify in the BNF. Thus 'a\bc' would no longer be legal, only things like 'a\'c'.

  2. Escape only the quote and the escape. That allows things like 'a\\b\'c'.

  3. Follow the ISO Prolog standard, which specifies the following interpreted escape sequences ...
    \b
    backspace (character code 8)
    \t
    horizontal tab (character code 9)
    \n
    newline (character code 10)
    \v
    vertical tab (character code 11)
    \f
    form feed (character code 12)
    \r
    carriage return (character code 13)
    \e
    escape (character code 27)
    \d
    \^?
    delete (character code 127)
    \a
    alarm (character code 7)
    \xCD
    the character code CD (two hexadecimal digits)
    \octal
    the character code octal base 8, where octal is up to 3 octal digits
    \^char
    the character code char mod 32, where char is a letter.
    \layout-char
    A single layout character, for example a newline, is ignored.
    \c
    All characters up to, but not including, the next non-layout character are ignored.
    \other
    A character not mentioned in this table stands for itself. For example, `\\' inserts a single backslash and `\'' inserts a single quote.
    The drawback or adopting this standard is that it makes work for ATP system developers.