B.TECH - Semester 6 complier design Question Paper 2021 (dec)
Practice authentic previous year university questions for better exam preparation.
Sample Questions
- What are the phases of a compiler?
- Why is buffering used in lexical analysis? Name some of the commonly used buffering techniques.
- Define an ambiguous grammar. Give example.
- Eliminate left recursion from the grammar $$ \begin{aligned} & S \rightarrow A a \mid b \\ & A \rightarrow A c|S a| \in \end{aligned} $$
- What is meant by cross compilation?
- Define backpatching.
- Name the techniques in loop optimization.
- List the fields of an activation record with example.
- How do we perform register assignment for outer loops?
- List the properties of flow graphs. ( $10 \times 4=40$ Marks) P.T.O. Answer any one full question from each module. Each carries 20 marks.
- Compare NFA and DFA. Give the procedure to convert a given NFA to a DFA. Draw the DFA for the augmented regular expression $\left((\in / a) b^{*}\right)^{*}$.
- (a) Describe the issues in lexical analysis. Write in detail about recognition of tokens.
- (b) Discuss input buffering in detail.
- Describe in detail recursive descending parsing. Construct a recursive descendent parser for the following grammar : ``` expr → expr add - op expr term → term mult - op factor | factor factor $\rightarrow($ expr $) \mid$ digit - seq add - op ...
- Design a LALR parser for the following grammar and parse the input id $=i d$. $$ \begin{gathered} S \rightarrow L=R \mid R \\ L \rightarrow * R \mid i d \\ R \rightarrow L \end{gathered} $$
- (a) Define a syntax-directed translation that type checks expressions in the CFG. exp → exp + term $\exp \rightarrow \exp \& \&$ term $\exp \rightarrow \exp ==$ term The type rules are:
- (i) Both operands of the + operator must be of type INT. (ii) Both operands of the \&\& operator must be of type BOOL. (iii) Both operands of the $==$ operator have the same (non-ERROR) type.
- (b) Describe how assignment and case statements can be converted into intermediate form. OR
- (a) Generate code for the following assignment using the code generator algorithm. $d:=(a-b)+(a-c)+(a-c)$
- (b) Describe in detail optimization of basic blocks with example.