Operators

Operators are syntax sugar over built-in functions.

Binary

<arithmetic_binary_operator> ::=
    | "+" | "+="
    | "-" | "-="
    | "*" | "*="
    | "/" | "/="
    | "%" | "%="
    | "**" | "**=" ;
<bitwise_binary_operator> ::=
    | "|" | "|="
    | ">>" | ">>="
    | "<<" | "<<="
    | "&" | "&="
    | "^" | "^=" ;

<logical_binary_operator> ::=
    | "=="
    | "!="
    | "&&"
    | "||"
    | ">" | ">="
    | "<" | "<=" ;

<binary_operator> ::=
    | <arithmetic_binary_operator>
    | <bitwise_binary_operator>
    | <logical_binary_operator> ;

Unary

<arithmetic_unary_operator> ::= "-" ;

<bitwise_unary_operator> ::= "~" ;

<logical_unary_operator> ::= "!" ;

<unary_operator> ::=
    | <arithmetic_unary_operator>
    | <bitwise_unary_operator>
    | <logical_unary_operator> ;

Semantics

Operator overloading is disallowed.

operatortypesbehaviorpanic case
+integerschecked additionoverflow
-integerschecked subtraction (binary)underflow
-integerschecked negation (unary)overflow
*integerschecked multiplicationoverflow
/integerschecked divisiondivide by zero
%integerschecked modulusdivide by zero
**integersexponentiation-
&integersbitwise AND-
\|integersbitwise OR-
~integersbitwise NOT-
^integersbitwise XOR-
>>integersbitwise shift right-
<<integersbitwise shift left-
==anyequality-
!=anyinequality-
&&booleanslogical AND-
\|\|booleanslogical OR-
!booleanslogical NOT-
>integersgreater than-
>=integersgreater than or equal to-
<integersless than-
<=integersless than or equal to-