Lexical
Strings and Characters
String literals may be defined using q{...}
or "..."
, when using the latter syntax d
or w
may be prepended to dictate the size of the characters (dchar
or wchar
) or r
to dictate that all escapes are ignored.
Character literals may be defined using '...'
in which a single character is defined.
Escapes
Escape sequences are sequences of characters which result in a special character being used.
Sequence | Definition |
---|---|
\' |
' |
\" |
" |
\\ |
\ |
\0 |
Null terminator. |
\a |
Alert. |
\b |
Backspace. |
\f |
Form backfeed. |
\n |
Newline. |
\r |
Carriage return. |
\t |
Horizontal tab. |
\v |
Vertical tab. |
\xhh.. |
Hexadecimal character insert. |
Literals
Literal suffixes are suffixes which may be appended to a literal to change the way that the literal is formatted or interpreted.
Integral -Fix | Definition |
---|---|
u |
Unsigned, suffix. |
U |
Signed, suffix. |
L |
64-bit integer, suffix. |
f |
32-bit floating point, suffix. |
0x |
Hexadecimal, prefix. |
0X |
Hexadecimal, prefix. |
0o |
Octal, prefix. |
0b |
Binary, prefix. |
All integer literals may have their values separated by underscores for clarity, in replacement of commas such as in 10_000
where the literal is the value 10 thousand.
Comments, Terminators, and Scopes
// comment
/* multi-line comment */
Comments in Fern use the syntax \\
for single-line and /*..*/
for multi-line.
[type] name;
[type] name[(parameters)]
Terminators in Fern are ;
, which are necessary to end any expression or declaration of a signature (such as a type or function.)
{ .. }
Scopes in Fern are started and ended using curly brackets.
Keywords
Keyword | Definition |
---|---|
this |
Refers to the parent instance of the scope in which it was used, it is a comptime error if the scope has no instance. |
return |
Return |
delete |
Destruct |
bool |
Builtin |
true |
Builtin |
false |
Builtin |
byte |
Builtin |
ubyte |
Builtin |
short |
Builtin |
ushort |
Builtin |
int |
Builtin |
uint |
Builtin |
long |
Builtin |
float |
Builtin |
double |
Builtin |
ulong |
Builtin |
nint |
Builtin |
nuint |
Builtin |
void |
Builtin |
char |
Builtin |
wchar |
Builtin |
dchar |
Builtin |
string |
Builtin |
wstring |
Builtin |
dstring |
Builtin |
pure |
Attribute |
const |
Attribute |
static |
Attribute |
public |
Attribute |
private |
Attribute |
internal |
Attribute |
partial |
Attribute |
system |
Attribute |
trusted |
Attribute |
safe |
Attribute |
inline |
Attribute |
mustuse |
Attribute |
ref |
Attribute |
align |
Attribute |
offset |
Attribute |
atomic |
Attribute |
alias |
Alias |
module |
Type |
import |
Type |
struct |
Type |
class |
Type |
tagged |
Type |
unittest |
Unittest |
function |
Function Pointer |
delegate |
Function Pointer |
if |
Statement |
else |
Statement |
foreach |
Statement |
foreach_reverse |
Statement |
while |
Statement |
goto |
Statement |
with |
Statement |
break |
Statement |
continue |
Statement |
mixin |
Mixin |
is |
Conditional |
debug |
Versioning |
export |
Reserved |
extern |
Reserved |
assert |
Reserved |
__asm |
Reserved |
Special Symbols
The prefix __
is resserved for implementation and thus should be blacklisted for use in declarations. Such implementation are as follows, but implementations may add to this:
Symbol | Definition |
---|---|
__Windows |
Is Windows being targeted? |
__Linux |
Is Linux being targeted? |
__OSX |
Is OSX being targeted? |
__Posix |
Is Posix being targeted? |
__iOS |
Is iOS being targeted? |
__tvOS |
Is tvOS being targeted? |
__watchOS |
Is watchOS being targeted? |
__visionOS |
Is visionOS being targeted? |
__FreeBSD |
Is FreeBSD being targeted? |
__OpenBSD |
Is OpenBSD being targeted? |
__NetBSD |
Is NetBSD being targeted? |
__Solaris |
Is Solaris being targeted? |
__Android |
Is Android being targeted? |
__x86 |
Is x86 being targeted? |
__x86_64 |
Is x86_64 being targeted? |
__x64 |
Is 64-bit being targeted? |
__x32 |
Is 32-bit being targeted? |
__fnc |
Is the Fern Native Compiler being used? |
.sizeof |
The size in bytes of the symbol being targeted, this is a member. |
.alignof |
The alignment in bytes of the symbol being targeted, this is a member. |
.offsetof |
The offset in bytes of the symbol being targeted, this is a member. |
.typeof |
The type of the symbol being targeted, this is a member. |
.tag |
The tag of a tagged, this is a member. |
.ptr |
The pointer of an object, this is a member. |
.length |
The length of an array, this is a member. |