JNTU
JNTU B.Tech III COMPILER DESIGN Previous Question Paper (March - 2024 - R13)
Note: i) Question paper consists of Part A, Part B. ii) Part A is compulsory, which carries 25 marks. In Part A, Answer all questions. iii) In Part B, Answer any one question from each unit. Each question carries 10 marks and may have a, b as sub questions.
Part A
Define lexeme, token, pattern.
Answer
A lexeme is a sequence of characters in the source program that matches the pattern for a token. A token is a category or classification of lexemes (e.g., identifier, keyword). A pattern is a rule or description (often expressed as a regular expression) that determines which lexemes belong to a specific token category.
Construct the transition diagram for relational operators in 'C'.
Answer
The transition diagram for relational operators (>, >=, <, <=, ==, !=) starts at a state and branches based on the input character:
- Start state: if '>', go to state 1; if '<', go to state 3; if '=', go to state 5; if '!', go to state 7.
- State 1: if '=', go to state 2 (>=); else return token >.
- State 3: if '=', go to state 4 (<=); else return token <.
- State 5: if '=', go to state 6 (==).
- State 7: if '=', go to state 8 (!=).
What is meant by goto function in LR parser? Give an example.
Answer
Sign in to view the complete answer paper.
For the grammar S->0S1 | 01. Indicate the handle in each of the following right-sentential forms: i) 000111 ii) 00S11
Answer
Sign in to view the complete answer paper.
Write SDTs for the Boolean expression grammar
Answer
Sign in to view the complete answer paper.
List the properties of a Memory manager for efficient usage of memory.
Answer
Sign in to view the complete answer paper.
What is a DAG?
Answer
Sign in to view the complete answer paper.
Define flow graph and provide an example.
Answer
Sign in to view the complete answer paper.
What is machine dependent optimization?
Answer
Sign in to view the complete answer paper.
How would you calculate the cost of an instruction with an example?
Answer
Sign in to view the complete answer paper.
Part B
Explain the various phases of a compiler. Show the translations for an assignment statement position=initial+rate *60, clearly indicate the output of each phase.
Answer
Sign in to view the complete answer paper.
Explain the concept of bootstrapping in the context of compilation, discussing its significance and potential challenges.
Answer
Sign in to view the complete answer paper.
Construct recursive descent parsing for the following grammar.
Answer
Sign in to view the complete answer paper.
Construct predictive parsing table for the following grammar: S → (L) | a L → L, S | S. Check whether the string (a, ((a , a), (a , a))) belongs to that language or not.
Answer
Sign in to view the complete answer paper.
Explain shift-reduce parsing with stack implementation.
Answer
Sign in to view the complete answer paper.
Build LR(1) parser and check the validity of the input string “id+id*id” by the LR(1) parser for the given grammar E → E+T/T, T → T*F/F, F → (E)/id
Answer
Sign in to view the complete answer paper.
Discuss the challenges associated with error recovery in parsing.
Answer
Sign in to view the complete answer paper.
Construct an LALR parsing table for the following grammar:
Answer
Sign in to view the complete answer paper.
For the grammar below: E → E + T | T, T → num .num | num Give an SDD to determine the type of each term T and expression E.
Answer
Sign in to view the complete answer paper.
Write the translation scheme for type checking of function declaration.
Answer
Sign in to view the complete answer paper.
Explain tree structured symbol tables.
Answer
Sign in to view the complete answer paper.
Explain in detail, the strategy for reducing fragmentation in heap memory.
Answer
Sign in to view the complete answer paper.
Discuss about principal sources of optimization with example.
Answer
Sign in to view the complete answer paper.
Write a short note on following optimizations concepts: i) Frequency reduction ii) Folding.
Answer
Sign in to view the complete answer paper.
Generate the flow-graphs for the following expressions:
Answer
Sign in to view the complete answer paper.
Explain about common sub expression elimination with an example.
Answer
Sign in to view the complete answer paper.
Discuss the issues in code generation.
Answer
Sign in to view the complete answer paper.
Discuss about register allocation and assignment in target code generation.
Answer
Sign in to view the complete answer paper.
What is peephole optimization? How can it be performed? Give its role in code generation.
Answer
Sign in to view the complete answer paper.
Write an algorithm for generating code from DAG with an example.
Answer
Sign in to view the complete answer paper.