Compiler Qbank

You might also like

Download as pdf
Download as pdf
You are on page 1of 4
Sanjivani College of Engineering Department of Computer Engineering Compiler Construction Question Bank UNIT 1 Sr No Question co | BIL |What is Compiler? Explain all the phases of Compiler. Explore Interaction between the lexical analyzer and the parser with diagram Describe Input Buffering used in Lexical Analyzer. /main() { int a; printf{“Hello World”); } Determine the lexemes and corresponding tokens in the given program. Draw and explain the architecture of a lexical analyzer generated by Lex Ilustrate Structure of LEX Program with example ‘Compare Compiler with Interpreter. Explain Language-processing System with diagram welolafalu [Demonstrate different phases of compiler by showing the translation of assignment statement for each phase position = initial + rate * 60 wirfalele Discuss Analysis and Synthesis phase in compilation. Describe different Compiler Construction Tools 12 Explain Tokens, Patterns and Lexemes with examples 13 Write the Regular Definitions for C identifiers and Unsigned numbers (integer or folating point) wletats 14 Write patterns and construct transition diagrams for following tokens : relational operator, identifiers, and unsigned numbers 15 Why the analysis portion of a compiler is separated into lexical analysis and parsing (syntax analysis) phases 16 Explain different operations on languages with example 17 How Lexical Analyzer is created using LEX 18 Write the LEX program for generating ‘C’ Tokens 19 Write the C++ function to simulate the transition diagram of relational operator token wlelrfe 20 [Explain Commutative and Associative Laws for regular expressions with example Prof N.G.Pardeshi Y io Prof, C.V.Longani oy Approved by Dr.D.B.Kshirsagar Sanjivani College of Engineering Department of Computer Engineering Compiler Construction Question Bank UNIT IL Sr'No Qui BIL Associate the use of Context Free Grat ‘Compare Top down and Bottom up parsers, Whats Lf Factoring? Let actor he lowing grammar: D—TL; T—inv/float List-sidistia we folg What is Left Recursion? Eliminate Left Recursion from the following grammar; G: ‘S—aBDh B-Bblc D-EF Egle Fofle G: S—SSHSS*|a (Costruct LALR parsing table for the given grammar. Parse id*id using the given grammar. G: ESE+TIT TT*FF E-(6)jid Use LR(0) parsing Construct LL(1) parsing table for the given Grammar. S—iEISS"la S'+reS|e Eb Find First and Follow for the given grammar, S—iEtSS'la [S'—+eS} ¢ Eb (Compare different LR parsers. Illustrate position of Parser in Compiler model with proper diagram Write CFG for simple arithmetic expressions and give the derivations for the string id+id*id [What is ambiguous grammar justify with example Consider the context-free grammar: $-> SS+/SS*| a and the string ata” . ; a) Give a leftmost derivation for the string. b) Give a rightmost derivation for the string. |c)Give a parse tree for the string. 4) Is the grammar ambiguous or unambiguous? Justify your answer. ©) Describe the language generated by this grammar. 14 |What is Left Recursive grammar? Eliminate Left Recursion fro1 A E->E¢T|T ym following grammar T ->T*F | F 15 |Why Left Factoring of grammar is necessary Perform Left Factoring on following grammar 'S --> iEtS | iEtSeS | a E—>b 16 | Construct Predictive Parsing Table for following grammar and show the Moves made by a predictive Parser on input id + id * id E->TE’ E’-->+TE’ |e T—> FT T > *FT Je F->(B)|id 17 ‘Compute the FIRST and FOLLOW sets for following grammar E->TE’ E’—>+TE’ |e T—>FT TFT |e F—>()|id 18 Illustrate Model of a table-driven predictive parser with diagram 19 What are the actions of shift-reduce parser? Show the Stack, Input and Action of shift-reduce parser while parsing the input string id1*id2 20 | Construct SLR Parsing Table for following grammar /E—>E+T|T T>T*F|F F—>(6)|id | Show the moves of parser on id*id+id 21 | Construct LALR parsing table for following grammar S->CC IC --> eC cd &, Approved by Prof N.G.Pardeshi ; Prof. C.V.Longani wy Sanjivani College of Engineering Department of Computer Engineering Compiler Construction Question Bank UNIT II Sr'No ‘Question co [BTL 1 __ | Explain annotated parse tree with an example. 3 3 2 _|Compare L-attributed and S-attributed definition. 3 4 3__|Whatis SDD? Write Syntax Directed Definition for a simple desk calculator. 3 3 4 [Construct annotated parse tree for the input string 3*5+4nusing SDD fora | 3 3 simple calculator Write Syntax-directed definition for simple type declarations? 3 3 /Show Dependency graph for a declaration float idl, id2, id3 using SDD for 3 3 simple type declarations 7 |Whatis S-attributed definition? Give example of S-attributed definition 2 8 _ | What is L-attributed definition? Give example of L-attributed definition 2 9 [Construct annotated parse tree for the input int a,b,c using SDD for simple type declaration 10 _ [Explain applications of Syntax Directed translations. 3 2 11 _ | Show Dependency graph for a declaration int a, b, ¢ using SDD for simple 3 3 type declarations 12 | What is SDD? Explain synthesized and inherited attributes with respect to 3 2 SDD 13 | Write S-attributed definition for constructing syntax trees for a simple 3 3 expression grammar, also show the construction of a syntax tree for the input ja-4+e 14 _ | Write L-attributed definition for constructing syntax trees for a simple 3 3 lexpression grammar, also show the construction of a syntax tree for the input ja-4+e 15 | Explain dependency graph with proper example 3 3 16 | What is postfix SDT? Write postfix SDT for implementing the desk calculator | _ 3 3 17 __ | What is Parser- Stack implementation of Postfix SDT’s? Write SDT for 3 3 |Implementing the desk calculator on a bottom-up parsing stack 18 | Justify with proper explaination that SDD containing following productions 3 3 land rules is L-attributed T—> FT IT’ > *FT,’ inh = T’.inh * F.val 19 | Justify with proper explaination any SDD containing the following production | 3 3 land rules cannot be L -attributed JA->BC As=Bb Biz f(Cc,As) 20 _ [Explain topological sort for dependency graph with example 3 3 i Dy q Approved by Prof N.G-Pardeshi Vike Prof. C.V.Longani

You might also like