previous | start | next

Question 1

Using the following grammar, show a parse tree and a leftmost derivation for each of the following statements:

<assign> -> <id> '=' <expr>
<id> -> 'A' | 'B' | 'C'
<expr> -> <id> '+' <expr>
                   | <id> '*' <expr>
                   | '(' <expr> ')'
                   | <id>
    1. A = A * (B + (C * A))
    2. B = C * (A * C + B)
    3. A = A * (B + (C))


previous | start | next