0 Голоса «за»0 Голоса «против»

Просмотров: 3.0K67 стр.Dec 28, 2011

© Attribution Non-Commercial (BY-NC)

DOC, PDF, TXT или читайте онлайн в Scribd

Attribution Non-Commercial (BY-NC)

Просмотров: 3.0K

Attribution Non-Commercial (BY-NC)

- Pcd Record
- System Software Unit-II
- PCD Lab Manual
- Mobile Phone Operating System Ppt
- Principles of Compiler design
- VisiCodeMiner - Discovering the Business DNA
- Syntax Directed Translation
- First and Follow Set
- Error Detection Recovery
- 040
- Regulation2004 Sylabus.pdf
- Example Program for the Lex and Yacc Programs
- JavaTranslator
- GateGenie cs
- Compiler Design by Ullman Aho]
- GATE Solved Question Papers for Computer Science and Information Technology [CS] by AglaSem.Com
- System Software Question Bank 2012 With Part-B Answers
- Compiler Design
- CHAP09
- Compiler Construction Lecture 6

Вы находитесь на странице: 1из 67

SUBJECTWISE DETAILS 1.1 AUTOMATA AND COMPILER DESIGN 1.1.1 1.1.2 1.1.3 1.1.4 i. ii. Objectives and Relevance Scope Prerequisites Syllabus JNTU GATE iii. 1.1.5. 1.1.6 1.1.7 1.1.8 1.1.9 1.1.10 1.1.11 1.1.12 1.1.13 i. ii. IES

Suggested Books Websites Experts Details Journals Recent Findings and Developments Session Plan Tutorial Plan Student Seminar Topics Question Bank JNTU GATE iii. IES

1.1.1

The theoretical foundations of computer science have expanded substantially in recent years. The objective of this course is to introduce students to this fundamental area of computer science, which enables students to focus on the study of abstract models of computation. These abstract models allow the students to assess via formal reasoning what could be achieved through computing when they are using it to solve problems in science and engineering. The course exposes students to the computability theory, as well as to the complexity theory. The goal is to allow them to answer fundamental questions about problems, such as whether they can or not be computed, and if they can, how efficiently. The course introduces basic computation models and their properties, and the necessary mathematical techniques to prove more advanced attributes of these models. The students will be able to express computer science problems as mathematical statements and to formulate proofs. Upon completion of this course the students are expected to become proficient in key topics of theory of computation, and to have the opportunity to explore the current topics in this area. The theory of formal languages and theoretical foundations of computer science, find their applications in areas like Program Verification, Cryptography, Distributed Computing, Mathematical Logic in Computer Science, Models and Logics for Reactive Systems, Semantics of Computation, compiling techniques, robotics, artificial intelligence and knowledge, complexity analysis, Systems Biology, Verifying correctness of circuits and protocols. 1.1.2 SCOPE

The purpose of this course is to acquaint the student with an overview of the theoretical foundations of computer science from the perspective of formal languages and design of compilers . "Computer Science is a cluster of related scientific and engineering disciplines concerned with the study and application of computations. These disciplines range from the pure and basic scientific discipline concerned with the foundations (or theory) of computer science (or of computation) to engineering disciplines concerned with specific applications." The growing importance of this research area is motivated not only by industrial concerns, but has a very solid scientific basis. Indeed, in Computer Science we build artifacts---implemented in hardware, software or, as is the case in the fast-growing area of embedded and interactive systems, using a combination of both---that are supposed to offer some well defined services to their users. Since these computing systems are deployed in very large numbers, and often control crucial, if not safety critical, industrial processes, it is vital that they correctly implement the specification of their intended behavior. The problem of ascertaining whether a computing system does indeed offer the behavior described by its specification is called the correctness problem, and is one of the most fundamental problems in Computer Science. The field of Computer Science that studies languages for the description of (models of) computer systems and their specifications, and (possibly automated) methods for establishing the correctness of systems with respect to their specifications is called (algorithmic) formal verification. The theory of computation can be sub-divided into numerous overlapping areas, and one of the main beauties of this scientific area is the unexpected interplay amongst these. Two main clusters of areas are complexity theory and algorithms. Examples of other related fields include Algorithmic Program Verification, Cryptography, Distributed Computing, and Mathematical Logic in Computer Science, Models and Logics for Reactive Systems, Semantics of Computation, compiling techniques, robotics, artificial intelligence and knowledge and Systems Biology. The emphasis in all of these areas is on the study of computational phenomena based on rigorous mathematical foundations. 1.1.3 PREREQUISITES

This course requires knowledge in mathematical preliminaries likes: sets, relations, functions, graphs, strings and principles of mathematical induction and knowledge about compilers operation.

1.1.4.i

SYLLABUS JNTU

UNIT I OBJECTIVE The main aim of this unit is to know the fundamentals of this subject, and definitions of different terms coming in this subject, and also the introduction for Finite automata and basic type of machines. SYALLBUS Formal Language and Regular Expressions: Languages, Definition Languages regular expressions, Finite Automata-DFA, NFA. Conversion of regular expression to NFA, NFA to DFA. Applications of Finite Automate to lexical analysis, lex tools. UNIT II OBJECTIVE In this unit we know the concept of context free grammars and languages. We define derivation tree, we know the methods of simplifying context free grammars. Finally about two normal forms and properties of context free language. SYALLBUS Context Free grammars and parsing: Context free grammars, derivation, parse trees, ambiguity LL(K) grammars and LL(1) parsing. UNIT III OBJECTIVE In this unit we know what is an regular expression i.e as a means of representing certain subsets of strings over sigma and we conclude that regular sets are precisely those accepted by finite automata. We know the closure properties of regular sets. Finally we can understand the relation ship between regular set and regular grammar. And also , we know the concept of grammar formalism i.e (about different grammars like right and left) and equivalence between regular grammar and finite automata. Finally we have introduction to context free grammar, derivation tree etc. SYALLBUS Bottom up parsing handle pruning LR Grammar Parsing. LALR parsing, parsing ambiguous grammars, YACC programming specification. UNIT IV OBJECTIVE In this unit we know the concept of grammar formalism ,their syntax translation this unit also gives the concept of intermediate code generation by using symbol tables and also translation of various statements like control flow statements. SYALLBUS Semantics: Syntax directed translation, S-attributed and L-attributed grammars, Intermediate code abstract syntax tree, translation of simple statements and control flow statements.

UNIT V OBJECTIVE In this unit we know about Chomsky hierarchy. We construct a automata called liner bounded automata and concept of LR(0) grammar and decidability problems in Turing machine and also we study different type expressions and overloading functions and operations SYALLBUS Context Sensitive features Chomsky hierarchy of languages and recognizers. Type checking, type conversions, equivalence of type expressions, overloading of functions and operations. UNIT VI OBJECTIVE In this unit we learn ,storage allocation for various data items of a procedure defined for a problem statement . Basic approach followed is dynamic(Run time) is followed. SYALLBUS Run time storage: Storage organization, storage allocation strategies scope access to now local names, parameters, language facilities for dynamics storage allocatin. UNIT VII OBJECTIVE In this unit we have introduction of code optimization approach. Different optimization mechanisms are also studied. Different flow diagrams for data and control statements are also studied SYALLBUS Code Optimization: Principal sources of optimization, optimization of optimization, flow graphs, Data flow analysis of flow graphs. UNIT VIII OBJECTIVE In this unit we learn the code generation techniques . different types of code generations studied in this unit are machine dependent , generic code etc. After completion of this unit student gets the concept of how a object code for a program of a particular language is generated SYALLBUS Code generation: Machine dependent code generation, object code forms, generic code generation algorithm, Register allocation and assignment. Using DAG representation of Block. 1.1.4.ii. SYLLABUS - GATE UNIT-I Finite Automata UNIT-II Context free languages UNIT-III basic blocks, peephole

Parsing techniques UNIT-IV Attributed grammars UNIT-V Chomsky languages and recognizers UNIT-VI Run time storage allocation UNIT-VII Code Optimization UNIT-VIII Code generation 1.1.4.iii SYLLABUS IES Not applicable. 1.1.5 SUGGESTED BOOKS

TEXT BOOKS T1 T2. Introduction to Theory of Computation Sipser 2nd edition Thomson Compilers and Principles , Techniques and tools Aho , ullman , Revesethi pearson Edu.

T3 Introduction to Automata Theory, Languages and Computation, Jhon E. Hopcroft, Jefferg D. Ulman T4 T5 Introduction to Computer Theory, II Edition Danicl I.A. Cohen. Compilers Principles, Techniques and Tools, Alfred V.Aho, Ravi Sethi, Jeffery D.lman LPE. Compiler Writing, BS Publications, Jean-Paul Trumblay, Paul

Modern compiler construction in C , Andrew w. Apple Cambridge Univ. Press Compiler construction Louden , Thompson WEBSITES www.ieeeexplore.ieee.org www.acm.org/dl www.cs.vu.nl www.cs.unm.edu www.people.westminstrcolleg.eud www.doi.ieeecomputersociety.org www.mitpressjournal.com www.deloreie.com/gnu/docs www.compilerconnection.com

10.

www.cse.lehigh.edu/~cheng/

1.1.7

EXPERT DETAILS

REGIONAL 1. Name Designation Department Address Phone E-Mail 2. Name Designation Department Address Phone E-Mail 3. Name Designation Department Address Phone E-mail : : : : : : : : : : : : : : : : : : OB Venkata Ramanaiah Assistant Professor Dept. of Computer Science JNTU, Kukatpally Hyderabad. 040-23158661 to 23158664 jntuadm@hd2.dot.net.in , info@jntu.ac.in G.Vijaya Kumari Assistant Professor Dept. of Computer Science JNTU, Kukatpally Hyderabad. 040-23158661 to 23158664 jntuadm@hd2.dot.net.in , info@jntu.ac.in Madhu Mutyam Assistant Professor International Institute of Information Technology Gachibowli Hyderabad 500032 91-40-23001967 Ext: 177 Madhu_mutyam@iiit.ac.in

NATIONAL 1. Name Designation Department Address Phone Email Name Designation Department Phone Email Name Designation Department Address Phone Email : : : : : : : : : : : : : : : : : Prof. Mrs Priya Chandran Professor Computer Science National Institute of Technology Calicut +91 495 2286804 priya@nitc.ac.in Mr. Murali krishnan K Lecturer National Institute of Technology Calicut +91 495 2286660 kmurali@nitc.ac.in Dr. Sanjay Kumar Jena, Professor Professor Department of Computer Science & Engineering, Qr. No: D-24, NIT Campus, Rourkela-769008 0661-2462352 skjena

2.

3.

INTERNATIONAL 1. Name Designation Department : : : John E.Hopcroft Dean Engineering Professor of Computer Science

Address Phone E-mail 2. Name Designation Department Address Phone E-mail Name Dsignation Department Adresse Phone E-mail 1.1.8 1. 2. 3. JOURNALS Name of the Journal Publisher Name of the Journal Publisher Name of the Journal Publisher 4. 5. 6. 7. 8. 9. 10. 11. Name of the Journal Publisher Name of the Journal Publisher Name of the Journal Publisher Name of the Journal Publisher Name of the Journal Publisher Name of the Journal Publisher Name of the Journal Publisher Name of the Journal

: : : : : : : : : : : : : : :

4130 Upson Hal Cornell Univerity, Ithaca, NY 1453-7501. 607-255-7316 WWW@cs.cornell.edu Jeffrey D.Ullman Professor at Stanford University Computer Science Stanford W.Ascherman 650-725-4802 ullman@cs.stanford.edu Pascal Weil Labri Professor Universit Bordeaux I 351 cours de la Libration 33405 Talence Cedex, France. +33 5 40 00 69 28 Pascal.Weil@labri.fr.

3.

: : : : : : : : : : : : : : : : : : : : :

Journal of Artificial Intelligence Research (JAIR) Association for computing Machinery (ACM) Journal of Machine Learning Research (JMLR) Springer Netherlands Publications Journal of American Society for Information Science and Technology (JASIST) Inder Science Publications Journal of Intelligent Information Systems(JIIS) Springer USA Publications ACM Transactions on Information Systems(TOIS) Springer Boston Publications ACM Transactions of Internet Systems (TOIS) Acta Informatic Publications ACM Transactions on Programming Languages and Systems Springer Berlin Publications International Journal of Intelligent Systems Acta Informatic Springer Berlian Publications International Journal of Digital Libraries Beijing Publisher China Journal of Documentation Springer Netherlands Publications Journal of Intelligent Systems

: : :

7.1.9 1.

RECENT FINDING AND DEVELOPMENTS Title Author Journal Year, Vol. & Page No. : : : : : : : : : : : : : : : : : : : : Computing optional description for optimality theory grammars With context free position structures Bruce Tesar Association for computational Linguistics 1996, vol. 211, 101-107 Lower bounds on information transfer in distributed comutations H.Aderson IEEE symp foundations of Computer Science 1978, vol.299, 151-158 A family of NFAs which need 2n-Deterministic states Kazuolwana, Akiniro, Masuuva, Mikapaterson Elsevier Science Publications Ltd. 2003, vol.301, 451-462 The parallel complexity of simple logic programs, Foto Afrati, Chritos H.Papadimitriou Acm press New York,Ny, USA 1978, vol.40, 891-916 DNA computing by blocking G.Rozenberg, H.Sppairk, Elsevierscience publisher ltd 2003, vol. 292, 653-665

2.

3.

Title Author Journal Year, Vol. & Page No. Title Author Journal Year, Vol. & Page No. Title Author Journal Year, Vol. & Page No.

4.

5.

1.1.10 S.No

5 6 7

8 9 10 11

12 13 14 15 16

Topics covered in JNTU No. of Modules and Sub modules Suggested Books syllabus Lectures UNIT I FORMAL LANGUAGE & REGULAR EXPRESSIONS (No. of Lectures 9) Definition T4-Ch1 (P:7-12) Introduction to Defining L1 T6-Ch1 (P:1-4) Languages Language L2 T6-Ch3 (P:68-87) R1-Ch1 (P:7-12) Kleene closure exams T1-Ch1(P:63-66) Definition Languages Regular Formal Definition L3 T6-Ch3 (P:151-155) Expression R1-Ch1 (P:18-21) Formal Definition L4 T1-Ch1(P:31-56) T3-Ch2(P:51-70) Finit Automata DFA, NFA T6-Ch4(P:156-165) Designating, Examples L5 R1-Ch1(P:21-23) T2-Ch3(P:99-103) Conversion of Regular T3-Ch3(P:97-99) Condition and Examples L6 Expression to NFA T6-Ch4(P:166-168) R1-Ch1(P:25-27) T2-Ch3(P:96-99) NFA to DFA Condition and Examples L7 T6-Ch4(P:170-177) R1-Ch1(P:27-30) Applications of Finit Automata T3-Ch2(P:45-46) Lexical Analyzers, Text Editors L8 to Lexical Analysis T6-Ch4(P:142-144) T5-Ch1(P:22-23) Complier constructions Lex Tools L9 T6-Ch1(P:4-11) tools,phases R1-Ch1(P:5-7) UNIT II CONTEXT FREE GRAMMERS AND PARSERS(No. of Lectures 5) T1-Ch2(P:101-108) Context free grammars Formal definition examples L10 T6-Ch2(P:42-49) R1-Ch3(P:41-43) T2-Ch4(P:134-140) Derivations Trees L11 T6-Ch2(P:35-36) R1-Ch3(P:42-43) T2-Ch4(P:138-140) Parse Trees Ambiguity L12 T6-Ch2(P:31-34) R1-Ch3(P:43-46) T2-Ch4(P:148-158) Ambiguity LL (K) grammars, Predictive Parsers, first and L13 T6-Ch6(P:235-241) LL (1) parsing follow, constructions, L14 R1-Ch3(P:46-54) UNIT III BOTOM UP PARSING (No. of Lecturers 8) T2-Ch4(P:158-160) Botom up parsing Handling L15 T6-Ch7(P:274-285) Handling parsing Parsing techniques L16 T2-Ch4(P:160-161) T2-Ch4(P:174-190) Algorithms, Construction of SLR, L17 LR grammar parsing T6-Ch7(P:341-370) CLR parsing tables 18 R1-Ch3(P:56-65) T2-Ch4(P:191-199) LA LR Parsing Construction L19 T6-Ch7(P:370-375) R1-Ch3(P:65-67) Parsing Ambiguous grammar Special case production, L20 T2-Ch4(P:199-208) L21 R1-Ch3(P:68-69)

GATE

GATE

GATE

17

L22

UNIT IV - SEMANTICS (No. of Lectures 5) Definitions, Synthesized, T2-Ch5(P:226-237) L23 18 Syntax directed translation Inherited attributes, Dependency T5-Ch5(P:280-287) L24 graph T6-Ch11(P;536-538) T2-Ch5(P:240-244) 19 S-attribute & L-attribute Definition, translation schemes L25 T5-Ch5(P:293-301) 20 Conditions L26 T2-Ch5(P:240-244) Intermediate Code Abstract T6-Ch10(P:525-527) syntax tree R1-Ch4(P:92-94) Translation of simples 21 statements and control flow statements 22 23 24 25 Implementation of three address code L27 T5-Ch8(P:470-473) T5-Ch8(P:504-506) T6-Ch10(P:523-525) GATE

26 27

UNIT V CONTEXT SENESTIVE FEAUTURES (No. of Lectures 4) Chomsky Hierarchy of T3-Ch9(P:217-223) Types of languages L28 languages and recognizers T1-Ch2(P:108-111) T2-Ch6(P:277-281) Type systems, Type expression, Type Checking L29 T5-Ch6(P:343-349) Type conversions R1-Ch5(P:118-123) T2-Ch6(P:285-290) Equivalence of type expression Structure, names cycles L30 T5-Ch6(P:352-359) R1-Ch5(P:115-118) Overloading of Function & Set of possible types for a subL31 T5-Ch6(P:361-364) operation expression UNIT VI RUN TIME STORAGE(No. of Lectures 8) L32 T2-Ch7(P:303-306) Sub-division of run time memory, Storage Organization L33 T6-Ch9(P:477-483) activation records L34 R1-Ch6(P:125-134) Storage allocation strategies, L35 Static allocation, stack location, T5-Ch7(P:404-423) Scope excess to non-local L36 dangling, references T6-Ch9(P:477-480) names, parameters L37 Language facilities for dynamic Explicit allocation of fixed sized, storage allocation variable sized blocks Function preserving transformation, Loop optimization Use of Algebraic identifiers Redundant loads and stores, flop control optimization Dominators, natural loops, inner loops Points Definitions, structured programs , conservative estimations of data flow information, computation of in L38 L39 T5-Ch7(P:440-446) T6-Ch9(P:480-519) T2-Ch10(P:430-438) T6-Ch12(P:610-654) T5-Ch10(P:592-598) T2-Ch10(P:441-444) T5-Ch10(P:598-602) T2-Ch10(P:438-441) T5-Ch9(P:545-557) T2-Ch10(P:444-449) T5-Ch12(P:660-678) T5-Ch10(P:602-608) T2-Ch10(P:449-461) T5-Ch10(P:608-620) T6-Ch12(P:655-678) T5-Ch10(P:662-670)

GATE

28

UNIT VII CODE OPTIMIZATION (No. of Lectures 11) 29 Principles sources of optimization L40 L41 L42 L43 L44 L45 L46 L47 L48 L49 GATE

30 Optimization of basic blocks 31 Peep hole optimization 32 Flow graphs 33 Dataflow analysis of flow graphs

and out L50 UNIT VIII CODE GENERATION (No. of Lectures 11) T2-Ch9(P:412-416) L51 Machine dependent code Impel code generator, registered T2-Ch9(P:371-398) 34 L52 generation and address description T5-Ch9(P:535-541) L53 35 Object code forms 36 37 38 Generic Code generation Algorithm Register Allocation & Assignment Symbolic debugging of optimized code, effect of global optimization Code generation Algorithms, Generating code from DAGs Global register Allocation L54 L55 L56 L57 L58 L59 L60 L61 T2-Ch10(P:522-529) T2-Ch9(P:403-412) T5-Ch:9(P:557-567) T6-Ch13(P:686-690) T5-Ch9(P:541-546) T2-Ch9(P:398-403) T5-Ch9(P:546-554) T6-Ch12(P:620-631)

Topics Scheduled Definition Languages Regulation Expressions Finite Automata DFA NFA, Legs Tools Context free grammars, Predictive Parsing Bottom up parsing YACCAutomatic parser generator Syntax Directed Translation Translation of simples statements and control flow statements Chomsky Hierarchy of languages and recognizers Type Checking

Salient topics to be discussed Formal Definition, Regular sets, Properties, Conversation. Formal Definitions, Conditions, Conversitions of NFA to DFA, Applications of Finite Automata, Facases of complier. Notational Conventions. Derivations and Parse Trees Ambiguity Preprocessive steps required for Predctive parsing, Fist and Follow construction of parsing tables. LR & SLR parsing, LALR parsing, LR grammars Precedence of Terminals and Productions, Implementation of LR Parsing Tables. S-attributed and L-attributed grammars, Abstract syntax tree Syntax directed translations schemes All the types of grammars Type systems, type conversions, equivalence of type expressions, overloading of functions and operations Storage allocation strategies, static allocation, stack allocation, Explicit allocation of fixed sized, variable sized blocks, Implicit De allocation.

3. 4. 5. 6. 7. 8. 9. 1 0. 1 1. 1 2.

23-09-08 30-09-08

1 3. 1 4. 1 5. 1 6. 1.1.12 1.

14-09-08

Sources of optimization, scope optimization, local optimization Loop Detection, Peephole optimization, Optimization in basic blocks, Data Flow analysis, structured program, General control flow. Object programs Environment of the code generator Problems in code generation Code generation from DAGs A heuristic ordering for DAGs

21-09-08

21-09-08

21-09-08

STUDENT SEMINAR TOPICS Title Author Journal Year, Vol. & Page No. Title Author Journal Year, Vol. & Page No. : : : : : : : : : : : : : : : : : : : : : : : : Descriptional complexity of finite automata Juraj Hromkovic Journal of Automata, Languages and combinotorics 2002 ,Volume 7, Issue 4,Pages 519-531 Formal semantic for computer languages and its applications compiler - complier Foto Afrati, Chritos H.P. Papadimitriou Comm. ACM 1978, vol. 9:1, 3-9 Semantics of context free languages, math. Systems theory D.Seeley 1998, Vol. 2:2, 127-145 The storage allocation strategies G.J. Simmons Comm. ACM 1970, vol.8:2, 111-112 A Parser-generating system for constructing compressed H.Aderson Comm. ACM 1988, vol. 16:11, 669-676 TMG-Syntax directed compiler RC HOLT ACM national conf. 2001, vol. 12:11, 262-274

2. in a

3.

1. Title

Author Journal Year, Vol. & Page No. 5. Title compilers, Author Journal Year, Vol. & Page No. 6. Title Author Journal Year, Vol. & Page No.

1.1.12

QUESTION BANK

UNIT-I 1. (a) Find 2-Closure(A) and 2-Closure(C) for the Finite Automaton as shown in Figure 3a

(b) Explain the bootstrapping process with a suitable diagram. 2. (a) What is Finite Automaton? Give an example. (b) Find the number of tokens presented in the following `FORTRAN' statements: i. DO 100 I = 1.625 ii. IF ( MIN .EQ. MAX ) GOTO 1000 (c) Find the Regular Expression for the DFA as shown in _gure 7c.

(a)

11)

(JNTU May

3. State the steps to convert a regular expression to NFA. Explain with an example. (a) Define regular expression. Give examples (b) (b) State & explain the properties of regular sets (JNTU May 11)

4. (a) Design a DFA that accepts strings over _=f0, 1g if and only if the value of the string, interpreted as a binary representation of an integer is zero modulo 5.

(b) Construct an NFA equivalent to the following Regular Expressions: (JNTU June 10) i. 10 + (0 + 11) 0* 1 ii. (a + b)* (aa + bb) (a + b)*. 2. a) Briefly explain about predictive parser. b) Let G = ({A0, A1, A2 , A3}, {a, b}, P, { A0}), where P is given by: A0 aA0 |bA1 A1 aA2 |aA3 A2 a |bA1| bA3 A3 b |bA0 5. Construct an NFA accepting L(G). .(JNTU JUNE10)

6. a) Write a general format of the LEX program and give an example. b) Construct a DFA that accepts an identifier of a programming language. c) Explain the difference between the phase and pass of a compiler.(JNTU JUNE10) Write short notes on following terms: (c) NFA (d) Regular Expression (e) Transition diasgram (f) Token (JNTU June 10)

7. (a) Define DFA and NFA. Give examples. (b) Convert the following NFA to equivalent DFA: (JNTU May 09)

8 (a) Define regular expression. Give example. Write its applications. [10+6] (b) Give regular expressions generating the following languages over = {0,1} (i) L1 = {w | w contains atleast three 1s} (ii) L2 = {w | w has length at least 3 and its third symbol is 0} (iii) L3 = {w | w doesnt contain the substring 110} (iv) L4 = {w | every odd position of w is a 1} (v) L5= {w | w contains at least two 0s and at most one 1} (JNTU May 09) 9. (a) Define finite automata and write its applications.

(b) Convert the following regular expressions into NFA. [6+10] (i) (0 U 1)*000(0 U 1)* (ii) (((00)*(11))U01)* (JNTU May 09) (iii) * 10. Describe lexical analysis and lex tools. (JNTU May 09)

11. (a) What are the closers properties of regular sets? Explain. (b) Briefly explain the logical phases of a compiler model . 12. (a) Write a general format of the LEX program and give an example. (b) Construct a DFA that accepts an identifier of a programming language. (c ) explain the difference between the phase and pass of a compiler.

13. (a) When are two regular Expressions said to be equivalent? Explain with an example. (b) b

B

b

C

b

A

b

E

(JNTU Nov 08)

14. (a ) Design a DFA that accept the language over the alphabet = { 0,1,2} where the decimal Equivalent of the language is divisible by 3. (b) Compare compiler and interpreter with the help of suitable example. (JNTU Nov 08)

15. a. b. c.

For the NFA given by following state transition diagram fig 1 Check whether the string abbabba is accepted or not Give at least two transition paths Find equivalent DFA. Check for same result of bit(a) (JNTU Feb 07)

Q1

a

Q0

Q3

Q2

b b a

b Fig-1 16. 17. Nov 06) 18. With the help of schematic diagram explain the function of DFA. What are the reasons to say it is deterministic? (JNTU Apr 05, Nov 06) Design a DFA accepting the language given over the alphabet {0,1}, L={the set of all strings such that every block of five consecutive contains at least two 0s}. (JNTU Apr 05, Feb 07, Nov 06) Give mathematical definition of NFA and state main differences between NFA and DFA. (JNTU Apr 05, Feb 07,

19. For the following State transition table draw the state transition diagram. Find its equivalent machine. For the string abbaaab test whether both give same result or not. q 0 is initial state and q3 is the final state. (JNTU Mar 06, Nov 05, 06) 0 1 Q/ q0 q1 q2 q1 q1 q1q3 q2 q3 q0q3 q3 20. Give DFA which reads string from {a,b} and end with aaa. (JNTU Nov 05)

21. a.

b.

Describe the languages denoted by the following regular expressions (JNTU Aug/Sep 06) i. (0+1) * 0(0+1) (0+1) [2] ii. 0*10*10*10* [2] iii. (00+11)_ ((01+10)(00+11)_ (01+10) (00+11)_ )_ Write a lex program that copies a file, replacing each non-null segments of white space by a single blank.

22. a. Write a procedure that combines two NFAs in to a single NFA. The operations to be performed are those of concatenation, union and closure. (JNTU Apr/May 07, 04, Aug/Sep 07) b. Write a procedure that detects all extraneous states in a DFA. 23 a. Write a procedure for constructing a deterministic finite automata from a non-deterministic Automata, explain with one example. (JNTU Apr/May 06, Aug/Sep 07, Nov 03) b. Give the general format of a LEX program. 24 a. b. Write about lexical analyzer generator. (JNTU Apr/May 06, Nov 05) Construct minimum state DFAs for the following regular expressions. i. (a+b)* a (a+b) [3]

ii. (a+b)* a (a+b) (a+b) [3] iii. (a/b)* a (a/b)(a/b)(a/b). [3] 25. a. b. 26. a. b. 27 Explain lexical analysis in detail. (JNTU Apr/May 06, Nov/Dec 05, 04, Aug/Sep 07) What are the reasons for separating lexical analysis from syntax analysis. What is the role of lexical analyzer. (JNTU Nov/Dec 05, Aug/Sep 06) Construct an NFA for the regular expression R=(a+b)* abb convert it in to an equivalent DFA. Explain with one example how LEX program perform lexical analysis for the following patterns in C : identifier, comments, numerical constants, arithmetic operators. (JNTU Nov/Dec 05, Aug/Sep 06, Apr/May 04) Construct a DFA equivalent to M={{q0,q1},{0,1},q0,{q0}, }, is given by the state table. (JNTU Nov 05) State/ q0 q1 0 q0 q1 1 q1 q0, q1

28.

29 Mar 06)

Minimize the FA given below and show both the given and the reduced one are equivalent (JNTU Nov 05, State/ q0 q1 q2 q3 q4 q5 q6 a q0 q2 q3 q0 q0 q1 q1 b q3 q5 q4 q5 q6 q4 q3

30.

Define epsilon closure. Find epsilon closures for all the states of given NFA-. Remove epsilons with out changing the acceptance fig 4. (JNTU Nov 05)

fig 4. 31 For the FA- given check whether the string aannanan is accepted or not, if accepted write the transition path. Find equivalent NFA without epsilon transitions, explain the procedure used and check the string given on your new NFA. Fig 6 (JNTU Apr 05, Nov 05)

Fig 6 32.onstruct the DFA equivalent to the NFA M=({p,q,r,s},{0,1},S,P, ) and is given by. ( JNTU Apr 05) 0 p,q R S S 1 P R S (GATE 09)

Q/ p q R S

33.. S a S a / b S b / a / b The language generated by the above grammar over the alphabet {a ,b} is the set of a All the palondromes b All odd length palindromes c strings that begin and end with the same symbol d All even length palindromes the following language over the alphabet { 0, 1 } is described by the regular expression (0+1)*0 ( 0 +1)* 0(0+1)*?

a The set of the strings containing the substring 00 b The set of the strings containing at most two 0s c The set of the strings containing at least two 0s d The set of the strings that begin and end with either 0 or 1. 34. Which one of the following is false? (GATE 09) a There is a unique minimal DFA for every Regular language b Every NFA can be converted to an equivalent PDA. c Complement of every context free language is recursive d Every non deterministic PDA can be converted to an equivalent deterministic PDA. 35. Match all items in Group-1 with correct options from those given Group-2 Group-1 Group-2 P. Regular Expression 1. Syntax Analysis Q. Push Down Automata 2. Code Generator R. Data flow Analysis 3. lexical analysis S. Register Allocation 4. Code optimization a P-4,Q-1,R-2,S-3 b P-3,Q-1,R-42,S-2 c P-3,Q-41,R-,S-2 d P-2,Q-1,R-4,S-3 (GATE 09)

36. a. b. c. d. 37.

Which of the following set can be recognized by Deterministic Finite State Automaton? The numbers 1,2,4,8,.,2n, .Written in binary The numbers 1,2,4,,2n,..written in unary The set of binary string in which the number of zeros is the same as the number of ones. The set {1,101,110111,1110111,} (GATE 98) Design a deterministic finite state automaton (using minimum number of states) that recognizes the following language L={w{0,1}*|w interpreted as binary number (ignoring the leading zeros) is divisible by five. (GATE 98) Find the number of binary string of w of length 2n with an equal number of 1s and 0s, and the property that every prefix and w has at least as many 0s as 1s. Show that all vertices in an undirected finite graph can not have distinct degrees, if the graph has at least 2 vertices. (GATE 02) A simple two-pass assembler does the following in the first pass: (GATE 93) it allocates space for the literals. It computes the total length of the program It builds the symbol table for the symbols and their values. It generates code for all the load and store register instructions. None of the above.

38. a.

b.

39. a. b. c. d. e.

40.

Q0 Q1

0

Q2

0 0 41. a. b. c. For ={a,b} Construct DFAs that accept the sets consisting of all the strings with exactly one a all the strings with at least one a all strings with at least one a and followed by exactly two bs

42 Design DFA which accepts the string 1010 only. 43 Design DFA which accepts the string 1100 or 1010 only.

44 Design DFA which accepts set of all strings containing 1010 as substring.

45 Design DFA which accepts set of all strings containing 0101 as substring. 46 Design DFA which accepts set of all binary strings. 47 48 49 Design DFA which accepts set of all strings ending with 00. Design DFA which accepts set of all strings containing 3 consecutive 0s. Design DFA which does not accepts set of all strings containing three consecutive 0s.

50 Build an FA that accept only those words that have even number of sub strings a,b. 51 Design a DFA which accepts set of all strings which are divisible by 5 for binary alphabet. 52 For NFA in figure find (q0,1010) and (q1,00) 0 start

Q0

0,1 1

Q1 Q2

Q0

0,1 0

Q1

1 0

Q2

54 Design an NFA which accepts set of all binary strings containing 1100 or 1010 as sub strings. 55 56 57 Design an NFA which accepts set of all binary strings ending with two consecutive 0s. Design an NFA which accepts set of all binary strings containing three consecutive 0s. Design an NFA, which accepts, set of all binary strings containing the third symbol from the left end is 1 and second symbol from left end is 0. a. b. c. d. 59 Find the length of the following strings |abcdef| |12436| |abcd pk| let y=abc1234 then |y|=? Write the prefix and suffix set of the string x=abcd

58

60 Write the proper prefix and proper suffix set of the string x=abcdef

61 Explain the operations on strings 62 Explain the operation of a Finite Automata. 63 Define transition system and Give the properties of transition functions 64 Draw the transition diagram for the given transition table Q/ q1 q2 q3 *q4 0 q3 q1 q2 q4 1 q2 q4 q1 q3

65 Give the entire sequence of states for the input string 110001 Q/ *q0 q1 q2 q3 66 67 0 q2 q3 q0 q1 1 q1 q0 q3 q2

Define Language. State and Explain the Operation on the Language. State whether the Automaton given below accepts the string 1100001.

UNIT II

1 (a) Test whether the following grammar is LL(1) or not. S ! AaAb jBbBa A!2 B !2 (b) Construct the predictive parse table for the following grammar: S!A A ! aB jAd B ! bBC jf (g) C ! g.(JNTU May 11) 2. (a) Draw the parse tree for an expression: a_ - ( b + c ) (b) Give the Context Free Grammar(CFG) that generates the set f0 to f1ay 11) 3 Construct the predictive parse table for the following grammar: S ! iEtSS0 ja S0 ! eS j2 E ! b. (JNTU June 10)

E->E+E/E*E/(E)/id

(b) What is the significance of lookahead symbol in parsing process. (JNTU June 10) 4Write a short note on following terms: (a) Derivation (b) Ambiguity (c) Parse tree (d) LL (k) grammar (JNTU June 10) 5. (a) The top down parsing is also considered as LMD derivation justify the statement. (b) Verify whether string id+(id+id) is accepted by following grammar or not by using predictive parsing: E->TE E->+TE/ T->FT T->*FT/ F->(E)/id

(JNTU June 10) (JNTU May 09) (JNTU May (JNTU May 09) (JNTU May

6Describe LL(1) parsing. 7Explain ambiguous grammar and LL(K) grammar. 09) 8 (a) Describe parse trees. (b) Describe LL(1) parsing. 9a) Describe Context Free Grammar. b) Generate CFG to the following finite automaton: 09)

10. ute the FIRST and FOLLOW sets of each of the non terminal for the following grammar. P AQRbe / mn/ Dei A ab / ^ Q q1q2/^ R r1r2/^ D d E e. 11.a) What is a recursive grammar? Explain (b) Consider the following recursive grammar: S Aa/b A Ac/Sd What is an equivalent grammar when the left recursion is removed?

(a) Give the CFG generating the set of palindromes over an alphabet (b) Consider the following recursive grammar : S Sa/Sb/ a/b Obtain an equivalent grammar with NO left recursion. (JNTU N0v 08) 13.Construct a Predictive parser table for the following grammar. (JNTU Nov 08) E->E+T/T T->T*F/F F->(E) /xy/xz

12

14a. Explain the reasons for separating lexical analysis phase from syntax analysis. b. Eliminate ambiguities from the following grammar S ! iEtSeS|iEtS|a E ! b|c|d (JNTU Apr/May 07, 06, Nov/Dec 05, Aug/Sep 07, Apr 03) 15a. Eliminate ambiguity if any from the following grammar for Boolean expressions. bexpr ! bexpr or bterm|bterm bterm ! bterm and bfactor|bfactor bfactor ! nst factor|(bexpr)|true|false. Where or, and, not (, ), true, false are terminals in the grammar. b. Write a recursion discent parser for the above grammar. (JNTU Apr/May 07) 16 a. The grammar S ! aSa|aa generates all even length string of as except for the empty string. If a brute force method of top down parsor is used, it succeeds of 2as, 4as, 8as but fails on 6as. Find out all even strings for which the parser succeeds. (JNTU Apr/May 07, Apr 03 b. 17 a. b. 18 a. that out b. List out the rules for constructing the simple precedence table for a CFG. Convert the following grammar into LL(1) grammar R ! R|'R|RR|R _ |(R)|a|b [10] (JNTU Apr/May 06, 04) What are the advantages and disadvantages of operator precedence parsing. The grammar S ! aSa|aa generates all even length strings of as except for the empty string-show the brute force method of top down parsing succeeds of 2,4 and 8as but fails on 6as. Also find what are the even strings that are passed by the technique. What is an LL(1) grammar. Can you convert every context free grammar into LL(1). (JNTU Apr/May 04, 03)

19 a. The grammar S ! aSa|aa generates all even length string of as except for the empty string. If a brute force method of top down parser is used, it succeeds of 2as, 4as, 8as but fails on 6as. Find out all even strings for which the parser succeeds. (JNTU Nov/Dec 05) b. List out the rules for constructing the simple precedence table for a CFG. 20 a. b. 21 a. Convert the following grammar into LL(1) grammar R ! R|0R|RR|R _ |(R)|a|b [10] (JNTU Aug/Sep 06, Nov 05) What are the advantages and disadvantages of operator precedence parsing. Eliminate ambiguity if any from the following grammar for Boolean expressions .(JNTU Aug/Sep 06) bexpr ! bexpr or bterm|bterm bterm ! bterm and bfactor|bfactor bfactor ! nst factor|(bexpr)|true|false. Where or, and, not (, ), true, false are terminals in the grammar.

b.

22 . Eliminate ambiguities in the following grammar. (JNTU Aug/Sep 06, 07, Apr/May 05, 04) S ! iEtS|iEtSeS|a E ! b|c|d where a,b,c,d,e,i,t are trminals. b. Construct operator precedence parse table for the above grammer. 23Generate parse tree for the following grammar E->E+E E->E*E E->id 24 Find the reduced grammar equivalent to CFG G=({S,A,B,C}{a,b,d},S,P) 25 Consider following gremar and obtain an equivalent grammar containing no useless grammar symbols. A->xyz/Xyzz X->Xz/xYx Y->yYy/XZ Z->Zy/z 26Find the reduced grammar that is equivalent to the CFG given below: S->aC/SB A->bSCa B->aSB/bBC C->aBC/ad 27Given the grammar shown below ,eliminate all the unit productions from the grammar S->AB A->a B->C/b C->D D->E E->a 28 Consider the following grammar, and eliminate Left recursion from the Grammar S->A A->Ad/Ae/aB/aC B->bBC/f C->g

29 Consider the following grammar, and eliminate Left recursion from the Grammar S->(L)/a L->L,S/S 30Test whether the following grammar is ambiguous. L->L;L/S s->a 31Differentiate left linear grammar and right linear grammar 32 Write a CFG to specify the declarations in C(ie basic data type, array declaration 33. 34. Explain regular set and regular expression Define Backtracking and LL(1) parser

35.

Test whether the given grammar is LL(1) or not , and Construct a predictive parsing table for it. S->AaAb/BbBa A-> B-> Construct the given grammar and test whether grammar is LL(1) or not . S->1AB/ A->1AC/0C B->0S C->1 Construct a Predictive parsing table for the following grammar where S/ is a start symbol and # is the end marker. S/->S# S->qABC A->a/bbD B->a/ C->b/ D->c/ Construct a predictive parser table for the following grammar S->A A->aB/Ad B->bBC/f C->g Construct a predictive parser table for the following grammar, Where S is a start symbol. S->iEtSS1/a S1->eS/ , E->b Construct LL(1) parsing table for the following grammar S->aBDh B->cC C->bC/ D->EF E->g/ F->f/ Compute the FIRST and FOLLOW sets for each non terminal of the grammar given below: S->ABa/bCa A->cBCD/ B->CdA/ad C->eC/ D->bSf/a Test whether the following grammar is LL(1); S->AB/eDa B->ab/c B->dC C->ec/ D->fD/ Every unambiguous grammar is LL(1).Comment on the truth/false-hood of the statement. Construct LL(1)parse table for the follwing grammar: S->aAC/bB

36.

37

38

39

40.

41

42

43 44

A->eD D->bE/ E->eD/dD B->f/g C->h/i 45. Transform the following grammar so that it will be LL(1),without changing the language S->aAC/bB A->Abc/Abd/e B->f/g C->h/i Consider the following grammar S->aA/AB A->Ab/c B->e/f Design LL(1) parse table for the following grammar. S->aAcd/BCe A->b/ B->Cf/, C->fe

46.

47

48 Construct the LL(1) table for the following grammar. 1. Expr->_Expr 2. Expr->(Expr) 3. Expr->Var Expr Tail 4. ExprTail->_Expr 5. ExprTail->^ 6. Var ->id Var Tail 7. VarTail->(Expr) 8. VarTail->^ 9. Goal->Expr$ 49 50. a. b. There may exist a grammar that is non LL(1)but generating an LL(1)language. Comment on the truth/false-hood of the statement. Define LL(1) grammar. Construct LL(1) parse table for the following grammar. bexpr ! bexpr or bterm|bterm bterm ! bterm and bfactor|bfactor bfactor ! nst factor|(bexpr)|true|false. Where or, and, not (, ), true, false are terminals in the grammar Define LL(1) grammar. Construct LL(1)parse table fr the following grammar S->Aa/bAc/Bc/bBa A->d B->d Is the following language LL(1) {an cbn/n1} 20 there may exist a grammar that is non LL(1)but generating an LL(1)language. Comment on the truth/false-hood of the statement. Find the reduced grammar equivalent to CFG G=({S,A,B,C}{a,b,d},S,P)

51 a. b.

52

53.

54.

Consider the grammar with non terminals N= { S, C, S1},terminals T= {a,b, i,t,e} with S as the startSymbol, and the following set of rules. S ---- > iCtSS1/c S1----- > eS /null The Grammar is not LL(1) because: a. It is left recursive b. it is right recursive C it is ambiguous d. it is not context free (GATE 07) Consider the following two statements: P: Every regular grammar is LL(1) Q:Every regular set has a LR(1) grammar Which of the following is true? a. Both P and q are true b. P is true and Q is false b. P is false and Q is true d. both P and Q are false (GATE 07) (GATE 07)

55.

Consider the CFG with {S,A,B} as the non terminal alphabet, {a,b}as the terminal output S as start symbol and the following set of production rules: S ---- > aB S ---- > bA B ----> b A -----> a B ----> bS A -----> aS B -----> aBB A -----> bAA 57. Which of the following strings is generated by the grammar? a. aaaabb b. aabbbb c.aabbab d.abbbba 58. Consider the following grammar: (GATE 06) S->FR R->*S/ F->id In the predictive parser table ,M, of the grammar the entries M[s,id] and M[R,$] respectively { S->FR} and {R-> } { S->FR} and{} {S->FR} and {R->*S} {F->id} and {R->}

a. b. c. d. 59.

Consider the following grammar. (GATE 06) S->S+E S->E E->F+E E->F F->id Consider the following LR(0) items corresponding to the grammar above. i. S->S*E ii. E->F.+E iii. E->F+.E given the items above ,which two of them will appear in the same set in the canonical sets ofitems for the grammar? a. i) and(ii) b. (ii) and (iii) c. (i) and (iii) d. None of the above

60.

The grammar A->AA/(A)/ is not suitable for predictive parsing because the grammar is (GATE 05) (a) ambiguous (b) left recursive (c) right recursive (d) an operator grammar The grammar A->AA/(A)/ is not suitable for predictive parsing because the grammar is (GATE 05) (a) ambigious (b) left recursive (c) right recursive (d) an operator grammar 1. 2. 3. 4. 5. 6. 7. 8. 9. Construct the LL(1) table for the following grammar. (GATE 95) Expr->_Expr Expr->(Expr) Expr->Var Expr Tail ExprTail->_Expr ExprTail->^ Var ->id Var Tail VarTail->(Expr) VarTail->^ Goal->Expr$ Which of the following features cannot be captured by context-free grammars? (GATE 94) syntax of if-then-else statements syntax of recursive procedures whether a variable has been declared before its use variable names of arbitrary length

61.

62.

63. a. b. c. d.

64 For the Context free grammar ,FOLLOW(A) is the set of terminals that can appear immediately to the right of non terminal A in some sentential form. We define two sets LFOLLOW(A) and RFOLLOW(A) by replacing the word sentential by left sentential and right most sentential respectively in the definition of FOLLOW(A). Which of the following statements is/ are true ? (GATE 92) a. FOLLOW(A) and FOLLOW(A) may be different. b. FOLLOW(A) and FOOLOW(A) are always same. c. All the three sets are identical. d. All the three sets are different

65. .For the correct answer string to Q. 60, how many derivation trees are there? a. 1 b. 2 c. 3 d. 4 66. Indicate all the true statements from the following: (GATE 91) a. Recursive decent parsing cannot be used for with left recursion. b. The intermediate form the representing expressions which is best suited for code optimization is the best fix form. c. A programming language not supporting either recursion or pointer type does not need the support of Dynamic memory allocation . d. Although C does not support call by name parameter passing ,the effect can be correctly simulated in c e. No feature of Pascal violates strong typing in Pascal

67. .There may exist a grammar that is non LL(1)but generating an LL(1)language. Comment on the truth/false-hood of the statement.

UNIT III 1. Describe, in detail, an operator precedence parsing with an example. 2. Build the LALR parsing table for the following grammar: E ! E + TjT T ! TFjF (h) F ! F_ jaj b: (JNTU May 11) 3. Construct SLR parsing table for following grammar: E ! E + T=T T ! T _ F=F F ! (E)=id. (JNTU June 10) 4. (a) What is LR parser? Compare and contrast the di_erent types of LR parsers. (b) Construct the CLR parse table for the following augmented grammar: A0 ! A A ! (A) ja (JNTU June 10) 5. Consider the following grammar: A` A A (A) |a

a) Construct the LR(0) parser. b) Find the SLR(1) parse table. c) Find the moves made by the LR(0) parser on the input string: ( ( a ) ). (JNTU JUNE10)

6. Explain Bottom up parsing with example. 09) 7 (a) What is handle pruning? Explain (b) Describe about LR grammars. 8. Describe LALR parsing with example. 9. a) Explain ambiguous grammars. b) Describe about YACC. 10. Consider the following augmented grammar: S-> E E E+T T a/(E)

(JNTU May (JNTU May 09) (JNTU May 09) (JNTU May 09)

(a) Construct the DFA whose states are the canonical collection of LR(0) items. (b) Construct the SLR(1) parse table. (JNTU Nov 08) 11. Consider the following grammar: S1 S S (S) S/^ (a) Construct the LR( 0 ) parser. (b ) Find the SLR (1) parse table.

(c ) Find the moves made by the LR( 0) parser on the input string:: ( ( ) ( ) ). 12. Consider the following grammar : E->E+T/T T->T*F/F F->(E) /a (a) Construct the SLR parse table . (b) Find the moves made by the parser on the input string : a + a * a. (JNTU N0v 08) 13. (a) what is LR parser ? Compare and Contrast the different types of Lr parser. (b) Construct the CLR parse table for the following augmented grammar:: A1 A A ( A ) /a (JNTU Nov 08)

14. Construct LALR parse table for the following grammer S!L=R S!R L ! _R L ! id R!L

15. Construct canonical LR pars table for the following grammar. (JNTU Apr/May 06, Nov/Dec 05, 04) SL=R SR L*R RL 16. a. What is an SLR grammar (JNTU Apr/May 06) b. Construct LALR(1) parse table for the following grammar for S ->Aa|bAc|Bc|bBa A!d B!d. 17. 18. Explain the algorithm for translator of S-attributed grammars along with bottom up parsing with suitable examples. Construct LALR parse table for the following grammar S ! Aa|bAc|Bc|bBa A!d B ! d. (JNTU Aug/Sep 06, Apr/May 04)

19. a. b.

Define LR(0) grammar. (JNTU Aug/Sep 06, 07, Apr/May 05, 04) Construct SLR passing table for the following grammar. E ! E + T/T T ! TF/F F ! F*|a|b. Suppose the declaration are generated by the following grammar(JNTU Aug/Sep 06, Apr 03) D!idL L!,idL/:T T!integer/real Construct a translation scheme to enter the type of each identifier into the symbol table. Explain the translator process using the following example id, id: real. Define LR(0) grammar. (JNTU Aug/Sep 06, Nov 05)

20. a.

b. 21. a.

b.

Construct SLR passing table for the following grammar. E ! E + T/T T ! TF/F F ! F_|a|b. Construct the SLR parse table for the following grammar. S->Aa/bAc/dc/bda A->d Distinguish SLR ,LALR grammar What is an LR(0) grammar. Construct SLR parsing table for the following grammar R-> R->R1R/RR/R*/(R)/a/b. Distinguish top down and bottom up parsing Construct a recursive Decent parser for the following grammar. E->E+T/T T->TF/f F->F*/a/b Construct LALR parsetable for the following grammar S ->Aa|bAc|Bc|bBa A!d B!d. What is an SLR grammar Construct LALR(1) parse table for the following grammar for S ->Aa|bAc|dc|bda A!d What is LR(1)parsing? Construct canonical LR parse table for the following Grammar S->Aa/bAc/bBa A->d B->d. Define shift reduce parser with an example grammar Differentiate between LR, LALR and SLR parser What is predictive parser & shift reduce parser What is an ambiguous grammar Define how to handle ambiguous grammar Explain the meaning of Handle by giving suitable example Design SLR(1) parser for the following grammar. S->aAb/bB A->Aa/ B->Bb/ Design LALR(1) parser for the following grammar S->aAd/bBd/aBc/bAc A->e (JNTU Aug/Sep 07)

25.

26 . a. b.

27. a. b.

35.

B->e 36. 37. if the grammar is ambiguous then there exist exactly one handle for each right sentential form comment. Design SLR(1) parser for the grammar give below S->aAb A->Aa/ If LALR(1)parser is designed for the grammar. S->aAb A->Aa/ How many states the LALR(1) parser will have Design CLR(1) parser for the grammar give below S->aAb A->Aa/ What is the advantage of left recursive grammar over right recursive grammar in LR parsing. Explain with suitable example A grammar containing left recursion cannot be LL(1),therefore a grammar containing right recursion cannot be LR(1).comment Give an example of a grammar that is LL(1),but not SLR(1) Construct an LALR(1) parsing table for the following grammar S->Aa/aAc/Bc/bBa A->d b->d

38.

39.

44.

Construct an SLR(a) parsing table for the following grammar S->xAy/xBy/xAz A->as/q B->q 45. Let L= L1^L2 when L1,L2 are languages as defined below (GATE 09) L1 = { am bm c an bn /m,n >=0} L2 = { ai bj ck / i,j,k >= 0} then L is a not recursive b regular c context free but not regular d. recursively enumerable but not context free 46. Which of the following statements are TRUE? (GATE 09) I. There exist parsing algorithm for some programming language whose complexities are less than (n3) II. A programming language which allows recursion can be implemented with static storage allocation. III. No- L attributed definition can be evaluated in the framework of bottom up parsing IV. Coding improving transformation can be performed at both source language and intermediate code level a I and II b I and IV c III and IV d I,II, IV 47. N LALR (1) parser for the grammar Gcan have shift reduce ( S- R) conflicts if and only if a. the SLR (1) parser G has S-R conflicts. b. the LR (1) parser G has S-R conflicts. c. the SLR (0) parser G has S-R conflicts. d. the LALR (1) parser G has reduce-reduce conflicts.

(GATE 08) 48. Consider the grammar: (GATE 05) S->(S)/ Let the number of states in SLR(1),LR(1) and LALR(1) parsers for the grammar be n1,n2 and n3 respectively . the following relationship hold goods: (a) n1<n2<n3 (b) n1=n3<n2 (c) n1=n2=n3 (d) n1>n3>n2 Consider the grammar shown below S->CC C->Cc/d This grammar is (a) LL(1) (c) LALR(1) but not SLR(1) a. b. c. d. 51. a. b. c. d. (GATE 03)

49.

50.

Which of the following statements is false? (GATE 01) An ambiguous grammar has same leftmost and rightmost derivation An LL(1)parser is a top down parser LALR is more powerful than SLR An ambiguous grammar can never be LR(k) for any k Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order. (GATE 00) Leftmost derivation Leftmost derivation traced out in reverse Rightmost derivation Rightmost derivation traced out in reverse

Which of the following is the most powerful parsing method? (a) LL(1) (b) Canonical LR (c) SLR (d) LALR Which of the following statements is true? SLR parser is more powerful than LALR LALR parser is more powerful than Canonical LR parser Canonical LR parser is more powerful than LALR parser The parsers SLR ,Canonical LR ,And LALR have the same power

Which of the following features cannot be captured by context free grammars? (GATE 94) a. Syntax of if-then else statements b. Syntax of recursive procedures c. Whether a variable has been declared before its use d. Variable names of arbitrary length 55. Consider the SLR(1) and LALR(1) parsing tables for the context free grammar. Which of the following statements is/are true? (GATE 92) a. The go to part of both tables may be different. b. The shift entries are identical in both the tables. c. The reduce entries in the tables may be different. d. The error entries in the tables may be different.

UNIT IV 1. (a) Construct triples of the expressions: a[i] := b and a := b[i] (b) Generate the three-address code for the following `C' program fragment: (i) for( i = 1; i <= 20; i++) if( a < b) x = y + z; (JNTU May 11) 2. Generate the three-address code for the following `C' program fragment: switch(a + b). [16] f case 2: x = y; break; case 5: switch(x) f case 0: a = b + 1; break; case 1: a = b + 3; break; default: a = 2; break; g break; case 9: x = y - 1; break; (j) default: a = 2; break; (JNTU May 11) 3. (a) Write a short note on abstract syntax tree. (b) Compare and contrast the quadruples, triples & indirect triples. (JNTU June 10)

4. Translate the executable statements of the following `C' program into a threeaddress code by assuming each element of an array `a' takes 4 bytes. [16] void main() f int i = 1, a[10]; while(i++ < = 10)a[i] = 0; (JNTU June 10) g 5. a) What is a Syntax Directed Translation Scheme? Explain with an example. b) Design an abstract syntax tree for the expression: a = (a[i+1] = 2) + a[j]. (JNTU June 10)) 6. a) What is syntax directed translation? Explain with example. (JNTU May 09) b) Describe about S-attributed and L-attributed grammars. 7.(a) What is abstract syntax tree? Explain with example. (b) Describe semantic analysis. (JNTU May 09) 8 Explain about Intermediate code in detail. (JNTU May 09) 9. Explain syntax directed translation of control flow statements. (JNTU May 09)

10. (a ) Explain quadruples, Triples,and Indirect triples. (b) Construct Quadruple, Ttriples,and Indirect Triples of the following expression ( a + b) * ( c + d )- ( a + b + c) (JNTU Nov 08) 11 Consider the following grammar:: D. TL

T INT /FLOAT L L,ID/ID (a) Write the Syntax Directed Definition to add the type of each identifier to its entry in the Symbol table during semantic analysis. (b) Draw an annotated parse tree for the declaration: float,id1,id2,id3; (JNTU Nov 08) 12. Let synthesized attribute ,Val give the value of the binary number generated by S in the following Grammar . For example, on input 101.101,S.Val = 5.625. S L * L / L L LB / B B0 / 1. (JNTU Nov 08) Write synthesized attribute values corresponding to each of the productions to determine the S.Val 13. (a) what is a three address code ? Give an Example. (b )Give detail analysis on generic function and polymorphic function? (JNTU Nov 08)

14. a. Explain in detail how an L-attributed grammar can be converted into a translator scheme.

b. 15. a. b. and w c. 16 a. b. 17. a. b. Give the translate scheme to convert an expression grammar into three address code. (JNTU Apr/May 07, 06, Aug/Sep 07) Write type expression for the following types (JNTU Apr/May 07, 06, Nov/Dec 05, Apr 03) An array of pointers to real, where the array index ranges from 1 to 100. A two dimensional array of integers ( i.e. an array of arrays) whose rows are indexed from 0 to 9 hose columns are indexed from-10 to 10. Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character. What are L-attributed grammars. (JNTU Apr/May 07, Nov 05) Explain the steps involved in converting an L-attributed grammar into translator scheme. What are S-attributed and L-attributed grammars. (JNTU Nov/Dec 05, Apr/May 05) Write a S-attributed grammar to connect the following grammar with prefix rotators L!E E!E+T E!E-T E!T T!T*F T!T/F T!F F!P" F F!P P!(E) P!id. Write a syntax directed translators scheme to translate the following grammars for declaration statement D->TL T->int T->red L->Ldid L->id (JNTU Apr 03)

18

19 a. The following grammar generator all possible binary numbers S->L.L/L L->LB/B B->0/1

b. 20. a. b. 21

Write a syntax directed translator scheme to translate the given binary number into its equivalent decimal number Distinguish s-attributed and L-attributed grammars. Define S attributed and L-attributed grammars. . (JNTU Nov 03) Write a syntax directed definition to convert the given binary number with its decimal equivalent (JNTU Dec/Jan 03)

a. What is a syntax tree? b. How to construct syntax tree for expressions? c. Construct a syntax tree for the expression a-4+c

22 a. b.

Explain the reasons for separating lexical analysis phase from syntax analysis. Eliminate ambiguities from the following grammar S ! iEtSeS|iEtS|a E ! b|c|d (JNTU Apr/May 07, 06, Nov/Dec 05, Aug/Sep 07, Apr 03) Explain Why every s-attributed definition is L-attributed? Write a grammar for the following control structure: Do N times S Write syntax directed translation to go along with this grammar to translate it into three address Differentiate between Quadraples, triples & indirect triples Explain clearly with examples ,the conditions under which an assignment statement can be subjected to hoisting out of a loop Explain Flow of-control constructs Explain briefly the terms Quadraples, triples Explain briefly the terms triples, indirect triples What does syntax directed translation mean ? Here id is a token that represents an integer and id.value represents the corresponding integer value. For an input 2*3+4,this translation scheme prints (A)2*3+4 (B)2*+3 4 (C)2 3 4 +* (D) 2 3 4 +* Consider the syntax directed translation schema (SETS)shown below: E->E+E{print+} E->E*E{print.} E->id{print id.name} E->(E)

31.

32. An LR-parser executes the actions associated with the productions immediately after a reduction by the corresponding production .Draw the parse tree and write the translation for the sentence. (a+b)*(c+d), using SDTS given above 33. Convert the following expression to postfix expression

(a+b)*(c+f) 34 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. a. b. c. 45. 46. Convert the following expression to prefix expression (a+b)*(c+f) Define syntax direct definition? Write the form of SDD. What is synthesized attribute? Explain its functions. Define annotated Parse tree. Explain with an example. What is inherited attributes? Explain its functions. What is dependency graph. Explain with an example. Write the procedure for construction of syntax tres for expressions. What is the transalation scheme. Explain in detail. Explain the procedure for left recurtion from a translation scheme. Explain about control flow statements. What is a three addressed code? Explain the following. Quadraple Tripples Indirect triples Explain about the anyalysis of syntax direct definition . Consider the following Translation Schema (GATE 06) S->ER R->*E{print(*);}R/ E->F->E{print(+);}/F F->(S)/id{print(id.value);} Here id is a token that represents an integer and id.value represents the corresponding integer value. For an input 2*3+4,this translation scheme prints (A)2*3+4 (B)2*+3 4 (C)2 3 4 +* (D) 2 3 4 +* Consider the grammar with the following translate on rules and E as the start symbol (GATE 04) E->E1#T {E.value=E1.value * T.value} / T {E.value=T.value} T->T1&F {T.value=T1.value * F.value} / F {T.value=F.value} F->num {F.value=num.value} Compute E.value for the root of the parse tree for the expression :2#3&5#6&4 (a)200 (b)180 (c)160 (d)40 Consider the syntax directed translation schema (SETS)shown below: E->E+E{print+} E->E*E{print.} E->id{print id.name} (GATE 96)

47.

48.

49.

E->(E) An LR-parser executes the actions associated with the productions immediately after a reduction by the corresponding production .Draw the parse tree and write the translation for the sentence. (a+b)*(c+d), using SDTS given above Convert the following expression to postfix expression (a+b)*(c+f)

UNIT V

1. (a) Distinguish static and dynamic Type checking? (k) (b) Discuss in detail about semantic analysis phase? b(JNTU May 11) 2. (a) Write a short note on type equivalence. (b) Write a short note on type checking. (JNTU June 10) 3. (a) Explain Type Conversion. Give the Type conversion rules for converting the type from integer to real. (b) Explain the algorithm for testing the structural Equivalence. (JNTU June 10) 4. Write and Explain about algorithm for construction of equivalence trees? (JNTU June 10)

5. What is Type Expression? Write type Expressions for the following types a) An array of pointers to real, where the array index ranges from 1 to 100 b) Function whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character (JNTU June 10)

6.a) What is Context Sensitive Grammar? Write its features. 09) b) Explain Type Checking with example. 7 Describe Chomsky hierarchy of languages and recognizers. 09) 8.(a) Write notes on type conversion. (b) Describe about type expressions. 9. Write notes on overloading of functions and operations. (JNTU May (JNTU May (JNTU May 09) (JNTU May

09)

10. a. What is a type checker ? How does it work? (JNTU Nov 08, Apr/May 07, Aug/Sep 06, .Nov 03) b. Write a short notes on static and dynamic type checking. 11. a. Type checking of expressions. b. Translation scheme for checking the type of statements (JNTU Nov 08) 12. . a. Discuss about the overloading of functions and operators with an examples. b. What are the advantages and disadvantages of Name equivalence. Explain with examples (JNTU Nov 08)

13.

. a Explain Chomsky Hierarchy of languages b. Give a detail analysis on generic function and polymorphic function

14. a. b. c. 15. a. b.

Write type expression for the following types An array of pointers to real, where the array index ranges from 1 to 100. A two dimensional array of integers ( i.e. an array of arrays) whose rows are indexed from 0 to 9 and whose columns are indexed from-10 to 10. Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character. (JNTU Apr/May 07, 06, Nov/Dec 05, Apr 03) Which of the following recursive type expressions are equivalent? Justify your answer? e1 = integer ! e1 e2 = integer !(integer ! e2) e3 = integer !( integer !e1). Suppose that the type of each identifier is a sub range of integers for expressions with the operators +, -,* , div and mod as in Pascal. Write type? Checking rules that assign to each sub expression, the sub range its value must lie in. (JNTU Apr/May 07, 05, 04 Aug/Sep 07)

. 16. a i. and ii. b. 17. a. b. 18. a. b. c. 19. a. b. What is type expression? Write type expression for the following types. A two dimensional array of integers (i.e. an array of arrays) whose rows are indexed from 0 to 9 whose columns are indexed from -10 to 10. (JNTU Apr/May 07, Apr 03) Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character. What is type system. Discuss static and dynamic checking of types. What are the advantages and disadvantages of Structural equivalence. Explain with example. What are the advantages and disadvantages of Name equivalence. Explain with examples. (JNTU Apr/May 06, 05, 04, Nov/Dec 05, Aug/Sep 06, Nov 05) Write type expression for the following types (JNTU Apr/May 06) An array of pointers to real, where the array index ranges from 1 to 100. A two dimensional array of integers ( i.e. an array of arrays) whose rows are indexed from 0 to 9 and whose columns are indexed from 10 to 10. Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character.

How do you check the expressions in polymorphic functions? Explain through an example. Consider the following declarations type link = " cell; var next : link; last : link; p : " cell; q,r : " cell; Which among the following expressions are Structurally equivalent? Which are name equivalent? Justify your answer. i. link ii. pointer(cell) iii. pointer(link) iv. pointer(record((info X integer) X (next X pointer(cell))) (JNTU Apr/May 06) List out some typical semantic errors . Explain how they can be rectified? What is static checking ? Give some examples of static checks.

20 a. b.

(JNTU Apr/May 06, Aug/Sep 07, Nov/Dec 05) 21 a. b. 22. a. b. 23. a. b. 24. a. i. and Write a note on the specification of a Simple type checker. (JNTU Nov/Dec 05, Aug/Sep 07) Explain the equivalence of type expressions with appropriate examples. Discuss about the overloading of functions and operators with an examples. Write a notes on polymorphic functions. (JNTU Aug/Sep 06, 07, Nov/Dec 04, 05, 03, Apr/May 05, 04) What is type-graph? How cycles are represented in type- graph? Give example. Give a detail analysis on generic function and polymorphic function. (JNTU Aug/Sep 06, Apr/May 05, 04) What is type expression? Write type expression for the following types. (JNTU Aug/Sep 06) A two dimensional array of integers (i.e. an array of arrays) whose rows are indexed from 0 to 9

whose columns are indexed from -10 to 10. ii. Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character. b. What is type system. Discuss static and dynamic checking of types. 25. a. b. 26. a. b. Write short notes on Type conversion with example. Type coercion with example (JNTU Apr 03)

What is meant by structural equivalence of type expressions. Write a function which will test the structural equivalence of two type expressions. Discuss briefly about type conversions. What is Coersion? The grammar for expression is given below. Write the semantic rules for coercionfrom integer to real E->num E->num.num E->id E->E1 op E2 Explain about the specification of a simple type checker. Explain the static storage allocation strategy for storage allocation Write a grammar for expressions, and Write parser, to go along with your grammar (JNTU Dec/Jan 03)

What is the advantage of using lower bound for each dimension of an array to be 0? Explain the Chomsky Hierarchy of various languages. What is type cheking.? Draw the position type cheker. And explain. Define type systems. Explain about static checking of types. What is type expressions. Explain the dynamic checking of types. Explain the specification of simple type cheker. Discuss with the following

Type checking of expression. Type checking of statements. Type checking of functions. Discuss the with the equivalaince of type expressions. Explain the cycles in representation of types. Definie type converstion. Explain in detail with a suitable example What is coercion? Explain the implicit type convertions. Define the overloading of function. Explain the set of possible types for sub expressions. Define the overloading of operaters. Explain the Narrowing the set of possible types. What are the type variables. Explain in detail.

UNIT VI

1. (a) Explain how scope information is represented in the symbol table for block structured language? (l) (b) Write and explain about activation record? (JNTU May 11) 2. (a) Describe the method to obtain faster access to nonlocals. (b) Describe the facilities provided by languages for dynamic allocation of storage of data. (JNTU June 10)

3. a) Explain concept of explicit allocation of fixed-sized blocks b) Explain concept of explicit allocation of variable-sized blocks. (JNTU June 10) 4. Explain about: a) a variable local to a procedure b) a global variable

c) a formal parameter d) a dynamically allocated global variable e) a compiler generated temporary variable. (JNTU June 10)

5 .What are the language facilities for dynamic storage allocation? (JNTU May 09) 6.. How to handle local names and parameters? (JNTU May 09) 3 Describe about Storage Organization in detail. (JNTU May 09) 7. Describe dynamic storage allocation stratagies. (JNTU May 09) 8. a. Write a notes on the static storage allocation strategy with examples and discuss its limitations. b. Discuss about the static allocation strategy of run-time environment with examples. (JNTU Apr/May 06, 05, Nov/Dec 05, Aug/Sep 06, Nov 05,Nov 08) 9. Explain about storage allocation strategies in Block structured Languages. (JNTU Nov 08) 10. Write and explain the following a. Activation Tree b. Activation record 11 Explain hash table organization of symbol tables for block structure languages (JNTU Nov 08) 12. What are self-organizing lists. How this can be used to organize a symbol table. Explain with an example. (JNTU Apr/May 07, Apr 03) 13 a. b. 14. a. b. a. b. 15. a. b. Which data structure will be used to implement a symbol table in an efficient way? Give reasons. (JNTU Apr/May 07, 05, Aug/Sep 07, Nov/Dec 04, Apr 03) Discuss and analyze about all the allocation strategies in run-time storage environment. Explain how the symbol table space can be reused. Explain through an example. Discuss various symbol table organization techniques. (JNTU Apr/May 07, Nov 03) What is an activation record? Explain how it is related with run time storage organization. Write a short notes on heap strategy and run-time storage allocation. (JNTU Apr/May 06, 05, Nov/Dec 05, Apr 03) What are the contents of a symbol table? Explain in detail. What is the data structure used to implement a symbol table in an efficient way? Give reasons? (JNTU Apr/May 06, 05, 4, Aug/Sep 06)

16 a. b. 17. a. b. 18 a. b. 19. a. b. 20 a. b.

Which data structure will be used to implement a symbol table in an efficient way? Give reasons. Discuss and analyze about all the allocation strategies in run-time storage environment. (JNTU Apr/May 06, Nov/Dec 04, Aug/Sep 07) Write detailed notes on the symbol table mechanism using tree data structure. Explain with an example about the symbol table mechanism using hash table data structures. (JNTU Apr/May 06, Nov 05) What is an activation record? Explain how it is related with run time storage organization. Write a short notes on heap strategy and run-time storage allocation. (JNTU Aug/Sep 06) Explain how the symbol table space can be reused. Explain through an example. (JNTU Nov 05) Discuss various symbol table organization techniques. Write a notes on the static storage allocation strategy with examples and discuss its limitations Discuss about the stack allocation strategy of run-time environment with examples

(JNTU Apr/May 05, Nov 03) 21. a What are the advantages and disadvantages of Static storage allocation strategy?(JNTU Apr/May 04) b. What are the advantages and disadvantages of Heap storage allocation strategy? 22. a. b. 23. What is dangling reference in storage allocation ?Explain with an example. (JNTU Apr/May 04) Explain hash table organization of symbol tables for block structure languages. Explain in detail the various storage allocation strategies. (JNU Apr/May 04)

24. a. Explain how the scope information is represented in the symbol table for the block structured language. b. Suppose P(x.y) is a C procedure and it is called by P(A+B,C).Show the intermediate code generated for the call and return make arbitrary assumptions about the locations of A,B and C in the activation record for the calling procedure (JNTU Apr 03) 25. a. b. 26. a. b. c. d. 26 27. 28. 29. 30 31 32 33 34 35 36 37 38. 39 Write detailed notes on : Symbol table organization peephole optimization Heap allocation is required for languages. that support recursion that support dynamic data structures that use dynamic scope rules none of the above Explain how do u reuse t=symbol table space? Describe about the data structures for a symbol table in detail Explain briefly about implementation of block structured languages What is an error & what are the sources if error What do u mean by a syntactic error, illustrate What do u mean by a Semantic error, illustrate What are the different errors seen by each phase what are they Describe briefly about Dynamic errors Explain briefly about Syntactic phase errors Explain briefly about error recovery in operator precedence parsing Explain briefly about Lexical phase errors Explain how do u handle shift reduce errors Explain briefly about error recovery in LR parsing Explain briefly about error recovery in LL parsing (JNTU Dec/Jan 03)

(GATE 97)

Explain briefly about Ad-hoc error recovery in LR parsing Define format of activation records in detail Explain briefly about Run time storage allocation Explain about Block Structure storage allocation Explain about Non Block structure storage allocation Explain briefly about storage allocation for arrays Explain briefly about storage allocation for strings Explain briefly about storage allocation for records Explain briefly about implementation of a Simple Stack Allocation Scheme

What are self organizing lists? How can this be used to organize a syntax table? Explain with an examples. Discuss and overlarge about all the allocation strategies in Runtime storage Environment. Explain the static data area implementing static allocation. What is an Activation Record? Explain its fields in details.

53 Write a short notes on the static storage allocation strategy with an example and discuss its ciritations. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. Discuss about the stack allocation strategy of Run time envi. With an example. Write a short notes on heap strategy and run time storage allocation. What are the advantages and disadvantages of heep storage allocation strategies. Explain how an activation record is related with run time storage organizations. What is dangling reference in storage allocation? Explain with an example. Differentiate b/w static allocation with stack allocation? Explain the memory allocation in a Block structure language ? Explain in brief about the register allocation for temporary and use informed variables. Explain the Basic Issues for allocating memory to a data items in details. What is return sequence? Write the advantages of stack allocation. Explain the storage allocation for Arrays, strings, and Records. Explain the languages features for dynamic stages allocation.

66. 67.

Differentiate b/w static & dynamic storage allocation Explain in details of implicit deal location. 68. Suppose P(x, y) is a c programs, and it is called by P(A+B+C). Show the intermediate code generated for call and return make assumptions about the locations of A, B and C in the activation record of the calling.

UNIT VII 1. (a) Define the following: i. Basic Block ii. Local Optimization iii. Global Optimization. (b) Explain about Algebraic Transformations? (m) (c) \Copy propagation Leads to Dead code" - Justify the statement. (JNTU May 11) 2. Explain Linear bounded automaton with an Example? 3. Explain the following: (a) Redundant loads and stores (b) Un reachable code (c) Flow-of-control optimization (d) Algebraic simpli_cation. 4. Consider following code: begin read n; for i=1 to n do a[i]=true; count=0; for i=2 to n**5 do if a[i] then begin count=count+1; for j=2* i to n by i do a[j]=false end print count end Generate three address code and draw ow graph. What optimizations can be performed? Generate an optimized code. (JNTU June 10) 5. (a) Explain how loop invariant computation can be eliminated? (b) Explain how \Redundant sub-expression eliminates" can be done in a given program? (JNTU June 10) 6. Describe about principal sources of optimization. 09) 7 Explain about optimization of basic blocks 09) 8. Describe about peephole optimization. (JNTU May . (JNTU May (JNTU May 09)

9. What is a flow graph? Explain data flow analysis of flow graphs. 09)

(JNTU May

10. a What is a flow graph. Explain how a given program can be converted into a flow graph b Explain the loop optimization (JNTU Nov 08) 11. Explain about Data-Flow analysis of structured flow graphs. (JNTU Nov 08) 12. Explain the machine independent Optimization in detail. (JNTU Nov 08) 13. Write and explain about Peephole optimization. (JNTU Nov 08) 14. Explain with an example the abstract machine code form of Intermediate code. (JNTU Apr/May 07, 06, Aug/Sep 06, 07, Apr/May 05, 04) 15. 16. 17. 18. 19. 20.. 05) 21. 22. 23. 03) 24. 25. 26. 05) 27. 28. 29. 30. 31. Nov 05) Compare various forms of three address code. (JNTU Aug/Sep 06) Give a translator grammar for converting Boolean expression into three address code. (JNTU Nov/Dec 05, Apr/May 05, Apr 03) Apply the translation scheme on the following expression a< b or c< d and e< f. (JNTU Nov 05) What are loop invariant components. Explain how they effect the efficiency of a program. (JNTU Aug/Sep 06, Nov Compare various forms of three address code. (JNTU Nov/Dec 05) Give a detailed account on loop optimization techniques. (JNTU Apr/May 07)

Explain any two machine dependent code optimization techniques. (JNTU Apr/May 06, Aug/Sep 06, 07, Nov 03) What is a DAG. Explain its application. (JNTU Apr/May 06, Aug/Sep 06)

Explain with an example how abstract machine code can be generated for a given if-then-else statement. (JNTU Apr/May 06, 05, Nov/Dec 05, Aug/Sep 06, Nov 03) Write a short notes on peephole optimization. What are loop invariant components. Explain how they effect the efficiency of a program. (JNTU Nov/Dec

What are the various machine dependent code optimization techniques. (JNTU Nov/Dec 05) Convert the following arithmetic expression into syntax tree and three address code b* 3 (a+b) (JNTU Nov/Dec 05, Apr

Write semantic routines to convert a C while statement into three address code. (JNTU Nov/Dec 04, Apr/May 04) Write short notes on peephole optimization techniques. What are the various machine dependent code optimization techniques. (JNTU Apr/May 04) (JNTU Nov 05)

Convert the following arithmetic expression into syntax tree and three address code b* 3 (a+b) (JNTU

Give a translator grammar for converting Boolean expression into three address code. (JNTU Apply the translation scheme on the following expression a< b or c< d and e< f. (JNTU Nov 05) What are the applications of DAG . Explain how the following expression in an can be converted in a DAG (JNTU Aug/Sep 07, Apr 03) a+b*(a+b)+c+d. Explain how loop invariant components can be eliminated. (JNTU Aug/Sep 07)

Translate the expression (a+b)*(c+d)+(a+b+c) into quadruple, triple and indirect triple (JNTU Apr/May 05, 04) Explian in detail the optimization technique Strength Reduction. (JNTU Apr/May 05)

What are the Various machine dependent code optimization techniques (JNTU Apr/May 05) Convert the following arithmetic expression into Syntax tree and three address code b*-(a+b) (JNTU Apr/May 05) Write briefly about various loop optimization techniques (JNTU Apr/May 04, Apr 03) Convert the following Boolean expression into 3 address code A<b and c<d or e>f . : (JNTU Apr/May 04, Apr 03) The following grammar generator all possible binary numbers (JNTU Apr 03) S->L.L/L L->LB/B B->0/1 Write a syntax directed translator scheme to translate the given binary number into its equivalent decimal number Distinguish s-attributed and L-attributed grammars. (JNTU Apr 03)

Explain the quadruples ,triples and indirect triples of a three address statement of intermediate (JNTU Dec/Jan 03) Explain any four issues in the design process of a code generator. Explain various machine dependent code optimization techniques machine dependent code optimization techniques Briefly explain about loop optimization techniques

48 Briefly explain about scope of an optimization 49. Briefly explain about loop &local optimization 50. Explain what is Address Descriptor 51. 52. 53. 54. Explain what is Register Descriptor Explain briefly about global optimization What is flow graph explain it by definition Discuss the properties of reducible flow graph

55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65.

Explain briefly about some other loop optimizations Explain the steps required for elimination of common sub expressions Explain about copy propagation What is induction variable ,define it Explain with an algorithm steps required for detection and elimination of induction variable Explain about reducible flow graphs Discuss global optimization techniques. What are the various object code forms. (JNTU Nov 05) (JNTU Nov/Dec 05)

Why Next-use information is required for generating Object code? What are the application of du-and ud. Discuss global optimization techniques

UNIT VIII 1. Generate code for following instructions and their associated cost, assume 3 registers are available and all variables are static. (a) X = a[i] + 1 (b) a[ i ] = b[ c[ i ] ] (c) a[i][j] = b[i][k] * c[k][j] (n) (d) a[i] = b[i] + c[j]. (JNTU May 11) 2. (a) Give the applications of DAG. (b) Generate code for the following C statements: i. x=++f(a) ii. _p++=_q++. 3. a) Consider the following code sequence. i. MOV B, R0 ADD C, R0 MOV R0, A ii. MOV B, A ADD C, A Calculate the cost of above instructions interms of access time and memory usage. b) What are assembler directives and explain? (JNTU June 10) 4. What are the object code forms? Explain the issues in code generation. (JNTU May 09) 5. Explain about code generation algorithm with example. (JNTU May 09) 6. Explain about register allocation and assignment in target code generation. (JNTU May 09) 7. What is DAG? Explain how a basic block is represented using DAG. (JNTU May 09)

8. Explain issues in the design of a code generator. 9. a Explain the concept of calculating cost of instructions b. Consider below addressing codes along with associated costs. Mode Address Cost Absolute 1 Register 0 Indexed 1 Indirect register 0 Indirect indexed 1 Compare costs of following set if Statements i. mov b, R0 Add c,R0 Mov R0,R1 ii. add R2,R! Mov R!,a iii. Mov b,a Add c,a 10. Write and Explain Heuristic Ordering algorithm for DAG with one example. 11. Write and explain about object code form.

12. 13 14 15 16.

Explain the generic issues in the design of code generator. Write about the various object code forms.

(JNTU Nov/Dec 05, Apr/May 05) (JNTU Nov/Dec 05, Apr/May 05)

Efficient code generation requires the knowledge of internal architecture of the target machine. Justify your answer with an example. (JNTU Aug/Sep 06) What are the various addressing mode are available? (JNTU Aug/Sep 06)

Give some examples of machine instructions which reduces memory access time.

17 a. Discuss the various forms of object code. (JNTU Aug/Sep 07, Nov 03) b. Explain how the nature of the object code is highly dependent on the machine and operating system 18 a. b. Write a macro which takes A,B,C and D as parameters and calculates A*B+C*D in any register Where would you store the temporary result? Would you reserve space for the temporary results with in the macro body or outside it(i.e. In the main program Why? What are the advantages and disadvantages of these alternatives. (JNTU Aug/Sep 07) Define Address Descriptor and Register Descriptor Why Next use information is required for generating object code? What are the various object code forms (JNTUApr/May05)

Explain how Lexical substitution is performed for model statements by a macro preprocessor Differentiate Positional and Keyword parameter. (JNTU Apr/May 05) How the value of the positional and Keyword parameter is determined?Explain with an example Augment the code generation algorithm to incorporate the following features.(JNTU Apr/May i. the parenthesis is an expression

b.

ii. Non commutative operators like - and/ etc show various steps in the code generation algorithm of the expression (a+b)/(c+d) Assuming two machine registers to be available.

22 Briefly explain the functions performed during Synthesis and Analysis Phase of an assembler design (JNTU Apr/May 05, 04) 23 a. b. Write a macro which takes A,B,C and D as parameters and calculates A*B+C*D in any register Where would u store the temporary result? Would you reserve space for the temporary results with in the macro body or outside it (i.e. in the main program) why? What are the advantages and disadvantages of these alternatives. (JNTU Apr 03) Write the features of Assembly Language programming. Write the general format of an Assembly language statement. Explain the 3 kinds of statements of an assembly program. (JNTUApr/May07, 04) (JNTU Apr/May 07) (JNTU Apr/May 07, 04)

Explain how lexical substitution is performed for model statements by a macro preprocessor. (JNTU Apr/May 07) Differentiate Positional and keyword parameter. (JNTU Apr/May 07)

How the value of the positional and keyword parameter is determined? Explain with an example. (JNTU Apr/May 07) 30. How are constants defined in an assembly program? Explain with an example. (JNTU Apr/May 07, Nov 05, 03) 31. What is meant by Assembler directives? Explain the functions of the following assembler directives. i. START ii. ORIGIN iii. EQU iv. LTORG 32. 33. 34. 35. 36. 37. 38. 39. 40. List out the data structure to perform Macro Expansion. Write an algorithm for Macro processing (JNTU Apr/May 06) (JNTU Apr/May 06)

Write the design specification for a parameter in macro statement (JNTU Apr/May 06, Nov/Dec 05, Aug/Sep 06) What is meant by Expansion time Variable (EV). Write the syntax of two forms of Expansion time variable. (JNTU Apr/May 06) How the value of EV can be manipulated through the preprocessor statement SET. Explain with an example (JNTU Apr/May 06) Write the features of Assembly Language programming. Write the general format of an Assembly language statement. Explain the 3 kinds of statements of an assembly program. (JNTU Apr/May 06) (JNTU Apr/May 06) (JNTU Apr/May 06)

An assembly Language program contains the following statement.(JNTU Apr/May 06, Apr 03) X EQU Y + 25

Indicate how the EQU statement can be processed by a single pas assembler If i. Y is a Back reference ii. Y is a Forward reference. 41. What are assembler directives.

42 Augment the code generation algorithm to incorporate the following features.(JNTU Apr/May 06) i. The parenthesis in an expression ii. Non commutative operators like - and / etc 43. Show various steps in the code generation algorithm of the expression ( a + b) / ( c + d) Assuming two machine registers to be available.

44. Explain the memory requirement for variant I and variant II of intermediate code of an assembler design. (JNTU Apr/May 06, Aug/Sep 06, 07) 45. 46. 47. 48. 49. 50. 51. 52. How Declarative state and Assembler directives are processed by an assembler. Differentiate single pass and two pass translation of an assembler. Explain Macro expansion and Lexical expansion. List out the data structure to perform Macro Expansion. Write an algorithm for Macro processing. Explain the generic issues in the design of code generator. Write about the various object code forms. (JNTU Nov/Dec 05) (JNTU Nov/Dec 05) (JNTU Nov/Dec 05, 04) (JNTU Nov/Dec 05, 04) (JNTU Nov/Dec 05, Apr/May 05) (JNTU Nov/Dec 05, Apr/May 05)

Explain the memory requirement for variant I and variant II of intermediate code of an assembler design. (JNTU Nov/Dec 05, Apr/May 05, Nov 03)

53. How Declarative state and Assembler directives are processed by an assembler.(JNTU Nov/Dec 05) 54. 55. 57. i. List out the data structure to perform Macro Expansion. Write an algorithm for Macro processing. (JNTU Nov/Dec 05) (JNTU Nov/Dec 05)

Consider the following code sequence. (JNTU Aug/Sep 06, 07, Nov 05) MOV B, R0 ADD C, R0 MOV R0 A ii. MOV B,A ADD C, A Calculate the cost of the above instructions in terms of access time and memory usage. Explain the simple Strategy to generate assembly code from Quadruples. (JNTU Aug/Sep 06, 07, Nov 05) Efficient code generation requires the knowledge of internal architecture of the target machine. Justify your answer with an example. (JNTU Aug/Sep 06) What are the various addressing mode are available? (JNTU Aug/Sep 06) Give some examples of machine instructions which reduces memory access time. (JNTU Aug/Sep 06) Define the following

What is meant by Macro definition? Explain the data structures used in a Macro Processor. Formulate an algorithm for the First pas of the assembler. Explain the Data structure used during the PASS I of an assembler. [16] (JNTU Aug/Sep 06, Apr/May 04) Differentiate single pass and two pass translation of an assembler. Explain Macro expansion and Lexical expansion. (JNTU Nov 05)

Design the algorithm for the PASS II of an assembler. Explain the Data structure used in PASS II (JNTU Nov 05) Discuss the various forms of object code. (JNTU Aug/Sep 07, Nov 03) Explain how the nature of the object code is highly dependent on the machine and operating Write a macro which takes A,B,C and D as parameters and calculates A*B+C*D in any register Where would you store the temporary result? (JNTU Aug/Sep 07) Would you reserve space for the temporary results with in the macro body or outside it(i.e. In the main program Why? What are the advantages and disadvantages of these alternatives. Define Address Descriptor and Register Descriptor Why Next use information is required for generating object code? What are the various object code forms (JNTU Apr/May 05)

Explain how Lexical substitution is performed for model statements by a macro preprocessor Differentiate Positional and Keyword parameter. (JNTU Apr/May 05) How the value of the positional and Keyword parameter is determined? Explain with an example i.

71. a. Augment the code generation algorithm to incorporate the following features. the parenthesis is an expression ii. Non commutative operators like - and/ etc (JNTU Apr/May 05) b. show various steps in the code generation algorithm of the expression (a+b)/(c+d) Assuming two machine registers to be available.

72. Briefly explain the functions performed during Synthesis and Analysis Phase of an assembler design (JNTU Apr/May 05, 04) 73. a. Write the general format of Macro Prototype statement and macro call give an example b. What is meant by Conditional expansion and Expansion time Loops? c. Define Macro Expansion Counter (MEC).Mention its functions. (JNTU Apr/May 05) 74. 04) 75. a. Write a macro which takes A,B,C and D as parameters and calculates A*B+C*D in any register Where would u store the temporary result? Design the algorithm for the PASS II of an assembler .Explain the data Structure used in PASS II (JNTU Apr/May

b.

Would you reserve space for the temporary results with in the macro body or outside it (i.e. in the main program) why? What are the advantages and disadvantages of these alternatives. (JNTU Apr 03) Explain the design process of an assemblies (JNTU Dec/Jan 03) What is nested macro? Explain it with a suitable example. Describe , how addressing modes can be used for reducing the memory access time. Generate the code sequence using Code generation algorithm for the following expression. W := (A-B) + (A C) + (A- C) (JNTU Aug/Sep 08)

Explain the different issues in the design of a code generator. Generate code for the following C Statements. i . f (a) + f (a) ii . x= f(a) / g ( b,c) iii. x = f ( f ( a)) iv. x = + + f ( a) (JNTU Aug/Sep 08) 79.Consider the following PASCAL program segment: If I mode 2 = 0 then While i>=0 do Begin i:=I div 2; If I mod 2<>0 do then i:=i-1; Else i:=i-2 End An appropriate loop invariant for the while loop is ----what are x and y in the following macro definition ? (GATE 95) macro Add x,y Load y Mul x Store y End macro (a)Variables (b)Identifiers (c)Actual parameters (d)Formal parameters 80. Given the following source program (GATE 95) START 100 A DS 3 MOVER X,B ADD X,C MOVEM X,D D EQU A+1 L2 PRINT D C DC 5 ORIGIN L2 + 1 STOP B DC 19 END. a. Show the contents of the symbol table at the end of the PASS I b. Explain the significance of EQU and ORIGIN statements in the program. c. Show the intermediate code generated for the given program. 81. Given the following source program (GATE 95) START 100 A DS 3 MOVER X,B ADD X,C MOVEM X,D D EQU A+1 L2 PRINT D

C DC 5 ORIGIN L2 + 1 STOP B DC 19 END. Show the contents of the symbol table at the end of the PASS I Explain the significance of EQU and ORIGIN statements in the program. Show the intermediate code generated for the given program. Explain the generic issues in the design of code generator. Write code generation algorithm .Explain it by taking suitable examples Explain the design process of a macro processor

85. 86 87

Briefly explain about DAG representation of basic blocks Explain briefly about DAG construction What do you mean by frequency reduction?

1.1.13

TUTORIAL SHEET

WEEK-1:

2. What is NFA? Explain with an example. 3. What is DFA? Explain with an example. 4. Convert the following NFA to equivalent DFA

WEEK-2:

1.What is a translator? Explain about different translatrs indetail. 2. Define compiler. Explain various phases of the compiler with a neat sketch. 3. Explain the bootstrapping process with a suitable diagram.

4. Write a general format of the LEX program and give an example. 5. . Describe lexical analysis and lex tools.

WEEK-3:

1. What is CFG? Give the examples. 2. (a) Draw the parse tree for an expression: a_ - ( b + c ) (b) Give the Context Free Grammar(CFG) that generates the set f0 to 1 3. (a) Give the CFG generating the set of palindromes over an alphabet (b) Consider the following recursive grammar : S Sa/Sb/ a/b Obtain an equivalent grammar with NO left recursion. 4. Explain about left linear and right linear grammars with examples. 5.Define ambiguity. Give the examples.

WEEK-4:

1. a.Define LL(1) grammar. b.Construct LL(1) parse table for the following grammar. bexpr ! bexpr or bterm|bterm bterm ! bterm and bfactor|bfactor bfactor ! nst factor|(bexpr)|true|false. Where or, and, not (, ), true, false are terminals in the grammar Compute the FIRST and FOLLOW sets of each of the non terminal for the following grammar.

2.

P AQRbe / mn/ Dei A ab / ^ Q q1q2/^ R r1r2/^ D d E e. 3. Construct a Predictive parser table for the following grammar. E->E+T/T T->T*F/F F->(E) /xy/xz 4. Find the reduced grammar that is equivalent to the CFG given below: S->aC/SB A->bSCa B->aSB/bBC C->aBC/ad 5. Construct the given grammar and test whether grammar is LL(1) or not . S->1AB/ A->1AC/0C B->0S C->1

WEEK-5:

E ! E + T=T T ! T _ F=F

3. Construct LALR parse table for the following grammer S!L=R S!R L ! _R L ! id (JNTU Apr/May 07, 06, 04, Aug/Sep 07)

R!L

4. Design SLR(1) parser for the following grammar. S->aAb/bB A->Aa/ B->Bb/ 5. Design CLR(1) parser for the grammar give below S->aAb A->Aa/

WEEK-6:

1. . (a) what is LR parser ? Compare and Contrast the different types of Lr parser.

(b) Construct the CLR parse table for the following augmented grammar:: A1 A A ( A ) /a 2. Describe about YACC. 3. a. Construct the SLR parse table for the following grammar. S->Aa/bAc/dc/bda b. Distinguish SLR ,LALR grammar 4.Compare among LR(0),LALR, CLR indetail. 5. Define shift reduce parser with an example grammar

A->d

WEEK-7:

Write a short note on abstract syntax tree. Compare and contrast the quadruples, triples & indirect triples. Construct Quadruple, Ttriples,and Indirect Triples of the following expression ( a + b) * ( c + d )- ( a + b + c) 4. what is a three address code ? Give an Example 5 a. What is a syntax tree? b. How to construct syntax tree for expressions? c. Construct a syntax tree for the expression a-4+c 1. 2. 3.

WEEK-8:

1. What is a Syntax Directed Translation Scheme? Explain with an example

2. Describe about S-attributed and L-attributed grammars 3. Explain in detail how an L-attributed grammar can be converted into a translator scheme 4. Explain Flow of-control constructs 5. (a) What is synthesized attribute? Explain its functions. (b)What is inherited attributes? Explain its functions

WEEK-9:

1. 2. 3. 4 What is Context Sensitive Grammar? Write its features Explain Chomsky Hierarchy of languages What is type cheking.? a. What is a type checker ? How does it work? b. Write a short notes on static and dynamic type checking. 5. a What is type expression? Write type expression for the following types. i. A two dimensional array of integers (i.e. an array of arrays) whose rows are indexed from 0 to 9 and whose columns are indexed from -10 to 10. ii Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character. c. What is type system. Discuss static and dynamic checking of types.

WEEK-10:

1. a. Discuss about the overloading of functions and operators with an examples. b. Write a notes on polymorphic functions. 2. Write short notes on a. Type conversion with example. b. Type coercion with example 3. a. Define type systems. b. Explain about static checking of types. 4. Discuss with the following a. Type checking of expression. b. Type checking of statements. c. Type checking of functions. 5. Discuss the with the equivalaince of type expressions.

WEEK-11:

1. . Explain about: a) a variable local to a procedure b) a global variable c) a formal parameter d) a dynamically allocated global variable e) a compiler generated temporary variable.

2. a. What is an activation record? Explain how it is related with run time storage organization. b. Write a short notes on heap strategy and run-time storage allocation. 3. a. What are the contents of a symbol table? Explain in detail. b. What is the data structure used to implement a symbol table in an efficient way? Give reasons? 4. Explain about Block Structure storage allocation

4.

WEEK-12:

1. Explain in detail the various storage allocation strategies. 2. Explain how the scope information is represented in the symbol table for the block structured language. 3. Explain briefly about storage allocation for arrays,strings, records. 4. Differentiate b/w static & dynamic storage allocation 5. Discuss about the stack allocation strategy of Run time envi. With an example.

WEEK-13:

1. Describe about the data structures for a symbol table in detail 2. Explain hash table organization of symbol tables for block structure languages. 3. Explain heap table organization of symbol tables for block structure languages. 4.Explain stack table organization of symbol tables for block structure languages. 5.Explain static table organization of symbol tables for block structure languages.

WEEK-14:

1. 2. 3. 4. 5. Describe about principal sources of optimization Explain about optimization of basic blocks Describe about peephole optimization Explain the machine independent Optimization in detail Compare various forms of three address code

WEEK-15:

1. Explain about Algebraic Transformations? 2. What is a flow graph? Explain data flow analysis of flow graphs.

3. What are loop invariant components. Explain how they effect the efficiency of a program 4. Apply the translation scheme on the following expression a< b or c< d and e< f. 5. Briefly explain about loop &local optimization

WEEK-16:

1. Briefly explain about DAG representation of basic blocks

2. What are the various addressing mode are available? 3. Explain about code generation algorithm with example 4. Explain about register allocation and assignment in target code generation. 5. . a Explain the concept of calculating cost of instructions b. Consider below addressing codes along with associated costs. Mode Address Cost Absolute 1 Register 0 Indexed 1 Indirect register 0 Indirect indexed 1

1.1.14

ASSIGNMENT QUESTIONS

UNIT-I:

2. Define DFA and NFA. Give examples. 3. Define FA and RE. Give examples. 4. Construct minimum state DFAs for the following regular expressions. i. (a+b)* a (a+b) [3] ii. (a+b)* a (a+b) (a+b) [3] iii. (a/b)* a (a/b)(a/b)(a/b). [3] 5Construct an NFA for the regular expression R=(a+b)* abb convert it in to an equivalent DFA 6. Compare compiler and interpreter with the help of suitable example. 7. Define compiler. Explain various phases of the compiler with a neat sketch. 8. Explain the bootstrapping process with a suitable diagram.

9. Write a general format of the LEX program and give an example. 10. Describe lexical analysis and lex tools.

UNIT-I1:

1. What is CFG? Explain with an example. 2. Define the following with ex. a. Parse tree b. LMD c. RMD 3. What is LL(1) grammar? Explain the steps involved in it. 4. Explain ambiguous grammar and LL(K) grammar 5. Differentiate left linear grammar and right linear grammar 6. Construct a Predictive parsing table for the following grammar where S/ is a start symbol and # is the end marker. S/->S#

S->qABC A->a/bbD B->a/ C->b/ D->c/ 7. Construct LL(1) parsing table for the following grammar S->aBDh B->cC C->bC/ D->EF E->g/ F->f/ 8. Compute the FIRST and FOLLOW sets for each non terminal of the grammar given below: S->ABa/bCa A->cBCD/ B->CdA/ad C->eC/ D->bSf/a 9. Construct the LL(1) table for the following grammar. 1. Expr->_Expr 2. Expr->(Expr) 3. Expr->Var Expr Tail 4. ExprTail->_Expr 5. ExprTail->^ 6. Var ->id Var Tail 7. VarTail->(Expr) 8. VarTail->^ 9. Goal->Expr$ 10. Design LL(1) parse table for the following grammar. S->aAcd/BCe A->b/ B->Cf/, C->fe

UNIT-III:

1. What is Parsing? Explain about bottom up parsing techniques. 2. What is handle pruning? Explain 3. Describe about YACC 4. Explain ambiguous grammars 5. Consider the following grammar : E->E+T/T T->T*F/F F->(E) /a Construct the SLR parse table . 6. Construct LALR(1) parse table for the following grammar for S ->Aa|bAc|Bc|bBa A!d B!d. 7. Compare among LR(0),LALR, CLR in detail. 8. Consider the following augmented grammar: S-> E

E E+T T a/(E) (c) Construct the DFA whose states are the canonical collection of LR(0) items. Construct the SLR(1) parse table. 9. Construct SLR parsing table for the following grammar R-> R->R1R/RR/R*/(R)/a/b. 10. Define shift reduce parser with an example grammar

UNIT-IV:

(b) Compare and contrast the quadruples, triples & indirect triples 2. Design an abstract syntax tree for the expression: a = (a[i+1] = 2) + a[j 3. Construct Quadruple, Ttriples,and Indirect Triples of the following expression ( a + b) * ( c + d )- ( a + b + c) 4. Consider the following grammar:: D. TL T INT /FLOAT L L,ID/ID (a) Write the Syntax Directed Definition to add the type of each identifier to its entry in the Symbol table during semantic analysis. (b) Draw an annotated parse tree for the declaration: float,id1,id2,id3; 5. What is a Syntax Directed Translation Scheme? Explain with an example 6. Explain in detail how an L-attributed grammar can be converted into a translator scheme 7. What are S-attributed and L-attributed grammars. 8. What is synthesized attribute? Explain its functions. 9 . Define annotated Parse tree. Explain with an example.

UNIT-V:

1. Explain Chomsky Hierarchy of languages

3. Discuss in detail about semantic analysis phase? Explain Type Conversion. Give the Type conversion rules for converting the type from integer to real. 4. Explain the algorithm for testing the structural Equivalence

5. What is Context Sensitive Grammar? 6. Write notes on overloading of functions and operations. 7. aWhat is type expression? Write type expression for the following types.

i. A two dimensional array of integers (i.e. an array of arrays) whose rows are indexed from 0 to 9 and whose columns are indexed from -10 to 10. ii. Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character. b. What is type system. Discuss static and dynamic checking of types. 8. What is type expression? Write type expression for the following types 9. a. What is coercion? b. Explain the implicit type convertions. 10. Define the overloading of operaters.

UNIT-VI:

1. a. Explain how the symbol table space can be reused. Explain through an example. b. Discuss various symbol table organization techniques. 2. a. What is an activation record? Explain how it is related with run time storage organization. b. Write a short notes on heap strategy and run-time storage allocation. 3. Define format of activation records in detail 4. .What are the language facilities for dynamic storage allocation? 5. How to handle local names and parameters? 6 Describe about Storage Organization in detail. 7. Describe dynamic storage allocation stratagies. 8. a. Write a notes on the static storage allocation strategy with examples and discuss its limitations. b. Discuss about the static allocation strategy of run-time environment with examples.

UNIT-VII:

2 Explain about optimization of basic blocks . 3. Describe about peephole optimization. 4. What is a flow graph? Explain data flow analysis of flow graphs. 5. a What is a flow graph. Explain how a given program can be converted into a flow graph b Explain the loop optimization 6. Explain about Data-Flow analysis of structured flow graphs. 7. Explain the machine independent Optimization in detail. 8. Write and explain about Peephole optimization. 9. Explain with an example the abstract machine code form of Intermediate code. 10. Write briefly about various loop optimization techniques

UNIT-VIII:

1. 2. 3. 4. 5 What are the object code forms? Explain the issues in code generation. Explain about code generation algorithm with example. Explain about register allocation and assignment in target code generation Explain the generic issues in the design of code generator. Write about the various object code forms.

6 7. 8. 9.

Efficient code generation requires the knowledge of internal architecture of the target machine. Justify your answer with an example. What are the various addressing mode are available? Give some examples of machine instructions which reduces memory access time. What is DAG? Explain how a basic block is represented using DAG

- Pcd RecordЗагружено:blacklistrivals711
- System Software Unit-IIЗагружено:palanichelvam
- PCD Lab ManualЗагружено:thalasiva
- Mobile Phone Operating System PptЗагружено:Prashant Awotorsing
- Principles of Compiler designЗагружено:Ravi Raj
- VisiCodeMiner - Discovering the Business DNAЗагружено:Visionet Systems, Inc.
- Syntax Directed TranslationЗагружено:muler_tesfa
- First and Follow SetЗагружено:api-3696125
- Error Detection RecoveryЗагружено:Tech_MX
- 040Загружено:Yogeswari Mohan
- Regulation2004 Sylabus.pdfЗагружено:Somasundaram Ramu
- Example Program for the Lex and Yacc ProgramsЗагружено:cse.rajiv8466
- JavaTranslatorЗагружено:Li Xio
- GateGenie csЗагружено:Kumar Gaurav
- Compiler Design by Ullman Aho]Загружено:Ashish
- GATE Solved Question Papers for Computer Science and Information Technology [CS] by AglaSem.ComЗагружено:aglasem
- System Software Question Bank 2012 With Part-B AnswersЗагружено:sumathi79
- Compiler DesignЗагружено:Mohd Shahid
- CHAP09Загружено:Kui Mangus
- Compiler Construction Lecture 6Загружено:R U Bored ??
- TY_ITЗагружено:rahulbhagat
- CD_R13_UNIT I_JNTUKЗагружено:manjusha
- BTech II Year Comp. Sc. & Engg. and Related Programs (Effective From 2017-18)Загружено:krishan
- Removing Bidirectionality From Nondeterministic Finite AutomataЗагружено:David Fernando Casas
- Through Twitter GlassЗагружено:Alexander Glasman
- SP(名詞解釋)Загружено:Mahesh Gosemath
- The Top 9½ Books In a Hacker's Bookshelf _ GrokCodeЗагружено:Alok H Tripathi
- Ply TalkЗагружено:piyavn5930
- 02 Character i oЗагружено:Muthu Ganesh Veerabaku
- AH Computing All 2012Загружено:esoel

- Cortem Group - Product GuideЗагружено:Anonymous cHU3zkYvf
- Ado.net 2.0 Day1Загружено:Vani Chopra
- ENZYME-LINKED FLUORESCENCE IMMUNOASSAYSЗагружено:Prakash
- Kobetsu KaizenЗагружено:coded2code
- Finalexam RevЗагружено:HuấnĐìnhNguyễn
- PDF Gene 7Загружено:api-3696645
- Digest Tolentino v. CatoyЗагружено:James
- Fluid Power CircuitsЗагружено:Mike Fredskilde
- Phrases of Conversation TestЗагружено:Selfhel
- Documento8399 El Deporte Femenino en La Antigua GreciaЗагружено:Sibi
- 19 - Fraud Inquiries TemplateЗагружено:Aayushi Jain
- SRS on hmsЗагружено:Rahul Dwivedi
- Jones Williams motion deniedЗагружено:Sarah
- SHGsЗагружено:krt17
- Admin Case Digest RecentЗагружено:Emily Unson
- Proposed Revisions to Planning Delegated Powers at Barnet Council - 14 June 2012Загружено:MisterMustard
- Razi's DissertationЗагружено:benson
- Brio6xstudent IbmЗагружено:amunozm
- Escrdb Gather Form 1.0Загружено:Houlahan
- SAP HCM Training Online TrainingЗагружено:fahadsap
- Subduction Model.pdfЗагружено:allansaja
- 2009 DfiЗагружено:Handayani lestari
- BIB_KIKIRPA_BUL_1992_024_161-170Загружено:PS
- The Documentary Credit in General TermsЗагружено:Kwalar King
- Gordons Functional Health Pattern Assessment Tool (Bano, R.)Загружено:ojay88
- Can You Hear Me the Right of Young Children to Participate in Decisions Affecting Them[1]Загружено:Carolina Cárdenas Fernández
- jurnalЗагружено:Novitasari S
- Grade 10 Activity ProbabilityЗагружено:Roqui M. Gonzaga
- SUBMERGED ARC WELD RESTORATION OF STEAM TURBINE ROTORS USING.pdfЗагружено:Rafael Garcia Illescas
- debating techniquesЗагружено:api-326297755

## Гораздо больше, чем просто документы.

Откройте для себя все, что может предложить Scribd, включая книги и аудиокниги от крупных издательств.

Отменить можно в любой момент.