Constants

Fast Intro#

You want numbers? We got numbers. You want strings? We got strings. Constants are a fast way to place data into a document. For instance, the following code outlines some basic constants:

#we_got_constants {
int x = 123;
int y = 0x04;
double z = 3.14;
bool b = true;
client c = @no_one;
}

Details#

There are a variety of ways to conjure up constants. The following table illustrates examples:

typesyntaxexamples
bool(truefalse)
int[0-9]+42, 123, 0
int0x[0-9a-fA-F]+0xff, 0xdeadbeef
double[0-9].?[0-9]([eE](0-9)+)?3.14, 10e19, 2.72e10
string"(^"escape)*"
label#[a-z]+#foo, #start
client@no_one@no_one
maybe<?>@maybe<Type>@maybe<int>
maybe(?)@maybe(Expr)@maybe(123)

String escaping#

A character following a backslash (\) is an escape sequence within a string, and it is an escape for the parser to inject special characters. For instance, if you are parsing a string initiated by double quotes, then how does one get a double quote into the string? Well, that's what the escape is for. Adama's strings support the following escape sequences:

escape codebehavior
\ta tab character
\ba backspace character
\na newline
\ra carriage return
\fa form feed
\"a double quote (")
\\a backslash character (\)
\uABCDa unicode character formed by the four adjoined hex characters after the \u