Literals

Literal values are constant explicit integer, string or array values that appear in the code.

Integer Literals

Integer literals can be defined in four different ways:

Decimal
A value consisting of the digits '0' to '9'. E.g.
INT x := 42;
Hexadecimal
A value consisting of the digits '0' to '9' and the letters 'a' to 'f', with a '0x' prefix. Note that the alphabetic digits and the prefix may be in upper or lower case. E.g.
INT x := 0x2a;
INT y := 0X2A;
Binary
A value consisting of the digits '0' and '1' with a '0b' prefix. Note that the prefix may be in upper or lower case. E.g.
INT x := 0b10110;
INT y := 0B00111;
Character
A single character enclosed in single quotes, which is equivalent to the ASCII value of that character. As well as literal characters, escaped characters as inside strings (see String Literals below) may also be used. E.g.
PRINT('A');
PRINT('\n');
would print the values 65 and 10, since the ASCII value of 'A' is 65 and a newline is 10.

String Literals

String literals are defined as text enclosed within double quotes. A number of special characters can also be included, similar to the C escape characters:

Escape sequenceMeaning
\aAlert (bell) character
\bBackspace
\fFormfeed
\nNewline
\rCarriage return
\tTab character
\vVertical tab
\'Single quote
\"Double quote
\\Backslash
\?Literal question mark

\f and \v are printer commands, so may act unpredictably on a console display.

Any other character preceded by a backslash will be treated as just the character itself. For example, "\x" is treated as "x".

Array Literals

Array literals are defined using curly bracket syntax:

INT[] i := {1, 2, 42};
INT[][] j := {{1, 2, 42}, {9, 72}, {}};
STRING[] s := {"hello", "world"};
PassArray({1, 2, 42})();  // pass array literal as a function argument