JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech III Year COMPILER DESIGN Previous Question Paper (September - 2021 - R13)
Answer any five questions. All questions carry equal marks.
Main
List out different phases of compiler and explain each phase role in compilation process
Answer
A compiler translates source code into target machine code through a series of sequential phases:
- Lexical Analysis: Reads the source program as a stream of characters and groups them into meaningful sequences called tokens.
- Syntax Analysis: Takes tokens and creates a hierarchical structure, typically an Abstract Syntax Tree (AST), ensuring the code follows the language's grammar rules.
- Semantic Analysis: Checks for semantic consistency, such as type checking and scope resolution, ensuring the program makes sense beyond its structure.
- Intermediate Code Generation: Produces a machine-independent, low-level representation of the source code, such as Three-Address Code.
- Code Optimization: Improves the intermediate code to make the final machine code run faster or consume less memory without changing the program's behavior.
- Code Generation: Translates the optimized intermediate code into target-specific machine or assembly language.
- Symbol Table Management: A supporting phase that records identifiers and their attributes throughout the compilation process.
- Error Handling: Detects and reports errors encountered during any of the above phases.
Explain the bootstrapping.
Answer
Bootstrapping is the process of using a compiler to compile itself or a newer version of itself. It is a technique used to port a compiler to a new environment or to develop a compiler for a new language.
The process is often represented using the T-diagram, where a compiler is defined by the source language it accepts, the target language it produces, and the language in which it is implemented. The steps typically involve:
- Writing a small subset of the target language compiler in an existing language.
- Compiling this subset using an existing compiler to produce a machine-executable version.
- Using this executable to compile a more complex version of the compiler written in the target language itself.
- Repeating this process until the full-featured compiler is produced.
This allows developers to move from a basic implementation to a fully functional, self-hosting compiler without needing to write the entire system in machine code.
Write a note on complier construction tools.
Answer
Sign in to view the complete answer paper.
Construct recursive descendent parsing table for following grammar.
T → TF | F
F → F* | a | b
Answer
Sign in to view the complete answer paper.
What is LALR parser? Explain LALR parsing algorithm.
Answer
Sign in to view the complete answer paper.
Write a note on YACC.
Answer
Sign in to view the complete answer paper.
What is shift reduce parser? Explain conflicts in shift reduce parser.
Answer
Sign in to view the complete answer paper.
Write LR parsing algorithm.
Answer
Sign in to view the complete answer paper.
Explain various different intermediate code forms.
Answer
Sign in to view the complete answer paper.
Write intermediate code for assignment statement and case statement.
Answer
Sign in to view the complete answer paper.
What is syntax directed translation scheme and write syntax directed scheme for while statement.
Answer
Sign in to view the complete answer paper.
Explain different formants of symbol table.
Answer
Sign in to view the complete answer paper.
Explain, how dead code elimination is done and illustrate with example.
Answer
Sign in to view the complete answer paper.
Explain optimization of basic blocks.
Answer
Sign in to view the complete answer paper.
Write the issues in design of code generation.
Answer
Sign in to view the complete answer paper.
Write the steps for constructing DAG for register allocation.
Answer
Sign in to view the complete answer paper.