Literals are ephemeral
expressions that allow expressing a fixed value directly.
Integer literals are expressions that represent an unsigned integral value. They are fluid
and thus not explicitly typed, but they may only convert to integral types. They are represented as one of the following:
0
1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
) followed by 0 or more decimal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
)0b
followed by 1 or more binary digits (0
, 1
)0o
followed by 1 or more octal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
)0x
followed by 1 or more hexadecimal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
, a
, A
, b
, B
, c
, C
, d
, D
, e
, E
, f
, F
)An integer literal may optionally have a suffix of scientific notation which is: an E
or an e
, followed by an optional +
or -
(omitting is equivalent to +
), followed by 1 or more decimal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
).
Integer literals may optionally be broken up by underscores ( _
) anywhere except for the beginning. This means that 12_345_
is equivalent to 12345
.
Float literals are expressions that represent an unsigned floating value. They are fluid
and thus not explicitly typed, but they may only convert to floating types. They are represented by one of the following:
0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
), followed by followed a period (.
), followed by 1 or more decimal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
). This may optionally be have suffix of scientific notation which is: an E
or an e
, followed by an optional +
or -
(omitting is equivalent to +
), followed by 1 or more decimal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
).0x
, followed by 1 or more hexadecimal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
, a
, A
, b
, B
, c
, C
, d
, D
, e
, E
, f
, F
), followed by a period (.
), followed by 1 or more hexadecimal digits (0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
, a
, A
, b
, B
, c
, C
, d
, D
, e
, E
, f
, F
)Float literals may optionally be broken up by underscores ( _
) anywhere except for the beginning. This means that 1_234.5
is equivalent to 1234.5
.
Boolean literals are expressions represent a single boolean value. They are type Bool
and are represented by the following:
true
false
Character literals are expressions that represent a single character and are represented as ASCII. They are type Char
. They are represented by two single-quote characters ('
) containing one the following:
'
, \
, new-line, or carriage returncharacter escape code
String literals are expressions that represent a string of text. They are type [Char:N;'\0']
where N
is the number of characters in the string literal. They are represented by two double-quotes characters ("
) containing 0 or more of the following:
"
, and \
character escape code
As suggested by the type, string literals automatically have a null-terminator appended. This means that "\0"
is represented in memory as two null-terminator.
Unlike languages like C/C++ and Zig, nothing special needs to be done to allow string literals to be multi-line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21// integer literals def INTEGER: Int = 12; def SCIENTIFIC_INTEGER: USize = 14e2; // 1400 def BINARY_FLUID_INTEGER = 0b11010; // 26 // float literals def FLOAT: F32 = 12.4; // boolean literals def BOOL: Bool = true; // character literals def CHARACTER: Char = 'a'; def NULL_TERMINATOR: Char = '\0'; // string literals literals def STRING_LITERAL: [Char:28;'\0'] = "Hello, I am a string literal"; def MULTI_LINE_STRING_LITERAL: [Char:38;'\0'] = "Hello, I am a multi-line\n string literal";