Compiler Design
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Consider the statement: int total = 25; Which of the following represents a lexeme?
The regular expression (a|b)* represents:
Which of the following is a problem for a top-down parser?
In bottom-up parsing, the parser constructs:
Consider a symbol table implemented using hashing with table size 10. For key 27, using h(k) = k mod 10, the initial position is:
Under static scoping, the meaning of a variable reference is determined primarily by:
Which optimization eliminates repeated computation of the same expression?
Which pipeline hazard occurs when an instruction depends on the result of a previous instruction?
Dynamic method dispatch is primarily used to implement:
Which statement is true regarding DFA and NFA?
Explain the different phases of compilation with a suitable example. Show the input and output produced at each phase.
Construct a DFA over {0,1} that accepts all strings containing an even number of 0s and an odd number of 1s. Verify the constructed DFA using suitable accepted and rejected input strings.
For a lexical analyzer, design regular expressions to recognize the following token classes:
(i) Identifiers beginning with a letter and containing letters and digits thereafter.
(ii) Unsigned integer constants.
(iii) Relational operators <, <=, >, >=, ==, and !=.Consider the grammar:
S→ABC
A→aA | ε
B→bB | ε
C→cC | d
Compute the FIRST and FOLLOW sets for all non-terminals. Using these, construct the LL(1) parsing table. Use the parsing table to show the parsing steps for the input string “aabd”.
Explain ambiguity in context-free grammars. Illustrate how ambiguity can lead to shift-reduce or reduce-reduce conflicts during LR parsing.
Construct a transition diagram for the Pushdown Automaton for the language:
L = {wcwR | w ∈ {a,b}*}
Explain the structure of an activation record and its role during procedure execution.
Discuss the structure of a symbol table and the information stored for each identifier.
Generate the three-address code for the following expression. Then represent the generated code using quadruple, triple, and indirect-triple representations.
x=a*(b+c)−d/eExplain the construction of basic blocks and control-flow graphs (CFGs) in compiler design using a suitable three-address code example.
Explain cache locality and its importance in loop optimization.
Explain the major stages involved in target code generation in a compiler. Discuss instruction selection, register allocation, and instruction scheduling, and explain how each stage contributes to generating efficient target machine code.
Discuss the major challenges involved in compiling object-oriented features such as classes, inheritance, and polymorphism.
Consider the following grammar:
E → E + T | T
T → T * F | F
F → digit
Define suitable synthesized attributes to evaluate an arithmetic expression. Construct the annotated syntax tree and evaluate the following expression:
3 + 5 * 2
SLR(1) parser
Syntax Directed Definition
peep-hole optimization
Attribute grammar
