JNTU
JNTU B.Tech III COMPILER DESIGN Previous Question Paper (August/September - 2024 - R16)
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
What is the role of the lexical analyzer in a compiler?
Answer
The lexical analyzer, or scanner, reads the input source code character by character and groups them into meaningful sequences called lexemes. It then produces a stream of tokens as output, which are passed to the syntax analyzer for further processing, while also removing whitespace and comments.
State and briefly explain the need for a language translator.
Answer
A language translator is necessary because computer hardware can only execute machine code (binary). Since programmers write code in high-level languages that are human-readable, a translator is required to convert this source code into an equivalent machine-executable form so the computer can perform the intended operations.
What are the benefits of LR parsers over LL parsers?
Answer
Sign in to view the complete answer paper.
Compare and contrast Top down parsing and bottom up parsing techniques.
Answer
Sign in to view the complete answer paper.
Define context-free grammars.
Answer
Sign in to view the complete answer paper.
Define synthesized attributes and inherited attributes.
Answer
Sign in to view the complete answer paper.
What are the key components of a run-time environment?
Answer
Sign in to view the complete answer paper.
How to identify a leader in a basic block provide example?
Answer
Sign in to view the complete answer paper.
Define a flow graph.
Answer
Sign in to view the complete answer paper.
Write about IN and OUT statements in data-flow analysis.
Answer
Sign in to view the complete answer paper.
Part B
Create a flowchart illustrating the process of lexical analysis, including input buffering, token recognition, and the role of a lexical analyzer.
Answer
Sign in to view the complete answer paper.
Design a regular expression and corresponding finite automaton to recognize valid identifiers in a programming language, considering alphanumeric characters and underscores, ensuring that the automaton is deterministic.
Answer
Sign in to view the complete answer paper.
Evaluate the significance of LR parsing in compiler construction, especially in handling ambiguous grammars and improving parsing efficiency. Provide examples to support your argument.
Answer
Sign in to view the complete answer paper.
Develop a context-free grammar for a simple arithmetic expression language, including rules for addition, subtraction, multiplication, and division. Illustrate the grammar with production rules and example expressions.
Answer
Sign in to view the complete answer paper.
Design a Syntax-Directed Translation Scheme (SDTS) to convert infix arithmetic expressions into postfix notation. Include semantic actions and attribute values to annotate the syntax tree.
Answer
Sign in to view the complete answer paper.
Develop a set of semantic rules to perform type checking in a programming language compiler. Consider different types (e.g., integer, floating-point, boolean) and type compatibility rules.
Answer
Sign in to view the complete answer paper.
Analyze the advantages and disadvantages of stack allocation versus heap management in run-time environments, considering factors such as memory efficiency, access time, and fragmentation.
Answer
Sign in to view the complete answer paper.
Evaluate the importance of garbage collection in modern programming languages. Discuss different garbage collection algorithms and their suitability for different application scenarios.
Answer
Sign in to view the complete answer paper.
Apply the concept of constant propagation to optimize the following code snippet:
int x = 5;
int y = x + 3;
int z = y * 2;Answer
Sign in to view the complete answer paper.
Analyze the importance of partial-redundancy elimination in compiler optimization. Discuss how it differs from other optimization techniques and its impact on code quality.
Answer
Sign in to view the complete answer paper.