Jawaharlal Nehru Technological University Hyderabad
Jawaharlal Nehru Technological University Hyderabad B.Tech III COMPILER DESIGN Previous Question Paper (August - 2022 - R13)
Answer any five questions
All questions carry equal marks
Main
What is LEX? Explain in brief about the different sections of LEX Program.
Answer
Lex is a tool used for generating lexical analyzers (scanners). It takes a set of regular expressions as input and produces a C program that recognizes the tokens defined by those expressions. A Lex program is structured into three distinct sections separated by the delimiter %%:
- Definitions Section: This section includes declarations of variables, manifest constants, and regular expression definitions (abbreviations) that are used in the rules section.
- Rules Section: This is the core of the program, containing a list of patterns (regular expressions) and the corresponding actions (C code) to be executed when a pattern is matched.
- User Subroutines Section: This section contains auxiliary C functions or code that are copied directly into the generated lexer, allowing for custom logic or helper functions.
Differentiate between a compiler and an interpreter.
Answer
| Feature | Compiler | Interpreter |
|---|---|---|
| Execution | Translates entire source code into machine code before execution. | Translates and executes source code line-by-line. |
| Performance | Faster execution speed as the code is pre-compiled. | Slower execution speed due to interpretation overhead. |
| Memory | Requires more memory to store the generated object code. | Requires less memory as it does not store intermediate object code. |
| Error Handling | Reports all syntax errors after scanning the entire code. | Stops execution at the first error encountered. |
Define a Compiler. Explain in brief about the types of lexical errors with example.
Answer
Sign in to view the complete answer paper.
Explain in brief about compiler construction tools.
Answer
Sign in to view the complete answer paper.
Construct CLR Parsing table for the grammar:
L → * R | id
R → L
Answer
Sign in to view the complete answer paper.
Demonstrate various conflicts raised in shift-reduce parsers with an example.
Answer
Sign in to view the complete answer paper.
Construct an annotated parse tree for 3*4+5.
Answer
Sign in to view the complete answer paper.
Translate the expression –(a+b)*(c+d)+(a+b+c) in to quadruple, triple and indirect triple.
Answer
Sign in to view the complete answer paper.
What are attributed grammars? Give an example.
Answer
Sign in to view the complete answer paper.
Define Symbol table. Explain about the data structures used for Symbol table.
Answer
Sign in to view the complete answer paper.
Define code generator. Discuss about Instruction Selection and Register allocation.
Answer
Sign in to view the complete answer paper.
Explain in brief about different Principal sources of optimization techniques with suitable examples.
Answer
Sign in to view the complete answer paper.
What is a Flow Graph? Explain how a given program can be converted in to a Flow graph.
Answer
Sign in to view the complete answer paper.