A literal is a text representation of a certain value. The following types of literals are available in Fore.NET: Logical, Integer, Real, Character, String and Null.
literal:
boolean-literal
integer-literal
real-literal
character-literal
string-literal
null-literal
There are two logical literal values: True and False.
boolean-literal:
True
False
The type of a logical literal is Boolean.
Integer literals are used to represent values of the following types: Byte, Short, Integer, Long. Integer literals have two possible forms: decimal and hexadecimal.
integer-literal:
decimal-integer-literal
hexadecimal-integer-literal
decimal-integer-literal:
decimal-digits integer-type-suffixopt
decimal-digits:
decimal-digit
decimal-digits decimal-digit
decimal-digit: one of
0 1 2 3 4 5 6 7 8 9
integer-type-suffix: one of
U u L l UL Ul uL ul LU Lu lU lu
hexadecimal-integer-literal:
0x hex-digits integer-type-suffixopt
0X hex-digits integer-type-suffixopt
hex-digits:
hex-digit
hex-digits hex-digit
hex-digit: one of
0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
The literal type is determined in accordance with the following rules:
If the literal does not contain a suffix, it uses as its type the first of the following types that can represent its values: SByte, Byte, Short, UShort, Integer, UInteger, Long and ULong.
If the literal value cannot be represented with the Ulong type, a compile-time error occurs.
Real literals represent values of the following types: Float, Double and Decimal.
real-literal:
decimal-digits . decimal-digits exponent-partopt real-type-suffixopt
. decimal-digits exponent-partopt real-type-suffixopt
decimal-digits exponent-part real-type-suffixopt
decimal-digits real-type-suffix
exponent-part:
e signopt decimal-digits
E signopt decimal-digits
sign: one of
+ -
real-type-suffix: one of
F f D d M m
If no real type suffix is specified, the type of the real literal is Double. Otherwise, the suffix determines the type of the real literal, as follows: F or f for the Float type, D or d for the Double type, M or m for the Decimal type.
A character literal represents a single character, and usually consists of this character in single quotes.
character-literal:
' character '
character:
single-character
unicode-escape-sequence
single-character:
Any character except ' (U+0027) and new-line-character
A character literal has the Char type.
A string literal consists of zero or more characters enclosed in double quotes. It also may contain Unicode escape sequences.
string-literal:
" string-literal-charactersopt "
string-literal-characters:
string-literal-character
string-literal-characters string-literal-character
string-literal-character:
single-string-literal-character
quote-escape-sequence
unicode-escape-sequence
single-string-literal-character:
Any character except " (U+0022) and new-line-character
quote-escape-sequence:
""
The type of a string literal is String.
null-literal:
Null
This literal has an empty type.
See also: