Syntax of constants and variables

Boolean

Constants true and false are the two only instances of class Boolean.

Nil

Constant nil is the single instance of class Nil.

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

The escape sequence using hexadecimal number representation can have 1 or 2 hexadecimal digits. The hexadecimal value should be different from 0, but it is allowed to have a 0 as a first of two digits. In addition characters '\x0' and '\x00' are allowed, but these escape sequences cannot be used inside strings. The documentation of the basic classes refers to the following classes of special characters and character sequences:

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>::= ["-"|"+"] <Digits> [("e"|"E") ["+"] <DecimalDigit>*]
| ["-"|"+"] "0" ["b"|"B"] <BinaryDigit>+
| ["-"|"+"] "0" ["x"|"X"]<HexadecimalDigit>+
<Real>::= ["-"|"+"] (<Digits> "." <DecimalDigit>* | "." <DecimalDigit>+) [("e"|"E") ["-"|"+"] <DecimalDigit>*]

These definitions are based on the following definitions:

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

Variable

Identifiers (variables, etc.) can be expressed in the following syntax:

<Identifier>::= (LowerCaseLetter | UpperCaseLetter) (LowerCaseLetter | UpperCaseLetter | DecimalDigit | "_")*

This definition is based on the following definitions:

<LowerCaseLetter>::= "a" | ... | "z"
<UpperCaseLetter>::= "A" | ... | "Z"
<DecimalDigit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

Environment variable

An environment variable is defined by a non-empty sequence of characters (alphabetical, numerical and underscore) , enclosed by the character sequence "${" and "}". When starting a simulation, each environment variable is replaced by its value. This requires that the environment variable is set in the operating system, and that its value can be parsed as another POOSL constant.