Parentheses are used to highlight or modify the order of evaluation of complex expressions. This improves both readability and maintainability.
Left and right parentheses must be paired in an arithmetic expression with the left parenthesis appearing before its corresponding right parenthesis.
Expressions within parentheses are evaluated first and parenthetical pairs can be nested within other pairs. Evaluation proceeds from the least inclusive pairing outward.
An arithmetic expression may begin only with a left parenthesis, a unary operator, or an operand (that is, an identifier or a literal). It may end only with a right parenthesis or an operand. An arithmetic expression must contain at least one reference to an identifier or a literal.
If the first operator in an arithmetic expression is a unary operator, it must be immediately preceded by a left parenthesis if that arithmetic expression immediately follows an identifier or another arithmetic expression.
| First Symbol | Second Symbol | ||||
|---|---|---|---|---|---|
| Identifier or Literal | * / ** + - | Unary + or Unary - | ( | ) | |
| Identifier or Literal | No | Yes | No | No | Yes |
| * / ** + - | Yes | No | Yes | Yes | No |
| Unary + or Unary - | Yes | No | No | Yes | No |
| ( | Yes | No | Yes | Yes | No |
| ) | No | Yes | No | No | Yes |