JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD

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

B.Tech | III | II | R18 | August - 2022

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

Answer any five questions. All questions carry equal marks.

Main

115 marks
a

What is the need for a compiler? Explain various phases in compiler construction.

10 marks

Answer

A compiler is a specialized program that translates source code written in a high-level programming language into machine-executable code. Its primary need arises from the fact that computer hardware understands only binary machine instructions, whereas high-level languages provide abstraction, readability, and portability for programmers. By automating the translation process, compilers ensure that complex logic can be executed efficiently on diverse hardware architectures while performing error checking and optimization.

The compilation process is divided into several logical phases:

  1. Lexical Analysis (Scanning): Reads the source code as a stream of characters and groups them into meaningful sequences called tokens.
  2. Syntax Analysis (Parsing): Takes tokens and creates a hierarchical structure, typically a Parse Tree or Abstract Syntax Tree, based on the language's grammar rules.
  3. Semantic Analysis: Checks the tree for semantic consistency, such as type checking and scope resolution, ensuring the program makes sense according to language rules.
  4. Intermediate Code Generation: Produces a machine-independent, low-level representation of the source code, such as Three-Address Code.
  5. Code Optimization: Refines the intermediate code to improve execution speed and reduce memory consumption without changing the program's output.
  6. Code Generation: Translates the optimized intermediate code into the target machine language or assembly code.

Additionally, the Symbol Table Manager and Error Handler interact with all phases to maintain identifier information and report diagnostic messages during the process.

b

Define token. Explain how it is represented.

5 marks

Answer

A token is the smallest individual unit of a programming language that has a specific meaning to the compiler, such as keywords, identifiers, operators, constants, or punctuation marks.

Tokens are typically represented as a pair consisting of a token name (a category like 'identifier' or 'keyword') and an optional attribute value (a pointer to the symbol table entry for that specific token). For example, in the statement count = 10;, the tokens are represented as:

<id, 1>, <assign_op, =>, <number, 10>, <semicolon, ;>
215 marks
a

Give the Lex program structure with an example for identifying keywords in ‘C’ language.

8 marks

Answer

Sign in to view the complete answer paper.

b

Convert 01*+11 Regular expression to NFA and DFA.

7 marks

Answer

Sign in to view the complete answer paper.

315 marks
a

Define context free grammar, parse tree and syntax tree.

6 marks

Answer

Sign in to view the complete answer paper.

b

Explain the steps to construct SLR parsing table.

9 marks

Answer

Sign in to view the complete answer paper.

415 marks
a

What is left factoring and left recursion in context free grammars? Explain the steps to eliminate these in context free grammars.

8 marks

Answer

Sign in to view the complete answer paper.

b

Write an algorithm for working principle of predicate parser.

7 marks

Answer

Sign in to view the complete answer paper.

515 marks
a

What are S-attributes and L- attributes grammar? Explain with an example.

7 marks

Answer

Sign in to view the complete answer paper.

b

Explain the SDD specification of simple type checker.

8 marks

Answer

Sign in to view the complete answer paper.

615 marks
a

Explain various forms of intermediate code.

9 marks

Answer

Sign in to view the complete answer paper.

b

Write the three address code for “if and while” statements.

6 marks

Answer

Sign in to view the complete answer paper.

715 marks
a

Compare various storage allocation methods.

7 marks

Answer

Sign in to view the complete answer paper.

b

What is DAG? Explain its representation for a basic block.

8 marks

Answer

Sign in to view the complete answer paper.

815 marks
a

Explain the principle source of code optimization.

8 marks

Answer

Sign in to view the complete answer paper.

b

Write about data flow analysis of structured program.

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 II, August - 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...