For now, this reference is a best-effort document. We strive for validity and completeness, but are not yet there. In the future, the docs and lang teams will work together to figure out how best to do this. Until then, this is a best-effort attempt. If you find something wrong or missing, file an issue or send in a pull request.

Notation

Grammar

The following notations are used by the Lexer and Syntax grammar snippets:

Notation Examples Meaning
CAPITAL KW_IF, INTEGER_LITERAL A token produced by the lexer
ItalicCamelCase LetStatement, Item A syntactical production
string x, while, * The exact character(s)
\x \n, \r, \t, \0 The character represented by this escape
x? pub? An optional item
x* OuterAttribute* 0 or more of x
x+ MacroMatch+ 1 or more of x
xa..b HEX_DIGIT1..6 a to b repetitions of x
| u8 | u16, Block | Item Either one or another
[ ] [b B] Any of the characters listed
[ - ] [a-z] Any of the characters in the range
~[ ] ~[b B] Any characters, except those listed
~string ~\n, ~*/ Any characters, except this sequence
( ) (, Parameter)? Groups items

String table productions

Some rules in the grammar — notably unary operators, binary operators, and keywords — are given in a simplified form: as a listing of printable strings. These cases form a subset of the rules regarding the token rule, and are assumed to be the result of a lexical-analysis phase feeding the parser, driven by a DFA, operating over the disjunction of all such string table entries.

When such a string in monospace font occurs inside the grammar, it is an implicit reference to a single member of such a string table production. See tokens for more information.