AnyDSL

AnyDSL

Expressions


Contents


Impala is an expression-oriented language. This means, that if-, while- and for-constructs are not Statements but Expressions that yield values. It is perfectly fine and even encouraged to nest expressions.

Syntax

expr ::= primary_expr
       | block_expr
       | for_expr
       | if_expr
       | while_expr
       | with_expr
       | definite_array_expr
       | function_expr
       | indefinite_array_expr
       | simd_expr
       | struct_expr
       | tuple_expr
       | infix_expr
       | postfix_expr
       | prefix_expr
       | cast_expr
       | field_expr
       | map_expr
       | type_application_expr

Precedence

Nesting of expressions is disambiguated according to this table:

Operator Description Associativity
++ --
()
[]
.
Postfix Expression (increment/decrement)
Map Expression
Type Application Expression
Field Expression
left-to-right
++ --
+ -
!
~
*
& &mut
|/*....*/|
Prefix Expression (increment/decrement)
Prefix Expression (unary plus/minus)
Prefix Expression (logical/bitwise NOT)
Prefix Expression (alloc)
Prefix Expression (dereference)
Prefix Expression (address-of/mutable address-of)
Function Expression
right-to-left
as Cast Expression left-to-right
* / % Infix Expression (multiplication/division/remainder) left-to-right
+ - Infix Expression (addition/subtraction) left-to-right
<< >> Infix Expression (bitwise left/right shift) left-to-right
& Infix Expression (bitwise AND) left-to-right
^ Infix Expression (bitwise XOR) left-to-right
| Infix Expression (bitwise OR) left-to-right
== !=
< <= > >=
Infix Expression (equal/not equal)
Infix Expression (less/less equal/greater/greater equal)
left-to-right
&& Infix Expression (logical AND) left-to-right
|| Infix Expression (logical OR) left-to-right
=
*= /= %=
+= -=
<<= >>=
&= ^= |=
Infix Expression (assignment)
Infix Expression (assign by sum/difference)
Infix Expression (assign by product/quotient/remainder)
Infix Expression (assign by bitwise left/right shift)
Infix Expression (assign by bitwise AND/XOR/OR)
left-to-right

Comparison with C