CISC 223 - Assignment 5 (Winter 2014) Due: beginning of class (3:30 PM), Wednesday February 26 1. Consider the grammar with the following rules (capital letters are nonterminals and S is the start nonterminal): S -> AB | a A-> CD B-> bAB | € C -> dSd | c D-> cCD | € (a) (4 marks) Determine each of the sets i. FIRST(AB) ii. FIRST(CD) iii. FOLLOW(S) iv. FOLLOW(A) v. FOLLOW(B) vi. FOLLOW(C) vii. FOLLOW(D) For each element z belonging to a set FOLLOW(X) (X E {S, A, B, C, D}) give a derivation starting from S where z occurs directly after X. (This is not required for the FIRST-sets.) (b) (2 marks) Does the grammar allow the use of recursive-descent parsing? Justify your answer. 2. Are the following languages context-free or non-context-free? · If a language is context-free, give a context-free grammar that generates it. · If a language is not context-free, prove this using the pumping lemma. (a) (2 marks) L1 = {bici+kdk | i ? 0, k ? 0} (b) (2 marks) L2 = {aibkom | i, k, m ? 0, i = k and k < m}
Regulations on assignments . The assignments may be done in groups consisting of one, two, three or four students. If more than one students are collaborating on an assignment, they must submit a single joint solution. . Clearly print (or type) the name(s) and student number(s), and course number, at the top of the first page. Additionally each student collaborating on an assignment must sign the top of the first page. . If the submission consists of more than one page, the pages must be stapled together. · Note: You are asked to write your solutions using non-erasable pen (or to type the solutions). Solutions written in pencil or erasable ink will be marked, but they will not be considered for remarking after the assignments are returned.