DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY “T3,EXAMINATION2017-2018” Semester: 4thDate of Exam:17/5/2018 Subject:TOC&CD Subject Code:CSH209-T Branch:CSE Session:II Course Type: CORECourse Nature: Hard Time: 3 Hours Program: B.Tech Max.Marks: 80Signature: HOD/Associate HOD: Note: All question are compulsory from Part A (2X 10=20Marks). Attempt any two questions from Part B (15 marks each). Attempt any two questions from Part C (15 marks each).

1 (a) What do you mean by Recursive Descent Parsing. (b) Give two differences between top down parser and bottom up parser. (c) What is an ambiguous grammar. Give example for the same (d) Discuss any two types of conflicts that occur while constructing an LR parser. (e) List down all the token and its types for string: printf(“the value of x=%d”,i) (f) Construct a parse tree for string (id+id*id) using grammar E->E+E|E*E|(E)|id (g)What is meant by operator grammar? Give an example. (h) Explain Synthesis attribute with example. (i) Explain Inherited attribute with example. (j) Define DAG PART B 1. (a) Check if the following grammar is accepted by CLR parser. Support your answer with parsing table for the same. S-> AA 10 A->aA | b (b)Eliminate left factoring for the following grammar. 2.5 S->aAd|aB A->a|ab B->ccd|ddc (c) Eliminate left recursion for the following grammar. 2.5 S-> (L) | a L-> L, S L-> S 2 (a) Construct a LL(1) parser table of the following grammar with the help of table(s) for FIRST() and FOLLOW().Note: € represent null 10 E -> TE’ E’ -> +TE’ | € T -> FT’ T’-> *FT’ | € F -> id | € (b) Discuss all the phases of compiler that falls in analysis phase of compiler with suitable examples. 5 *******

3(a) Construct a LR(0) parser for the following grammar and highlight the conflicts (if any) in the table. S->Aa | bAc | dc | bda 10 A-> d 3(b) Give two differences between compiler and interpreter. Discuss all the phases of compiler that falls in synthesis phase of compiler with examples. 2+3 PART C 1.(a) Discuss following methods of code optimization along with suitable examples. 5*2=10 Strength Reduction, Dead Code Elimination, Constant Folding, Redundancy Elimination, Simplification (b) Construct an SDT for input string: 2*3+4 and determine the output for the same. S-> ER R-> *E{printf(“*”);}R |R E-> F+ E { printf(“+”);} |F F-> num {printf(num.val);}

5

2. (a) Represent input string (a*b)+(a*b*c)+(d/e*f) with the help of syntax tree, directed acyclic graph, postfix notation and three address code. 4*2=8 (b) What do you understand by the term three address code? Also using (a*b)+(a*b*c)+(d/e*f) as string construct the tables for Quadruples and Triples 1+2*3=7 3. (a) Discuss three methods of loop optimization. (b) Write three address code for the following expression If a<b && c>d then t=1 else e=0

3*2=6 4

(c) Explain the concept of tokenization. Generate three address code from the following DAG where (-) represent minus sign and (+) represent addition sign 3+2

*******
{"ft_lang_label":"__label__en","ft_lang_prob":0.7641083,"math_prob":0.7435678,"size":2967,"snap":"2019-13-2019-22","text_gpt3_token_len":840,"char_repetition_ratio":0.112048596,"word_repetition_ratio":0.033402923,"special_character_ratio":0.2925514,"punctuation_ratio":0.105785124,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9884709,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-03-23T11:38:24Z\",\"WARC-Record-ID\":\"<urn:uuid:4c329864-fc61-4440-8014-eb90c9b112d2>\",\"Content-Length\":\"82261\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5ba63947-9858-4281-b4b1-88b6770b5d61>\",\"WARC-Concurrent-To\":\"<urn:uuid:163d6a7e-d266-4374-8e67-b3684e560515>\",\"WARC-IP-Address\":\"3.91.114.175\",\"WARC-Target-URI\":\"https://issuu.com/manavrachna/docs/toc_cd\",\"WARC-Payload-Digest\":\"sha1:3FD6SJAQAGSDR36IOPJWV3OY6PK6BV6S\",\"WARC-Block-Digest\":\"sha1:TCKCOTEJSGR3NOEA3JHPVM7U66YSFCDE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-13/CC-MAIN-2019-13_segments_1552912202781.83_warc_CC-MAIN-20190323101107-20190323123107-00048.warc.gz\"}"}