JNTU

JNTU B.Tech III COMPILER DESIGN Previous Question Paper (October - 2020 - R13)

B.Tech | III | I | R13 | October - 2020

Answer PaperPaper Code: 115APMaximum Marks: 75Time: 2 Hours

Answer any five questions. All questions carry equal marks.

Main

115 marks
a

Write the need of dividing compilation process into various phases.

7 marks

Answer

Dividing the compilation process into distinct phases is essential for managing the complexity of translating high-level source code into machine-executable code. This modular approach provides several key benefits:

  1. Simplicity and Manageability: Each phase handles a specific sub-task, such as lexical analysis, syntax analysis, or code generation, making the compiler easier to design, implement, and maintain.
  2. Portability: By separating the front-end (which deals with source language analysis) from the back-end (which deals with target machine code generation), the compiler can be retargeted to different machine architectures by replacing only the back-end phases.
  3. Optimization: Intermediate representations allow for machine-independent code optimizations to be performed effectively before translating to specific machine instructions.
  4. Error Detection and Reporting: Distinct phases allow for more precise identification of errors. Lexical errors are caught during scanning, syntax errors during parsing, and semantic errors during type checking, providing clearer feedback to the programmer.
  5. Efficiency: Modular design allows developers to optimize individual phases independently, improving the overall performance of the compilation process.
b

What is top down parsing? Explain difficulties arise in top down parsing.

8 marks

Answer

Top-down parsing is a strategy where the parser attempts to construct a parse tree for the input string starting from the root (the start symbol) and working down to the leaves (the input tokens). It essentially performs a leftmost derivation of the input string.

Several difficulties arise in top-down parsing, primarily due to the limitations of predictive decision-making:

  1. Left Recursion: A grammar containing left-recursive productions (e.g., A → Aα | β) causes a top-down parser to enter an infinite loop, as it will repeatedly try to expand the same non-terminal without consuming any input.
  2. Backtracking: If a grammar is not predictive, the parser may choose the wrong production rule for a non-terminal. When it discovers that the chosen rule does not match the input, it must backtrack to a previous state and try an alternative, which is computationally expensive and inefficient.
  3. Left Factoring: When multiple productions for a non-terminal share a common prefix (e.g., A → αβ1 | αβ2), the parser cannot decide which rule to apply based on the current lookahead symbol. This ambiguity requires the grammar to be transformed to defer the decision until the common prefix is processed.
  4. Lookahead Limitations: Basic top-down parsers (like LL(1)) are restricted by the amount of lookahead available. If a grammar requires looking ahead more than one token to distinguish between productions, standard predictive parsing techniques fail.
215 marks
a

Discuss about error handling mechanism in lexical analyzer.

7 marks

Answer

Sign in to view the complete answer paper.

b

Write predicative parsing algorithm and construct parsing table the input id+id*id for the following grammar.

E → E+T | T, T → T*F | F, F → (E) | id
8 marks

Answer

Sign in to view the complete answer paper.

315 marks
a

Write LR parsing algorithm.

7 marks

Answer

Sign in to view the complete answer paper.

b

Check the following grammar is SLR or not.

S → L=R, S → R, L → *R | id, R → L
8 marks

Answer

Sign in to view the complete answer paper.

415 marks
a

Explain the steps in SLR parser construction.

7 marks

Answer

Sign in to view the complete answer paper.

b

What is ambiguous grammar? How do you eliminate ambiguity in grammar?

8 marks

Answer

Sign in to view the complete answer paper.

515 marks
a

Explain heap storage allocation strategy.

7 marks

Answer

Sign in to view the complete answer paper.

b

Explain three address codes and illustrate with examples.

8 marks

Answer

Sign in to view the complete answer paper.

6

Explain different data structures used for constructing symbol table.

15 marks

Answer

Sign in to view the complete answer paper.

715 marks
a

Explain loop optimization techniques and illustrate with examples.

7 marks

Answer

Sign in to view the complete answer paper.

b

Compare reducible Vs non reducible flow graphs.

8 marks

Answer

Sign in to view the complete answer paper.

815 marks
a

Construct DAG for a sub expression.

7 marks

Answer

Sign in to view the complete answer paper.

b

Write the procedure for generating code from DAG and explain with example.

8 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the question paper of COMPILER DESIGN from JNTU for B.Tech CSE III I, October - 2020, R13.

For the solved question paper with answers, switch to the Answer Paper tab.

Other papers in COMPILER DESIGN

Loading Question Papers

Fetching data from database...