Operator precedence, also called operator priority, orders operators so an expression has a predictable evaluation order. Operations with higher-precedence operators are evaluated before lower-precedence ones; parentheses make a contained subexpression evaluate first. section 12.1 section 12.5
Reading arithmetic expressions
In 1 + 2 * 3, multiplication is evaluated before addition. In 1 + 2 * (3 + 4), the parenthesized addition is evaluated first, then multiplication, then the outer addition. Each completed subexpression is replaced by its result as evaluation proceeds recursively. section 12.1
Precedence must shape an expression AST, not merely its displayed symbols. An AST that groups the multiplication beneath the addition represents 1 + 2 * 3 correctly and supports code generation that preserves its intended runtime meaning. This also lets a projectional editor behave like familiar linear expression editing. section 12.0 section 12.5
When adjacent binary operators have unequal precedence, the higher-precedence operation groups first. Equal precedence needs associativity: left-associative operators group the left operation first, while right-associative operators group the right operation first. Projection can add virtual show-only parentheses when an AST’s displayed grouping would otherwise be ambiguous. section 12.5
Rental-price computation
A rental price after discount can be generated as rentalPriceBeforeDiscount - discount * 0.01 * rentalPriceBeforeDiscount. Multiplication groups before subtraction, producing the discount amount before subtracting it from the original price. section 11.3 section 13.1
Figure 12.5 Building an AST for the expression 1 + 2 * 3
Trace how precedence determines the AST built for 1 + 2 * 3. section 12.1






