ANNA UNIVERSITY · REGULATION 2021
Important Questions
CS 3501 — COMPILER DESIGN
Fifth Semester · Computer Science and Engineering
Prepared from 3 previous year question papers (Nov/Dec 2024, Apr/May 2024, Nov/Dec 2023). Every question was compared with the others of its unit; the ones asked more than once come first. "Most asked topics" shows in how many different exams a syllabus topic had a question.
UNIT 1Introduction to Compilers & Lexical Analysis
Most asked topics: The Phases of Compiler (2/3) · Role of Lexical Analyzer (2/3) · Finite Automata (2/3)
Part A · 2 marks
- 1.State the term interpreter.(2)
Asked in Nov/Dec 2024
- 2.Write the major task of lexical analyzer.(2)
Asked in Nov/Dec 2024
- 3.State the difference between a compiler and an interpreter.(2)
Asked in Apr/May 2024
- 4.Define the interaction between lexical analyzers and parsers.(2)
Asked in Apr/May 2024
- 5.Define compiler.(2)
Asked in Nov/Dec 2023
- 6.What is finite automata?(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.Draw the phases of compiler and describe each phase of it.(13)
Asked 2 times: Nov/Dec 2024, Nov/Dec 2023
- 2.(i) Divide the following C++ program. float limitedSquare(x) { /* returns x-squared, but never float x; more than 100*/ return (x<=-10.0||x>=10.0)? 100:x*x; } Into appropriate lexemes. Which lexemes should get associated lexical values? What should those values be? (ii) Explain the role of lexical analyzer.(13)
Asked 2 times: Apr/May 2024, Nov/Dec 2023
- 3.Define finite automata. Explain the two types of finite automata with suitable example.(13)
Asked in Nov/Dec 2024
- 4.(i) Describe the languages denoted by the following regular expressions: (1) a(a|b)*a (2) ((epsilon|a)b*)* (3) (a|b)*a(a|b)(a|b) (4) a*ba*ba*ba* (5) !! (aa|bb)*((ab|ba)(aa|bb)*(ab|ba)(aa|bb)*)*. (ii) Explain the construction of a DFA from a regular expression.(13)
Asked in Apr/May 2024
UNIT 2Syntax Analysis
Most asked topics: Parser (3/3) · Error Handling and Recovery in Syntax Analyzer (2/3) · Role of Parser (1/3) · Grammars (1/3) · Context-free grammars (1/3) · LR Parser (1/3)
Part A · 2 marks
- 1.Mention the role of parser.(2)
Asked in Nov/Dec 2024
- 2.Specify the error recovery in YAAC.(2)
Asked in Nov/Dec 2024
- 3.What are the common programming errors that can occur at different levels?(2)
Asked in Apr/May 2024
- 4.What is the purpose of LR parsers?(2)
Asked in Apr/May 2024
- 5.What are the goals of error handler in a parser?(2)
Asked in Nov/Dec 2023
- 6.Define a parse tree.(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.Construct a parse tree for the input string starting from the root and creating the nodes of the parse tree in preorder using top-down parsing.(13)
Asked in Nov/Dec 2024
- 2.Write the error handling process and recovery in syntax analyzer.(13)
Asked in Nov/Dec 2024
- 3.(i) Consider the context-free grammar. S -> SS + | S S * | a and the string aa + a* (1) Give a leftmost derivation for the string. (1) (2) Give a rightmost derivation for the string. (1) (3) Give a parse tree for the string. (1) (4) Is the grammar ambiguous or unambiguous? Justify your answer. (2) (ii) Explain the error handling and error recovery mechanism of syntax analyser.(13)
Asked in Apr/May 2024
- 4.(i) Show that the following grammar. S -> S A | A A -> a is SLR(1) but not LL(1). (ii) State and explain the algorithm to eliminate left recursion from a grammar.(13)
Asked in Apr/May 2024
UNIT 3Syntax Directed Translation & Intermediate Code Generation
Most asked topics: Type Checking (3/3) · Construction of Syntax Tree (1/3) · Design of predictive translator (1/3) · Three Address Code (1/3) · Translation of Expressions (1/3) · Back patching (1/3)
Part A · 2 marks
- 1.Express the construction of syntax tree.(2)
Asked in Nov/Dec 2024
- 2.Source-language expression is x + y * z and translate it into the sequence of three-address code instructions.(2)
Asked in Nov/Dec 2024
- 3.Define inherited attribute.(2)
Asked in Apr/May 2024
- 4.State the rules of type checking.(2)
Asked in Apr/May 2024
- 5.What is meant by Back patching?(2)
Asked in Nov/Dec 2023
- 6.What is meant by Type Checking?(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.Summarize how to construct syntax trees for simple expressions.(13)
Asked in Nov/Dec 2024
- 2.Discuss about the things behind type checking in intermediate code generation.(13)
Asked in Nov/Dec 2024
- 3.(i) The expressions involving operator + and integer or floating-point operands. Floating-point numbers are distinguished by having a decimal point. E -> E + T | T T -> num.num | num Give an SDD to determine the type of each term T and expression E. (ii) Explain the S-Attribute Definitions with example.(13)
Asked in Apr/May 2024
- 4.(i) Translate the arithmetic expression a + (b + c) into (1) Syntax tree (2) Quadruples. (ii) State and explain the translation of expressions and the addressing array elements with example.(13)
Asked in Apr/May 2024
UNIT 4Run-Time Environment and Code Generation
Most asked topics: Issues in the Design of a code generator (3/3) · Design of a simple Code Generator (3/3) · Storage Allocation Strategies: Static (2/3) · Dynamic Storage Allocation (2/3)
Part A · 2 marks
- 1.Differentiate between static and dynamic storage allocation.(2)
Asked in Nov/Dec 2024
- 2.Define flowgraph.(2)
Asked in Nov/Dec 2024
- 3.What are two strategies for dynamic storage allocation?(2)
Asked in Apr/May 2024
- 4.Write the role of activation record.(2)
Asked in Apr/May 2024
- 5.Define symbol table.(2)
Asked in Nov/Dec 2023
- 6.What is a flow graph? Give example.(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.Elaborate the issues in the designing of a code generator.(13)
Asked 3 times: Nov/Dec 2024, Apr/May 2024, Nov/Dec 2023
- 2.With neat diagram illustrate typical subdivision of run-time memory into code and data areas.(13)
Asked in Nov/Dec 2024
- 3.Explain the stack allocation of space with example? What principles are helpful when designing calling sequences?(13)
Asked in Apr/May 2024
- 4.Discuss about the run time storage management of a code generator in detail.(13)
Asked in Nov/Dec 2023
UNIT 5Code Optimization
Most asked topics: Optimization of Basic Blocks (2/3) · Principal Sources of Optimization (1/3)
Part A · 2 marks
- 1.Identify the causes of redundancy.(2)
Asked 2 times: Nov/Dec 2024, Apr/May 2024
- 2.Write the principal sources of optimization.(2)
Asked in Nov/Dec 2024
- 3.What is copy propagation?(2)
Asked in Apr/May 2024
- 4.What is DAG? Give example.(2)
Asked in Nov/Dec 2023
- 5.What is basic block?(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.Write short notes on optimization of basic blocks using Directed Acyclic Graph (DAG).(13)
Asked 3 times: Nov/Dec 2024, Apr/May 2024, Nov/Dec 2023
- 2.State and explain peephole optimization as an effective technique to improve the locally target code.(13)
Asked in Nov/Dec 2024
- 3.What are induction variable and how to find the induction variable in loops and optimize their computation. Explain with example.(13)
Asked in Apr/May 2024
- 4.Explain the principle sources of code optimization in detail.(13)
Asked in Nov/Dec 2023
PART CAny unit
Part C · 15 marks
- 1."A Syntax-Directed Definition (SDD) is a context-free grammar together with attributes and rules". - Justify the statement.(15)
Asked in Nov/Dec 2024
- 2.Write a review on the "recent trends in compiler design".(15)
Asked in Nov/Dec 2024
- 3.Construct the DAG and identify the value numbers for the subexpressions of the following expressions, assuming + associates from the left. (i) a + b + (a + b) (ii) a + b + a + b (iii) a + a + (a + a + a + (a + a + a + a)).(15)
Asked in Apr/May 2024
- 4.Explain the steps involved in the construction of predictive parser with suitable example.(15)
Asked in Apr/May 2024
- 5.How the context free grammar will work and compare various parser techniques performance using various code blocks?(15)
Asked in Nov/Dec 2023
- 6.How the data flow optimization can be done and compare the features?(15)
Asked in Nov/Dec 2023