Syntax of constants

String and Char

A string constant is defined by a sequence of characters from the extended ASCII set of 256 characters enclosed by double quotation marks. Special syntax is added to represent non-printable characters by means of escape sequences that all begin with the backslash (\) symbol. Characters with ASCII value below 32 (except ASCII value 9) and the two characters " (double quotation mark, ASCII value 34) and \ (backslash, ASCII value 92) are not allowed in a string constant except as part of an escape sequence. The escape sequences that are supported are conforming to the C / Java specifications and provided in the table below.

Similarly, character constants are represented by a character between single quotation marks for characters with ASCII values 9 and 32 and above, except the single quotation mark character (ASCII value 39) and the backslash character (ASCII value 92). Moreover, any escape sequence can be used (between single quotation marks).

CharacterASCII RepresentationASCII ValueEscape Sequence
NewlineNL (LF)10\n
Horizontal tabHT9\t
Vertical tabVT11\v
BackspaceBS8\b
Carriage returnCR13\r
FormfeedFF12\f
AlertBEL7\a
Backslash\92\\
Question mark?63\?
Single quotation mark'39\'
Double quotation mark"34\"
Hexadecimal numberhhany\xhh
Null characterNUL0\0

The escape sequence using hexadecimal number representation can have 1 or 2 hexadecimal digits. It is allowed to have a 0 as a first of two digits.

Syntactic representations of String constants are not unique. Whenever a syntactic representation of a String constant is generated, the following encoding shall be used. For any character which has an individual encoding shown in the above table, this encoding shall be used. For any other character with an ASCII value below 32 (except ASCII value 9) the hexadecimal number escape sequence shall be used. All other characters are not encoded.

Integer and Real

Integer and real constants can be expressed in the following syntax:

<Integer>::= ["-"] <DecimalDigit>+ [("e" | "E") ["+"] <DecimalDigit>+]
| "0b" <BinaryDigit>+
| "0o" <OctalDigit>+
| "0x" <HexadecimalDigit>+
<Real>::= ["-"] <DecimalDigit>+ "." <DecimalDigit>+ [("e" | "E") ["+" | "-"] <DecimalDigit>+]

These definitions are based on the following definitions:

<BinaryDigit> ::= "0" | "1"
<OctalDigit> ::= <BinaryDigit> | "2" | "3" | "4" | "5" | "6" | "7"
<DecimalDigit> ::= <OctalDigit> | "8" | "9"
<HexadecimalDigit> ::= <DecimalDigit> | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"