Operators bind from or and xor, the weakest, through and, the comparisons, as, and the adding operators, to the multiplying operators, the strongest. Operators of one level group from the left. A comparison does not chain.

expression

expressionexpression = conjunction { ( "or" | "xor" ) conjunction } .conjunctionconjunctionorxorconjunctionconjunction
expression = conjunction { ( "or" | "xor" ) conjunction } .

An expression: conjunctions joined by or and xor.

Used in constant-entry, typed-constant-value, variable-group, dimension, subrange-type, bitset-type, bitrecord-type, bitrecord-field-group, wide-integer-type, tensor-type, assignment-statement, scheduled-stream, actual-parameters, if-statement, while-statement, repeat-statement, for-statement, case-statement, case-label, when-guard, dispose-statement, fail-statement, emit-statement, select-arm, value-consumption, aggregate-element, set-element, allocation, index-list.

conjunction

conjunctionconjunction = relation { "and" relation } .relationrelationandrelationrelation
conjunction = relation { "and" relation } .

Relations joined by and.

Used in expression.

relation

relationrelation = "not" relation | "odd" cast-expression | cast-expression [ comparison-operator cast-expression | "is" case-pattern ] .notrelationrelationoddcast-expressioncast-expressioncast-expressioncast-expressioncomparison-operatorcomparison-operatorcast-expressioncast-expressioniscase-patterncase-pattern
relation = "not" relation | "odd" cast-expression
         | cast-expression [ comparison-operator cast-expression | "is" case-pattern ] .

A comparison, a case test, a negation, or an oddness test.

Used in conjunction, relation.

comparison-operator

comparison-operatorcomparison-operator = "=" | "#" | "≠" | "<" | "<=" | "≤" | ">" | ">=" | "≥" | "in" .=#≠<<=≤>>=≥in
comparison-operator = "=" | "#" | "≠" | "<" | "<=" | "≤" | ">" | ">=" | "≥" | "in" .

The comparisons; ≠, ≤ and ≥ are the same operators as #, <= and >=.

Used in relation.

cast-expression

cast-expressioncast-expression = simple-expression { "as" identifier } .simple-expressionsimple-expressionasidentifieridentifier
cast-expression = simple-expression { "as" identifier } .

A value converted to a type by its name.

Used in case-pattern, relation.

simple-expression

simple-expressionsimple-expression = term { ( "+" | "-" ) term } .termterm+-termterm
simple-expression = term { ( "+" | "-" ) term } .

Terms joined by adding operators.

Used in cast-expression.

term

termterm = factor { multiplying-operator factor } .factorfactormultiplying-operatormultiplying-operatorfactorfactor
term = factor { multiplying-operator factor } .

Factors joined by multiplying operators.

Used in simple-expression.

multiplying-operator

multiplying-operatormultiplying-operator = "*" | "×" | "/" | "·" | "⊙" | "mod" | "shl" | "shr" .*×/·⊙modshlshr
multiplying-operator = "*" | "×" | "/" | "·" | "⊙" | "mod" | "shl" | "shr" .

The multiplying operators: × is the same operator as *, · is the dot product and ⊙ the elementwise product.

Used in term.

factor

factorfactor = [ "+" | "-" | "address" | "value" ] primary { selector } (?! "." ) .+-addressvalueprimaryprimaryselectorselectornot followed by "."
factor = [ "+" | "-" | "address" | "value" ] primary { selector } (?! "." ) .

A value with its selectors, after one optional prefix.

value reads through the pointer before the selectors apply; a sign and address apply to the selected value.

A period behind a value always selects a field, so a unit whose body ends in a value is written begin ... end.

Used in term.

primary

primaryprimary = function-call | identifier | literal | parenthesized-value | set-constructor | allocation .function-callfunction-callidentifieridentifierliteralliteralparenthesized-valueparenthesized-valueset-constructorset-constructorallocationallocation
primary = function-call | identifier | literal | parenthesized-value | set-constructor | allocation .

A call, a name, a literal, a parenthesized value, a set, or an allocation.

Used in factor.

function-call

function-callfunction-call = routine-name [ type-arguments ] actual-parameters .routine-nameroutine-nametype-argumentstype-argumentsactual-parametersactual-parameters
function-call = routine-name [ type-arguments ] actual-parameters .

A function is called, writing out its type arguments where they cannot be inferred.

Used in primary.

literal

literalliteral = integer-literal | floating-point-literal | string-literal | unicode-literal | masked-integer-literal | regex-literal | "nil" .integer-literalinteger-literalfloating-point-literalfloating-point-literalstring-literalstring-literalunicode-literalunicode-literalmasked-integer-literalmasked-integer-literalregex-literalregex-literalnil
literal = integer-literal | floating-point-literal | string-literal | unicode-literal | masked-integer-literal
        | regex-literal | "nil" .

A literal value.

Used in primary.

parenthesized-value

parenthesized-valueparenthesized-value = "(" aggregate-element { "," aggregate-element } ")" .(aggregate-elementaggregate-element,aggregate-elementaggregate-element)
parenthesized-value = "(" aggregate-element { "," aggregate-element } ")" .

A grouped expression, or with a comma or a field name a whole composite value at once.

Used in assignment-target, primary.

aggregate-element

aggregate-elementaggregate-element = [ identifier ":" ] expression .identifieridentifier:expressionexpression
aggregate-element = [ identifier ":" ] expression .

An element of a composite value, named by its field or by its place.

Used in parenthesized-value.

set-constructor

set-constructorset-constructor = "[" [ set-element { "," set-element } ] "]" .[set-elementset-element,set-elementset-element]
set-constructor = "[" [ set-element { "," set-element } ] "]" .

A set by its elements and ranges.

Used in primary.

set-element

set-elementset-element = expression [ ".." expression ] .expressionexpression..expressionexpression
set-element = expression [ ".." expression ] .

An element of a set, or a range of them.

Used in set-constructor.

allocation

allocationallocation = "new" ( shape-form | (?! "tensor" "of" ) type-name ) [ "reserve" expression ] ( until-owner | (?! "until" ) ) .newshape-formshape-formnot followed by "tensor" "of"type-nametype-namereserveexpressionexpressionuntil-owneruntil-ownernot followed by "until"
allocation = "new" ( shape-form | (?! "tensor" "of" ) type-name ) [ "reserve" expression ]
             ( until-owner | (?! "until" ) ) .

A heap cell or an owned dynamic array, optionally reserved and owned.

A type named tensor takes no type arguments here: tensor of would begin a tensor without its rank, which is refused.

An until directly behind an allocation always names its owner, so a repeat loop whose last statement allocates needs a semicolon before the loop’s own until.

Used in primary.

selector

selectorselector = "." identifier | "[" index-list "]" ..identifieridentifier[index-listindex-list]
selector = "." identifier | "[" index-list "]" .

A field by its name, an element by its indices, or a slice by its bounds.

Used in assignment-target, factor.

index-list

index-listindex-list = expression ".." expression | expression { "," expression } .expressionexpression..expressionexpressionexpressionexpression,expressionexpression
index-list = expression ".." expression | expression { "," expression } .

Indices, or the bounds of a slice.

Used in selector.