JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech III Year PRINCIPLES OF COMPILER CONSTRUCTION Previous Question Paper (February/March - 2022 - R18)

B.Tech | III Year | II Semester | R18 | February/March - 2022

Answer PaperPaper Code: 156CPMaximum Marks: 75Time: 3 hours

Answer any five questions. All questions carry equal marks.

Main

115 marks
a

Discuss briefly about Lexical Analyzer.

8 marks

Answer

The Lexical Analyzer, or scanner, is the first phase of a compiler. Its primary role is to read the stream of characters from the source program, group them into meaningful sequences called lexemes, and produce a stream of tokens as output for the syntax analyzer.

Key functions include:

  • Tokenization: Identifying keywords, identifiers, operators, literals, and punctuation.
  • Stripping: Removing white spaces, tabs, newlines, and comments that are not relevant to the syntax.
  • Error Handling: Reporting lexical errors such as illegal characters or unterminated strings.
  • Symbol Table Interaction: Entering identifiers into the symbol table to store attributes like type and scope.

The lexical analyzer often operates as a subroutine of the parser, providing the next token only when requested. This separation simplifies the compiler design by isolating the platform-dependent character-handling logic from the language-dependent syntax logic.

b

Explain input buffering in lexical analysis.

7 marks

Answer

Input buffering is a technique used by the lexical analyzer to increase the efficiency of reading characters from the source file. Since reading from disk is expensive, the scanner uses a buffer to hold a block of characters, minimizing the number of system calls.

To handle the lookahead requirement where the scanner must look one or more characters ahead to distinguish between tokens (e.g., distinguishing '=' from '=='), a two-buffer scheme is typically employed:

  • The buffer is divided into two halves, each of size N (the size of a disk block).
  • Two pointers, lexeme_beginning and forward, move across the buffer.
  • When the forward pointer reaches the end of one half, the scanner refills the other half with the next block of input.
  • Sentinels (e.g., the EOF character) are placed at the end of each buffer half to detect the boundary, reducing the number of conditional checks required per character read.

This approach allows the scanner to perform efficient lookahead while maintaining a continuous stream of input, ensuring that the lexical analysis process remains fast and scalable.

215 marks
a

Describe briefly about Top Down Parsing.

8 marks

Answer

Sign in to view the complete answer paper.

b

Write a note on Left Factoring.

7 marks

Answer

Sign in to view the complete answer paper.

315 marks
a

Describe about Dependency Graphs in detail.

8 marks

Answer

Sign in to view the complete answer paper.

b

What is an ambiguous grammar? Give an example of the same.

7 marks

Answer

Sign in to view the complete answer paper.

4

What is Code Generation? Explain briefly about issues in design of code generation.

15 marks

Answer

Sign in to view the complete answer paper.

515 marks
a

Distinguish between L-attributed and S-attributed definition.

8 marks

Answer

Sign in to view the complete answer paper.

b

Explain Principle Sources of Optimization in detail.

7 marks

Answer

Sign in to view the complete answer paper.

615 marks
a

Give an overview of storage allocation strategies.

8 marks

Answer

Sign in to view the complete answer paper.

b

Give an overview of register allocation.

7 marks

Answer

Sign in to view the complete answer paper.

715 marks
a

Explain briefly about reaching definitions.

7 marks

Answer

Sign in to view the complete answer paper.

b

Give an overview of data structures used in symbol table representation.

8 marks

Answer

Sign in to view the complete answer paper.

815 marks
a

Write about Live Variable Analysis in detail.

8 marks

Answer

Sign in to view the complete answer paper.

b

What is Redundancy? Explain about Causes of Redundancy.

7 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the solved question paper with answers of PRINCIPLES OF COMPILER CONSTRUCTION from JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD for B.Tech IT III Year II Semester, February/March - 2022, R18.

For the question paper without answers, switch to the Question Paper tab.

Other papers in PRINCIPLES OF COMPILER CONSTRUCTION

Loading Question Papers

Fetching data from database...