Expressions¶
Expressions produce statically typed values. Binary operations currently require both operands to have exactly the same type.
Primary expressions¶
42
3.14
true
'A'
"hello"
count
values[index]
factorial(5)
(left + right)
Array indices are restricted to an integer literal or identifier. Function calls used in expressions must name a declared, non-void function.
Operators¶
| Category | Operators |
|---|---|
| arithmetic | + - * / |
| relational | < > <= >= |
| equality | == != |
| logical | && || ! |
| unary | + - ! |
Precedence follows the order documented on the syntax page.
Note
The current semantic analyzer checks matching operand types but does not enforce operator-specific operand categories or convert comparison results to a separate type. Write conventional combinations—numeric arithmetic and comparisons, and boolean logic—for behavior covered by the compiler tests.
Assignment and updates¶
Assignments target an identifier or array access and are statements:
count = 10;
count += 2;
count -= 1;
values[index] = count;
Prefix and postfix increment/decrement accept an identifier or array access:
++count;
count--;
values[index]++;
(count)++;
Computed targets such as ++(count + 1) and function-call targets are rejected.
Explicit casts¶
Cast syntax is a parenthesized target type followed by a restricted cast value:
double amount = (double) count;
character letter = (character) 65;
string label = (string) amount;
See types for the supported conversion table.