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
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
conjunction = relation { "and" relation } .Relations joined by and.
Used in expression.
relation
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-operator = "=" | "#" | "≠" | "<" | "<=" | "≤" | ">" | ">=" | "≥" | "in" .The comparisons; ≠, ≤ and ≥ are the same operators as #, <= and >=.
Used in relation.
cast-expression
cast-expression = simple-expression { "as" identifier } .A value converted to a type by its name.
Used in case-pattern, relation.
simple-expression
simple-expression = term { ( "+" | "-" ) term } .Terms joined by adding operators.
Used in cast-expression.
term
term = factor { multiplying-operator factor } .Factors joined by multiplying operators.
Used in simple-expression.
multiplying-operator
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
factor = [ "+" | "-" | "address" | "value" ] primary { selector } (?! "." ) .A value with its selectors, after one optional prefix.
valuereads through the pointer before the selectors apply; a sign andaddressapply 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
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-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
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-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-element = [ identifier ":" ] expression .An element of a composite value, named by its field or by its place.
Used in parenthesized-value.
set-constructor
set-constructor = "[" [ set-element { "," set-element } ] "]" .A set by its elements and ranges.
Used in primary.
set-element
set-element = expression [ ".." expression ] .An element of a set, or a range of them.
Used in set-constructor.
allocation
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
tensortakes no type arguments here:tensor ofwould begin a tensor without its rank, which is refused.
An
untildirectly behind an allocation always names its owner, so a repeat loop whose last statement allocates needs a semicolon before the loop’s ownuntil.
Used in primary.
selector
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-list = expression ".." expression | expression { "," expression } .Indices, or the bounds of a slice.
Used in selector.