QUESTIONS RELATED TO UNIT I, II And III

Similar documents
1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

2068 (I) Attempt all questions.

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI

GUJARAT TECHNOLOGICAL UNIVERSITY

Compiler Design Aug 1996

DEPARTMENT OF INFORMATION TECHNOLOGY / COMPUTER SCIENCE AND ENGINEERING UNIT -1-INTRODUCTION TO COMPILERS 2 MARK QUESTIONS

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

INSTITUTE OF AERONAUTICAL ENGINEERING

Question Bank. 10CS63:Compiler Design

1. (a) What are the closure properties of Regular sets? Explain. (b) Briefly explain the logical phases of a compiler model. [8+8]

Roll No. :... Invigilator's Signature :. CS/B.Tech(CSE)/SEM-7/CS-701/ LANGUAGE PROCESSOR. Time Allotted : 3 Hours Full Marks : 70

A simple syntax-directed

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR / EVEN SEMESTER

VALLIAMMAI ENGINEERING COLLEGE

CS 2210 Sample Midterm. 1. Determine if each of the following claims is true (T) or false (F).

INSTITUTE OF AERONAUTICAL ENGINEERING (AUTONOMOUS)

Compiler Construction

Compiler Construction

General Overview of Compiler

Downloaded from Page 1. LR Parsing

Summary: Semantic Analysis

CPS 506 Comparative Programming Languages. Syntax Specification

Section A. A grammar that produces more than one parse tree for some sentences is said to be ambiguous.

LECTURE NOTES ON COMPILER DESIGN P a g e 2

CS606- compiler instruction Solved MCQS From Midterm Papers

CS143 Handout 20 Summer 2011 July 15 th, 2011 CS143 Practice Midterm and Solution

Torben./Egidius Mogensen. Introduction. to Compiler Design. ^ Springer

CS 315 Programming Languages Syntax. Parser. (Alternatively hand-built) (Alternatively hand-built)

CMSC 330: Organization of Programming Languages

UNIT III & IV. Bottom up parsing


About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

QUESTION BANK CHAPTER 1 : OVERVIEW OF SYSTEM SOFTWARE. CHAPTER 2: Overview of Language Processors. CHAPTER 3: Assemblers

VIVA QUESTIONS WITH ANSWERS

ECE251 Midterm practice questions, Fall 2010

BSCS Fall Mid Term Examination December 2012

Context-Free Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

COMPILER DESIGN. For COMPUTER SCIENCE

UNIT-III BOTTOM-UP PARSING

VALLIAMMAI ENGINEERING COLLEGE

Concepts Introduced in Chapter 3. Lexical Analysis. Lexical Analysis Terms. Attributes for Tokens

Context-Free Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

Context-Free Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

CSCI Compiler Design

University of Technology Department of Computer Sciences. Final Examination st Term. Subject:Compilers Design

The analysis part breaks up the source program into constituent pieces and creates an intermediate representation of the source program.

LALR Parsing. What Yacc and most compilers employ.

Time : 1 Hour Max Marks : 30

Structure of a compiler. More detailed overview of compiler front end. Today we ll take a quick look at typical parts of a compiler.

Context-Free Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

A Simple Syntax-Directed Translator

EDAN65: Compilers, Lecture 06 A LR parsing. Görel Hedin Revised:

Context-free grammars

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

COL728 Minor1 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20

Compiler Construction: Parsing

Where We Are. CMSC 330: Organization of Programming Languages. This Lecture. Programming Languages. Motivation for Grammars

Concepts Introduced in Chapter 4

Parsing Algorithms. Parsing: continued. Top Down Parsing. Predictive Parser. David Notkin Autumn 2008

CST-402(T): Language Processors

Part 3. Syntax analysis. Syntax analysis 96

Parsing Wrapup. Roadmap (Where are we?) Last lecture Shift-reduce parser LR(1) parsing. This lecture LR(1) parsing

Using an LALR(1) Parser Generator

Architecture of Compilers, Interpreters. CMSC 330: Organization of Programming Languages. Front End Scanner and Parser. Implementing the Front End

CS308 Compiler Principles Syntax Analyzer Li Jiang

PART 3 - SYNTAX ANALYSIS. F. Wotawa TU Graz) Compiler Construction Summer term / 309

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully

SYLLABUS UNIT - I UNIT - II UNIT - III UNIT - IV CHAPTER - 1 : INTRODUCTION CHAPTER - 4 : SYNTAX AX-DIRECTED TRANSLATION TION CHAPTER - 7 : STORA

A programming language requires two major definitions A simple one pass compiler

Final Term Papers 2013

Top down vs. bottom up parsing

CSE 130 Programming Language Principles & Paradigms Lecture # 5. Chapter 4 Lexical and Syntax Analysis

VETRI VINAYAHA COLLEGE OF ENGINEERING AND TECHNOLOGY

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

Introduction to Syntax Analysis. The Second Phase of Front-End

4. Lexical and Syntax Analysis

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND ENGINEERING COURSE PLAN

Lexical and Syntax Analysis (2)

LR Parsing Techniques

Introduction to Parsing Ambiguity and Syntax Errors

Syntax Analysis Part I

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Chapter 4. Lexical and Syntax Analysis. Topics. Compilation. Language Implementation. Issues in Lexical and Syntax Analysis.

Introduction to Parsing Ambiguity and Syntax Errors

4. Lexical and Syntax Analysis

CSE P 501 Compilers. LR Parsing Hal Perkins Spring UW CSE P 501 Spring 2018 D-1

Syntax. Syntax. We will study three levels of syntax Lexical Defines the rules for tokens: literals, identifiers, etc.

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

COP5621 Exam 3 - Spring 2005

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages. Architecture of Compilers, Interpreters

Introduction to Syntax Analysis

CMSC 330: Organization of Programming Languages. Context Free Grammars

LR Parsing LALR Parser Generators

Bottom-up parsing. Bottom-Up Parsing. Recall. Goal: For a grammar G, withstartsymbols, any string α such that S α is called a sentential form

CS5363 Final Review. cs5363 1

PRINCIPLES OF COMPILER DESIGN

GUJARAT TECHNOLOGICAL UNIVERSITY

Transcription:

QUESTIONS RELATED TO UNIT I, II And III UNIT I 1. Define the role of input buffer in lexical analysis 2. Write regular expression to generate identifiers give examples. 3. Define the elements of production. Give examples. 4. Discuss brief lexical phase error. 5. Discuss neatly the language for specifying lexical analyzers. 6. Define Compiler. What are the phases of the Compiler? Explain with a neat diagram. 7. What are Compiler Construction Tools? Explain its specifications in detail. 8. Explain the role of lexical analyzer in detail. 9. Define finite automata. Explain its types in detail. 10. Construct NFA, DFA for the expression bb*. 11. Explain in detail about error detection and recovery. 12. Consider the following fragment of C code: float i, j; i = i * 70 + j + 2; Write the output at all phases of the compiler for the above C code. 13. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail. 14. Explain the different phases of a compiler, showing the output of each phase, using the example of the following statement: position : = initial + rate * 60 15. What is cross compiler? How is bootstrapping of compiler done to second machine. 16. Write short note on a) Incremental compiler b) Bootstrapping compiler. 17. How lexical analyzer removes white spaces from a source file. 18. Give lex specification in details. UNIT II 19. Construct a parse tree to the string-(id+id) using left most derivation. 20. What is ambiguous grammar? Eliminate ambiguities for the grammar: E -> E + E E E (E) id.

21. Define Parser. Construct the derivation of parse trees 22. Distinguish between parse tree and syntax tree. 23. Consider the following grammar. S -> 0A 1B 0 1 A -> 0S 1B 1 B -> 0A 1 S Construct leftmost derivations and parse trees for the following sentences i. 0101 ii. 1100101 24. Explain top-down parsing. Give example. 25. Explain the principle of predictive parser. Give an example. 26. Explain the different moves of LR Parser on id* id + id. 27. Construct SLR parsing table for the following grammar. S ->AS b A -> SA a 28. Construct predictive parsing table for the following grammar. E -> T E' E' -> +T E' e T -> F T' T' -> *FT' e F -> (E) id 29. What is an operator grammar? Give an example. 30. Write an operator precedence parsing algorithm. 31. What are the advantages and disadvantages of operator Precedence parser? 32. Write a note on the specification of a simple type checker. 33. What is a type expression? Explain the equivalence of type expressions with an appropriate examples. 34. What is recursive descent parser? Construct recursive descent parser for the following grammar. E -> E + T T T -> T* F F F -> a b 35. Define LR(k) parser. Draw and explain model of LR parser. 36. Write LR parsing algorithm.

37. Consider the following grammar : G -> S $ S -> AM M-> S A -> ae baa E -> ab ba ε B -> be abb Is the above grammar LL(1). If so, construct LL(1) parsing table. If no, explain why? 38. Find FIRST and FOLLOW of the following :- a) S -> aab ba ε b) S-> v XUW UV uwv A -> aab ε U -> w WvX SUVW SWX ε B -> bb c V -> x wx ε W -> w UXW X -> yz SuW SW 39. Are following grammars LL(1). (1) E -> E+T T (2) E -> E + T T (3) S-> AaAb BbbA (4) S-> ietss T-> T*F F T -> TF F A-> ε S -> es E F -> (E) id F-> F* a b B-> ε E->b (5) exp->atom list (6) decl -> type list atom-> num id type -> int float list->(exp ) list -> id,list id exp ->exp exp exp 40. Construct LR(1) parsing table for following : S->aBD AB DAC b A-> SCB SABC CbD C ε B->d ε C->ADC c D->SaC SC fg 41. Construct LR(0) parsers for each of the following: a) S->cA ccb b) S->aSSb asss c c) A->cA a d) B->ccB b 42 Find canonical collection of LR(0) items for following grammar : E-> E+T T T->T*F F F->(E) id 43 Construct LALR items for following grammar :

E-> E+T T T->T*F F F->(E) id 44. Construct LALR parsing table for following grammar: S-> B B-> begin DA end D-> Dd; ε A-> A;E ε E-> B S 45. Write LEX specifications and auxiliary routines, if any, to read source text file and display total number of characters, words and lines in the file. (16M) 46. Write a CFG to parse an assignment statement consisting of arithmetic expression on RHS of the assignment. +, * and / operators needs to be supported with + having higher precedence and left associative and * and / have equal precedence but lesser than + and both are right associative. Is your grammar suitable for top-down table driven parser? If not, write equivalent suitable grammar. Compute First and Follow sets of non - terminals of the CFG. (10M) 47. Construct LALR parser table for the following CFG S -> A = B S -> B B -> A A -> * B A -> I Here, I (representing identifier), * and = are terminal symbols, S is the start symbol and A & B are non -terminals. Resolve the conflicting entries, if any, in the parser table and justify. Show the moves of the LALR parser for the following input. *p = *q (18M) 48. How YACC handles different types of conflits in parser? (4M) 49. Construct SLR parser for following grammar: [8] S a SS b S a SSS S c Show moves of above parser on one valid input string and one invalid input string. 50. Explain the use of LR Parsing method. 51. Whether lexical analysis detects any errors? Explain with example. 52. Explain the following : i) token. ii)pattern. iii) lexeme 53. Explain Recursive Descent parser with an example 54. What is Shift-Reduce and Reduce-Reduce conflict? How these can be resolved? With examples explain in which condition S-R and R-R conflict can occur in SLR, canonical LR and LALR parsers. (Make use of LR(0), LR(1) items). [10] UNIT III 1. Write the function of syntax directed translation. 2. Write semantic actions to the set of procedure. S->E$

E ->E+E E->E+E E->(E) E->I I->I digit I->digit. 3. Explain the implementation of syntax directed translators. 4. Write short notes on the following: (a) S-attributed definitions. (b) L-attributed definitions. (c) Dependency graph. 5. Write an ATG for floating point value of a decimal number given by following grammar : Dnum -> num. num num -> num digit digit digit -> 0123456789 6. Consider following ATG : Production Semantic Rule S -> ABC B.u = S.u ; A.u =B.v + C.v ; S.v = A.v A ->a A.v = 2 * A.u B -> b B.v = B.u C-> c C.v = 1 Draw the parse tree for the string abc, draw dependency graph, describe the order of evaluation, Suppose S.u=3 then what is the value of S.v when evolution finished. 7. Explain the need of semantic analysis. Position of type checker. 8. Explain synthesized and inherited attributes 9. What do you meant by attributed translation grammar (ATG)? What are synthesized and inherited attributes? What type of attribute (synthesized or inherited) will be required in C and PASCAL to enter in the symbol table the type information of variables appeared in declarative statements? Variables may be of simple types such as integers and float or array of simple types. Write the ATG for both the languages.(8m) 10. Generate annotated parse tree for following expression: [6] a*b-c/e + f 11. Explain bottom-up evaluation of L-attributed grammar(6m)

12. What is typecasting? What changes should be made in the semantic analyzer to add typecasting? (6M) 13. Explain Translation Scheme and Syntax Directed Definition with example.(8m) 14. Explain Bottom up evaluation of S-Attributed Definiton.(6M) 15. Write three address code to the statement A=-B*(C+D). 16. Write the quadruple, triple, indirect triple for the statement a: = b * - c + b * - c. 17. Give sequence of 3-address code for following in form of quadruples, triples and indirect triples 1. 2+3+4+5 2. 2+(3+(4+5)) 3. a*b+a*b*c 4. a[a[i]]=b[i[2]] 18. Give three address code for 1. read a 2. read b 3. if b=0 then 4. b=1; 5. else 6. do i. temp = b; ii v = a-a b*b iii a = temp; 7. while (b=0) 8. write (a) 19. Write CFG and semantic actions to parse and handle procedure calls and returns. Show the intermediate code for the following source statement in a) Quadruples and b) Triples notations. a = func (p, q, r); 20. What are Marker non-terminal symbols? Explain their significance for generation of intermediate code for flow - of - control statements UNIT I (Rest Part) 1. Explain the advantage of indirection in symbol table. 2. Explain the formulate of activation record.

3. Write notes on implementing block structured language. 4. What is an ordered and unordered symbol table? What is the function of symbol table in the compilation process? Explain. 5. What are the various attributes of a Symbol Table. 6. Compare three different storage allocation strategies. 7. Discuss the Display Mechanism used by the Pascal compiler to handle access to non - local names with adequate illustrations. [10] 8. Compare static scope with dynamic scope. Illustrate with suitable examples. [8] 9. What do you meant by activation record? With a neat sketch, describe the activation record used by a C compiler. [8] 10. With suitable examples explain various parameter passing methods. Also explain the mechanism needed to support procedure parameter. [10]