Keep asking yourself. "How bad do you want it? how bad?"
--Your friends at LectureNotes

Solution to Previous Year Exam Questions for Compiler Design - CD of BPUT by Adarsh Dash

  • Compiler Design - CD
  • 2019
  • PYQ Solution
  • Biju Patnaik University of Technology Rourkela Odisha - BPUT
  • Electrical and Electronics Engineering
  • B.Tech
  • 3 Topic/Links
  • 7 Offline Downloads
  • Uploaded 5 months ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-3

1. Answer the following questions: (a) What do you mean by a cross-compiler? Ans:- Cross compiler is a system software which runs in one machine and produce the target code for another machine. (b) Describe the necessity of intermediate code Generation in a compilation process. Ans: - The intermediate code generation phase converts the syntactic structure into equivalent intermediate code. This intermediate representation should have two important properties: It should be easy to produce and it should be easy to translate into the target code. So the intermediate code Generation in a compilation process is very much necessary. (c) What is the role of LEX and FLEX? Explain. Ans: - LEX is a computer program that generates lexical analyzers. LEX tool is a specification of a lexical analyzer, consisting of set of regular expression together with an action for each regular expression. Whereas FLEX is a free software alternative to LEX. It is a tool for generating scanners. A scanner is a program which recognizes lexical patterns in text (d) Write down the various compiler construction tools. Ans:-Some Compiler construction tools are : 1. Parser Generator 2. Scanner Generator 3. Syntax-Directed Translation Engines

Text from page-4

4. Automatic Code Generator 5. Data-Flow analysis Engines (e) Define the term “induction variable” Ans:- Induction variable substitution is a compiler transformation to recognize variables which can be expressed as functions of the indices of enclosing loops and replace them with expressions involving loop indices. This transformation makes the relationship between the variables and loop indices explicit, which helps other compiler analysis, such as dependence analysis. Example: Input code: int c, i; c = 10; for (i = 0; i < 10; i++) { c = c + 5; // c is incremented by 5 for each loop iteration } (f) What are the standard storage allocation strategies? Explain. Static allocation: Statically allocated names are bound to storage at compile time. Storage bindings of statically allocated names never change, so even if a name is local to a procedure, its name is always bound to the same storage. The compiler uses the type of a name (retrieved from the symbol table) to determine storage size required. The required number of bytes (possibly aligned) is set aside for the name. The address of the storage is fixed at compile time. Stack-dynamic allocation: Storage is organized as a stack. Activation records are pushed and popped. Locals and parameters are contained in the activation records for

Lecture Notes