70 likes | 146 Views
Homework #3. J. H. Wang Nov. 1, 2011. Homework #3. Chap. 4 4.1 (c) 4.7 (c) 4.8 (a)(b)(c) 4.11. Chap. 4
E N D
Homework #3 J. H. Wang Nov. 1, 2011
Homework #3 • Chap. 4 • 4.1 (c) • 4.7 (c) • 4.8 (a)(b)(c) • 4.11
Chap. 4 • 4.1: For each of the grammars below, describe the language associated with the grammar and determine if the grammar is ambiguous. If the grammar is ambiguous, show two parse trees for the same string (see Fig. 4.3). Otherwise, explain why the grammar is not ambiguous.(c) SA B AA a | A b | a BB a | B b | b
4.7: Describe the language denoted by each of the following grammars:(d) ({A,B,C}, {a,b,c}, {ABB, Ba, Bb, Bc}, A)
4.8: A grammar for infix expressions follows: Start E $ E T plus E | T T T times F | F F ( E ) | num(a) Show the leftmost derivation of the following string. num plus num times num plus num $(b) Show the rightmost derivation of the following string. Num times num plus num times num $(c) Describe how this grammar structures expressions, in terms of the precedence and left- or righ- associativity of operators.
4.11: Compute First and Follow sets for the nonterminals of the following grammar.S a S e | BB b B e | CC c C e | d
Submission • Hand-written exercises: hand in your paper version in class • Due: two weeks (Nov. 15, 2011)