Jawaharlal Nehru Technological University Hyderabad
Jawaharlal Nehru Technological University Hyderabad B.Tech III COMPILER DESIGN Previous Question Paper (May/June - 2019 - R13)
Note: This question paper contains two parts A and B. Part A is compulsory which carries 25 marks. Part B consists of 5 Units. Answer any one full question from each unit. Each question carries 10 marks and may have a, b, c as sub questions.
Part A
Why lexical and syntax analyzers are separated?
Answer
Separation simplifies compiler design by modularizing the process. Lexical analysis handles character stream processing and tokenization, which is easier to implement using regular expressions, while syntax analysis focuses on the hierarchical structure using context-free grammars. This separation improves compiler efficiency, maintainability, and portability.
List the various error recovery strategies for a lexical analysis.
Answer
Common error recovery strategies include: 1) Panic mode recovery (deleting successive characters until a valid token is found), 2) Local correction (inserting, deleting, or replacing a character), and 3) Global correction (minimizing the number of changes to transform the input into a valid sequence).
Mention the types of LR parser.
Answer
Sign in to view the complete answer paper.
Define LR(0) items with examples.
Answer
Sign in to view the complete answer paper.
What are the benefits of intermediate code generation?
Answer
Sign in to view the complete answer paper.
Explain about hashing.
Answer
Sign in to view the complete answer paper.
What is a basic block?
Answer
Sign in to view the complete answer paper.
Discuss about common sub expression elimination.
Answer
Sign in to view the complete answer paper.
How do you calculate the cost of an instruction?
Answer
Sign in to view the complete answer paper.
List out the common issues in the design of code generator.
Answer
Sign in to view the complete answer paper.
Part B
Explain the various phases of a compiler in detail. Also write down the output for the following expression after each phase a:=b*c+d.
Answer
Sign in to view the complete answer paper.
What is FIRST and FOLLOW? Explain the steps to compute FIRST and FOLLOW with an example.
Answer
Sign in to view the complete answer paper.
Check whether the following grammar is SLR (1) or not. Explain your answer with Reasons. S→ L=R, S→R, L→*R, L→id, R→L.
Answer
Sign in to view the complete answer paper.
Consider the grammar E → E + T, E → T, T → T * F, T → F, F → (E) | id. Construct CLR parsing table for the above grammar. Give the moves of the CLR parser on id * id + id.
Answer
Sign in to view the complete answer paper.
What is a three address code? Mention its types. How would you implement the three address statements? Explain with examples.
Answer
Sign in to view the complete answer paper.
Describe in detail the syntax directed translation of case statements.
Answer
Sign in to view the complete answer paper.
What are steps needed to compute the next use information?
Answer
Sign in to view the complete answer paper.
Discuss about the following: a) Copy Propagation b) Dead code Elimination and c) Code motion.
Answer
Sign in to view the complete answer paper.
Write the code generation for the d:=(a-b)+(a-c)+(a-c).
Answer
Sign in to view the complete answer paper.
Write a code generation algorithm. Explain about the descriptor and function getreg(). Give an example.
Answer
Sign in to view the complete answer paper.