6th Semester-CSIT-B.Tech - (CDCS-3002) - Compiler Design-Spring Mid Semester-2016

You might also like

Download as pdf
Download as pdf
You are on page 1of 2
Dok O\-62 MG . Compiler Design /CS-3002 /CSE & IT/ 6" /2016 Mid-Semester Examination School of Computer Engineering KIT University, Bhubaneswar-24 Time: 2 hrs Full Mark: 25 (Answer Question no.1 and any FOUR from the resi) a xs] a) Draw the transition diagram for the token class relop defined by the following regular definition Relop »<| <=|==|!=|>=|> 'b) Why do we need to buffer the input in the Lexical Analysis phase? Why do we go for two buffers instead of one? ©) Consider the following grammar Find the precedence of the operators @, ? and $. 4) Explain the following: i. Sentential form ii, Regular Definition ) Write a regular expression for student KIIT email id. @. [05] a) Explain the different phases of a compiler with a suitable example. ) Consider regular expression (ab | ac)* i Design an NFA equivalent to the regular expression. ii, Convert the NFA to a DFA using subset construction method. @ {05} a) For the grammar ‘S—aAbBpbAsBlc AGS BOS an LL(1) parsing table is given below. [ a b s L Ss x Y Se A ASS ASS Q B Bos BS Z Find appropriate entries for X, Y, Z and Q. b) Consider the following grammar Sal*|(1) Tsu U Su] <« Write down procedures for the nonterminals of the grammar to make a recursive descent parser. Q4. Compute the FIRST and FOLLOW sets for the following grammars. [05] a) SWAB | ABCS A—B | WB B-yBle Cz Wx b) SaAC|Bb er) Boflg cohli D—bEJe E-eD| dD co) S—ABa|bCA A cBCD\€ Bo CdA| ad Cole D—bSfla QS. The following grammar is not suitable for top down predictive parser. (05) L— Ra|Qba R—aba|caba |Rbe Q— bbe | be a) Justify the statement, ) Transform the grammar to make it suitable for top down predictive parser without changing the language that it describes. ©) Generate the LL(1) parse table to show that the transformed grammar is indeed LL(1) Q6. Consider the following Context-Free {051 $+ 8+8|ss |(S)[s* [a and the string (ata)*a i. Givea leftmost derivation for the given string, fi, Give a rightmost derivation for the given string. iii, Give a parse tree for the given string. iv. Is the grammar ambiguous? Justify your answer. v. Whats the language of the CFG?

You might also like