Slide 3.2: Ambiguity (cont.) Slide 3.4: Abstract syntax Home |
if (0) if (1) other else other
if (0) { if (1) other else other }
<statement> ::= <if-stmt> | <other> <if-stmt> ::= if ( <exp> ) <statement> | if ( <exp> ) <statement> else <statement> <exp> ::= 0 | 1 ⇓ <statement> ::= <matched-stmt> | <unmatched-stmt> <matched-stmt> ::= if ( <exp> ) <matched-stmt> else <matched-stmt> | <other> <unmatched-stmt> ::= if ( <exp> ) <statement> | if ( <exp> ) <matched-stmt> else <unmatched-stmt> <exp> ::= 0 | 1
if x ≠ 0 then if y = 1/x then ok := true; else z := 1/x; end if>; end if>;