Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views4 pages

Compiler Design

This document is an examination paper for the Compiler Design course (CS604A) at Guru Nanak Institute of Technology, consisting of multiple-choice questions, short answer questions, and long answer questions. It covers various topics related to compiler design, including parsing, grammar, lexical analysis, and code generation. The paper is structured into three groups, with specific marks allocated to each question.

Uploaded by

Bijay Nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Compiler Design

This document is an examination paper for the Compiler Design course (CS604A) at Guru Nanak Institute of Technology, consisting of multiple-choice questions, short answer questions, and long answer questions. It covers various topics related to compiler design, including parsing, grammar, lexical analysis, and code generation. The paper is structured into three groups, with specific marks allocated to each question.

Uploaded by

Bijay Nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
EVEN/SEM-VI/CS604A/R18/2022 aN B.TECHICS GURU NANAK INSTITUTE OF TECHNOLOGY An Autonomous Institute under MAKAUT 2022 COMPILER DESIGN CS604A TIME ALLOTTED: 3HR FULL MARKS:70 The figures in the margin indicate full marks, Candidates are required to give their answers in their own words as far as practicable GROUP -A (Multiple Choice Type Questions) Answer any ten from the following, choosing the correct alternative of each question: 10%1=10 Marks CO No, 1. (i) Which of the following error will not be detected by the compiler? 1 col a) Lexical error ») Syntactic error c) Semantic error 4) Logical error (ii) From X > YZ production rule, FIRST(X) is 1 03 a) FIRST(Y) b) FIRST(Y) U FIRST(Z) ©) FIRST(Y) U FIRST(Z) if FIRST(X) contains ¢ else FIRST(Y) @) FIRST(Z) (iii) _Lastpos of coneatenate node with left child cl and right child c2 is i cor a) lastpos(cl) U lastpos(c2) b) lastpos(e1) n lastpos(e2) ©) if (nullable(cl)) lastpos(c1) U lastpos(e2) else lastpos(e2) 4) if (nullable(c2)) lastpos(c1) U lastpos(c2) else lastpos(c2) (iv) A given grammar is not LL(1) if the parsing table of a grammar may contain 1 03 a) any blank field ) duplicate entry of same production ¢) more than one production rule in a cell 4) any field mentioned as error (¥) Ina programming language, an identifier is permitted to be a letter followed by any number 1 cos of letter followed by any number of letter or digits. If Land D denote the set of letters and digits respectively. Which of the following expressions defines an identifier? a) (L{D) + b) L.(L| Dy ©) (LD) @) LD Page Lot 4 (wi) (vii) (viii) (ix) Ww (xi) B.TECH/CSE/EVEN/SEM-VI/CS604A/R18/2022 Which of the following software tool is a lexical analyzer generator? a) Lex b) Yace ¢) Both Lex and Yace d) Neither Lex nor Yace Which of the following statements is false? a) An unambiguous grammar has same left most and right most derivation b) An LL(1) parser is a top-down parser ¢) An LR()) parser is a bottom-up parser d) An ambiguous grammar can never be LR(k) for any k Which one of the following is a top-down parser? a) Recursive descent parser ') Operator precedence parser ©) An LR(K) parser d) An LALR(k) parser Which of the following gra Q. Rare non-terminals and r, s,t are terminals. 1, P+QR 2, P+QsR 3. Poe 4, PoQrRr a) Lonly b) 1 and 3 only ¢) 2and 3 only d) 3and 4 only Annotated Parse tree is generated in the phase of 4) Syntax Analysis bb) Semantic Analysis ¢) Code Optimization 4) Intermediate Code Generation Consider the given below SDT Pl:S MN {S.val P2:;M— PQ {M.val Mwal + N.val} P.val * Q.val and Q.val =P.val} Seleet the correct option: ) Both P! and P2 are $ attributed b) PI is § attributed and P2 is L-attributed ¢) P1 is L attributed but P2 is not L-attributed d) Both Pl and P2 are L attributed mar rules violate the requirements of an operator grammar? P, 1 co2 1 co3 1 co3 1 co3 Page 2 of 4 6 (xii) a) b) a) b) a) b) a) b) °) a) b) B.TECH/CSE/EV! Three Address code involves a) Atleast 3 addresses b) At most 3 addresses ©) Exactly 3 addresses 4) Temary operator GROUP -B (Short Answer Type Questions) (Answer any three of the following) Write down the output of each phase for the expression b+e*70 [Assume a, b and ¢ are real numbers] ‘What is a handle? Consider the Grammar EEE | E*E | id Find the handles of the right sentential forms of reduction for the string id*id+id What is an operator grammar? Give an example. Consider the following conditional statement if(z>4) then y= 71 else y=10; From the above statements how many tokens are possible and what are they’? Eliminate left-recursion from the following grammar: S—Bb\a B— Be|Sd|e Consider the following grammar G A aAB | aBe |aAc Find an equivalent left-factored grammar of the above grammar. Generate an annotated parse tree for the string “4+S~2" using the grammar: E> E+T|E-T|T TO) 1/2/3)4/5)6|7/8|9 GROUP -~C (Long Answer Type Questions) (Answer any three of the following) Construct an ¢-NFA from the following regular expression: L=(a|b)*abb Construct the equivalent DFA of that e-NFA. What are the analysis phase and synthesis phase of a compiler? Construct a LL(I) Parsing Table for the following grammar: S—>aCDb Cele Dodie Explain the LL(1) Parser’s action by describing the moves it would make on an input acdbs V/SEM-VI/CS604A/R18/2022 co4 3xS=15 Marks CO No. 5 col 2 co3 3 co3 2 03 3 co4 3 co3 2 C03 5 C03 3x 1S=45 Marks CO No, 3 co2 10 co2 2 coi 10 03 3 C03 Page 3 of & 9. b) a) b) ° a) by °) a eS) 4 B.TECH/CSE/EVEN/SEM-VI/CS604A/R18/2022 ~ Compute the collection of sets of LR(0) item sets for the following grammar. ESET |T To TR|F Foa Construct the SLR parsing table using the SLR algorithm. Translate the expression a=-b*(e+d/b)—(e*f) into i) Quadruple ii) ‘Triple fii) Indirect Triple iv) iv) 3-address code Construct the DAG for the following basic block d= bie ex ath b= bte ared ‘Translate the expression a4(b+e/d) into syntax tree, Write short notes on any three of the following: Lex Context Free Grammar Parse Tree L-attributed Syntax Directed Definition Principle of sources of code optimization Unary Operators 10 Page 4 of 4 co3 co3 co2 co2 co2 co2 co3 co3 co4 co4

You might also like