Lexical
The words, literals and comments Adam source is made of.
Examples: res\examples\language\lexical holds small, commented programs for this page's features, each listing the output it prints; run one with adam build <file> -r.
module exe lexical_literals;
const
MILLION: int64 = 1'000'000;
MASK: uint32 = 0xFF'00;
BITS: uint8 = 0b1010;
HALF: float64 = .5;
/// A raw string: nothing in it is an escape
FOLDER: string = R"x(C:\no\escapes\here)x";
var
GLetter: char;
begin
// a line comment
GLetter := 'A'; /* a block comment */
println("{} {} {}", MILLION, MASK, BITS);
println("{} {}", HALF, 1.5e3);
println("{}", FOLDER);
println("{} {}", len("four"), GLetter);
end.
1000000 65280 10
0.5 1500
C:\no\escapes\here
4 A
Names
Adam is case-sensitive, and its keywords are lowercase. A name starts with a letter or _ and goes on with letters, digits and _; a name starting adam_ belongs to the compiler.
Many of Adam's words are context words: words only where the grammar expects them and plain names everywhere else. The intrinsics are names declared in an outer scope, never reserved. The Reference lists every keyword, context word and intrinsic.
Comments
//starts a comment that runs to the end of its line./* .. */is a block comment; block comments do not nest.- A
///line is a doc comment, written in Markdown, that documents the declaration on the line below it.@param,@returnsand@examplemark its parts, and hover and these docs read it.
Numbers
An integer literal is decimal, hexadecimal (0x) or binary (0b), and a ' may separate its digits: 1'000'000. There is no octal literal: a leading 0 followed by digits is an error.
A float literal without a suffix is a float64, and one with f is a float32: 1.5, .5, 1.5e3, 1.5f.
Strings and characters
A string literal is written in double quotes and a char literal in single quotes. A raw string, R"x( .. )x", holds its text exactly as written, and string literals written next to each other join into one.
There are no string prefixes: a literal is narrow unless the type it goes to is wstring or wchar, which then makes it wide.