h2 assignment 2017
1 Using the grammar Ginteger• develop a leftmost derivation for the integer 4520. How many .steps are required for this derivation? In general, how many steps are required to derive an integer with an arbitrary number, say d, of Digits’?
2 Using the grammar Gimeger, develop a rightmost derivation for the integer 4520.
3 Develop a leftmost derivation for the Identifier value a2i, using the BNF syntax given in Figure 2.7.
4 Develop a rightmost derivation for the Identifier value a2i, using the BNF syntax given in
Figure 2.7.
5 Using the grammar of Figure 2.7, draw parse trees for each of the following:
(a) x = x + a -1;
(b) a = b * c I d;
(c) i = i + j * k – 3;