2 Notation
Shplait syntax is bicameral, meaning that it is defined in two layers that each enforce a set of rules. The first layer is shrubbery syntax, which is described at Shrubbery Notation. Shrubbery notation defines the syntax of identifiers and numbers, and it defines how token sequences are grouped by parentheses, brackets, braces, quotes, and indentation. It also defines the technical words term, group, and alternative. A second layer of syntax specification (in this manual) determines which identifiers refer to syntactic forms, such as def and match, and it determines the allowed shapes of those forms. Superficially, Shplait resembles Rhombus, which also uses shrubbery notation, but Shplait is statically typed, much smaller, and has a different set of constructs overall.
An operator cannot start with |, except that || is allowed. This constraint avoids trouble when | as a pattern or conditional separator is not followed by whitespace.
The $ operator cannot continue a group on a new line by being more indented. This constraint avoids confusion when a multi-line pattern or template is intended (see Syntax Objects, Patterns, and Templates), but extra space appears before a $ that starts a line.
The rest of Shplait’s syntax specification uses patterns over Shrubbery forms. In the pattern for a syntactic form, ... indicates zero or more repetitions of the preceding form. The preceding form can be an individual term, a group, or an alternative.
id (or a name that ends in id) stands for an identifier, such as x or interp.
op (or a name that ends in op) stands for an operator, such as + or ==.
expr (or a name that ends in ...) stands for an expression, such as x, "hello", 1 + 2, or f(3, 4).
defn stands for a definition, such as def x = 1 or fun f(x): x.
body stands for a sequence of definitions and expressions that ends with an expression, and where an expression that isn’t the ending expression must have type Void; see also block. The last expression in body provides the type and result value of the body sequence.
typed_id stands for either an identifier or an identifier followed by :: and a declared type. Note that there cannot be spaces between the two :s in ::.