Questions
Identify the odd one out.
- Global common subexpression
- Copy propagation
- Register allocation
- Code motion
Number of states for a grammar in SLR parser and LALR is
- double of the other
- somewhat dependent on each other
- independent
- dependent on grammar
Match the following.
(Choose the most appropriate option)
(A) S – Attributed Definition (i) Synthesized attribute
(B) L _ Attributed Definition (ii) Inherited attributed
- A – i, B – ii
- A – ii, B – i
- A – i, B – i, B – ii
- A – i, B – ii, A – ii
Consider the following grammar:A $\rightarrow$ BCC $\rightarrow$ +$A| \epsilon$B $\rightarrow$ id
In the predictive parser table, m, of grammar the entire M [A, id] and M [C, $] respectively, is
- {A $\rightarrow$ BC} and {C $\rightarrow$$\epsilon$}
- {A $\rightarrow$ BC} and { }
- {A $\rightarrow$ BC} and {C $\rightarrow$+A}
- {B $\rightarrow$ id} and {C $\rightarrow$ $\epsilon$}

Expression corresponding to this DAG is
- a + a * (b - c) + (b - c) *d
- a + a × (b - c) + (b - c) * (e/f)
- a*a + (b - c) + (b - c) * (e/f)
- a + a* (b - c) + (b + c) * (e/f)
The grammar
E $\rightarrow$E + E |E*E|(E)| id is
- left recursive
- ambiguous
- both (1) and (2)
- none of these
Which of the following statements is false about viable prefixes?
- SLR passing is based on the fact that LR(0) automata recognize viable prefixes.
- It is always possible to add terminal symbols to the end of a viable prefix to obtain a right- sentential form.
- Both (1) and (2)
- None of the above
Which of the following is generally not present in activation record?
- Access link
- List of all processes in system
- Saved machine status
- Control link
Match the following.
| i. Token | a. Character i, f, letter followed by latter and digits etc |
| ii. Pattern | b. if, id, comparison |
| iii. Lexeme | c. if, pi, < = |
- i – b, ii – a, iii – c
- i – b, ii – c, iii – a
- i – c, ii – a, iii – b
- i – c, ii – b, iii - a
A$\rightarrow$BCC $\rightarrow$ + B {print ('+'); }C|$\epsilon$ B$\rightarrow$ D* B {print ('')i}|D D$\rightarrow$ (A)|id {print (id.value); }
For an input '5 + 67' this translation scheme prints
- 5 + 6 *7
- 5 + *6 7
- 5 6 + 7*
- 5 6 7 *+
Consider the following statements.
(i) Every SLR (1) grammar is unambiguous
(ii) There are many unambiguous grammars that are not SLR (1)
- i - True, ii - True
- i - True, ii - False
- i - False, ii - True
- i - False, ii - False
Eliminate left recursion
S $\rightarrow$ Aa|b
A $\rightarrow$Ac|Sd|f
- $S \rightarrow Aa | b \\\\ A \rightarrow bdA'| fA' \\\\A | \rightarrow cA'| adA'| \epsilon$
- $S \rightarrow Aa | b \\\\ A \rightarrow cdA'| dA' \\\\ A' \rightarrow bA'| adA' |\epsilon $
- $S\rightarrow Aa|b \\\\ A\rightarrow bdA'|fA'$
- $S \rightarrow Aa| b$ $A \rightarrow bdA'|fA'$ $A'\rightarrow cA'|adA'$
Computer value of 5 # 9 and 3 is
- 6
- 7
- 8
- 9
Find the false statement.
- No left recursive or ambiguous grammar can be LL(1)
- The class of grammars that can be parsed using LR methods is a proper subset of the class of grammars that can be the passed by LL method
- LR parsing is non - back tracking method
- LR methods can describe more languages than LL - grammars
Follow (E) is
- { )}
- {$}
- both (1) and (2)
- none of the above
The grammar
- is ambiguous
- is unambiguous
- cannot be decided
- generates two parse trees for one input string
The grammar
$S \rightarrow SA|A$
$A \rightarrow a$
- SLR (1) but not LL (1)
- SLR (1) and LL (1)
- Not SLR (1), not LL (1)
- Not SLR (1), but LL (1)
The value printed by the following is
$ (( A + B ) * C + ( D * E) + ( F *G)) $
- $ ++\*+ABC\*DE\*FG $
- $ +\*++ABC\*DE\*FG $
- $AB+C\*DE\*+FG\*+$
- $ABC+\*DE\*+FD\*+$
While (i < = limit - 2) statement becomes
$
\begin{cases}
t=\text{limit - 2} \\
\text{While } (i \Leftarrow t)
\end{cases}
$
This optimization is caused by
- copy propagation
- code motion
- dead code elimination
- insufficient information
Consider the grammar.
T$\rightarrow$T*F|F
F $\rightarrow$ id
For a sentence id1 *id2, the handlers in the right sequential form of the reduction are
- id1, F, id2, T *F
- id1, id2, T *F
- id1, F, T *F
- id1, F, id2
Consider the grammar with transition rule and E is the start symbol.
E $\rightarrow$ E1 $\ne$ T {E1.value = E1.value + T.value}
|T {E.value = T.value}
T $\rightarrow$ T1 & F {T.value = T1.value / F.value}
|F {T.value = F.value}
F $\rightarrow$ num {F.value = num.value}
Concept E. The value for the root of the parse tree for expression 6 # 4 and 2 # 16 and 4 is
- 16
- 12
- 8
- 6
Consider the grammar.
First ( E' ) and first ( E ) are respectively
- {+, $\epsilon$}, { , id }
- {+ , $\epsilon$}, { *, $\epsilon$}
- {*, $\epsilon$}, {C, id}
- none of these
Choose the most appropriate option.
(i) Indirect triples is advantageous than triples.
(ii) With indirect triple, an optimizing compiler can move an instruction by reordering the instruction list, without affecting the triples themselves.
- i is true but ii is false.
- i and ii are true and ii is the cause of i.
- i and ii are true but ii is not the cause of i.
- Both of them are false.
Left factor the grammar.
$A \rightarrow ad|a|ab|abc|b$
- $A \rightarrow aA'|b\\\\A' \rightarrow d| \epsilon |b|bc$
- $A \rightarrow aA'| b\\\\A'\rightarrow d |\epsilon| bA\\\\A'\rightarrow \epsilon| c$
- $A \rightarrow aA'| b\\\\A'\rightarrow d | bA'\\\\A\rightarrow c $
- $A \rightarrow aA' | b\\\\A' \rightarrow d | b | bc$
Following are the production and the action.
- $L\rightarrow E \eta$
- $E \rightarrow \{ print('+'); \}E_1 + T$
- $E \rightarrow R$
- $E \rightarrow \{ print('+'); \}T_1 + F$
- $T\rightarrow F$
- $F\rightarrow (E)$
- $F\rightarrow \text{digit \{print (digit lexval)\} }$
This is syntax directed translation for
- prefix to infix
- infix to prefix
- postfix to infix
- infix to postfix

<span class="Apple-style-span" style="font-size:" small;="">
There is no conflict in the LR (0) items. So, it is in SLR (i). So option (a) is correct.
