A declaration has some effect in its lexical scope. Declarations may be attached to statements, rules or expressions.

‘Legend’ declarations

A legend declaration declares a legend which is used by ‘load’ expressions in the declaration’s lexical scope. The legend must be a compile-time constant pattern of height 1 using the current alphabet.

legend declarations are currently useless, because load expressions are not yet supported.

legend Expression

‘Let’ declarations

A let declaration declares a variable with a given name and value. Variables are immutable and cannot be re-assigned elsewhere in the program, but a variable may take different values during different lifetimes the statement or rule containing the declaration is executed or applied multiple times.

A compilation error occurs if a variable of the same name is already declared in the current lexical context.

let Name = Expression

A let param declaration is as above, except that the variable’s value will instead be a runtime parameter of that name, if one is provided, otherwise the variable’s initialiser is used.

A compilation error occurs if a runtime parameter of the same name is declared anywhere else in the same program.

let param Name = Expression

‘Symmetry’ declarations

A symmetry declaration sets the symmetry group which is used for rules in the declaration’s lexical context. The symmetry group name must be a compile-time constant of type str with one of the following values:

symmetry Expression

‘Union’ declarations

A union declaration declares a union label to have the same meaning as a given character set. The union label can then be used as a pattern character in pattern literals within the declaration’s lexical scope.

The union label must be a pattern literal containing a single pattern character which is not already defined as a symbol in the current alphabet or a union label, and the character set must be a compile-time constant expression with a 1x1 pattern type for the current alphabet.

union [U] = [[CharSet]]