Literals
There are various types of literals in SIMPOL. Boolean literals are either .true
or .false
. Numeric literals must be a contiguous sequence of digits or digits
and letters in the case of hexadecimal values. If only digits are encountered then the value is
considered to be decimal. There is also support for other numeric bases. If it starts with:
0b
then the number will be evaluated as binary0o
then the number will be evaluated as octal0d
then the number will be evaluated as decimal0x
then the number will be evaluated as hexadecimal
String literals can be delimited either by a single ('
) or double ("
)
quote character. Any character can also be inserted into a string literal by placing the hexadecimal
character value inside of curly braces. For example, to insert a carriage return and linefeed pair into
a string literal it would look like this: "{0D}{0A}"
. To escape the starting curly brace
in the string simply include a second one. It is not always necessary to escape the starting curly brace,
only if there is any chance that the following character could be interpreted as a hexadecimal value.
To include a double quote character in a string the easiest method is to use single quotes to delimit the string literal. Another method is simply to escape the double quote character with itself. An example of this is:
function main() string foo foo = 'Don''t you know?' end function foo
which will return the string: Don't you know?
.
Number literals are currently not supported, nor is scientific notation. To enter a value that has a fractional
component into a number variable, it is necessary to place the value in a string and use the
.toval()
intrinsic function to convert it to a value. To enter a value that is normally a repeating
decimal into a number, the special notation for repeating decimals can be used. This is also the way that
repeating decimals are converted using the .tostr()
intrinsic function. For example, to enter
the value 1/3 into a number variable, try the following:
function main() number n n = .toval("0.3[3]", .nul, 10) n = n * 3 end function n
The return value of the function is 1
.
The special values .inf
and .nul
are essentially typeless, and can apply to
any value type. The special value .nul
can also mean the absence of an object.
![]() | Gotcha |
---|---|
These special values may cause some confusion when you begin using them. Any numeric expression,
regardless of whether that is string concatenation or multiplication of integers, that includes the value
|
![]() | Warning |
---|---|
Constants in SIMPOL can currently only be of type integer, string, or boolean and additionally integer constants cannot be negative (since this is considered to be an operation and at the time that constants are evaluated operations are not supported). |