Recent questions and answers in Compiler Design

1 1 vote
2 2 answers
315
315 views
Consider the following $C$ code segment: A[i] = A[i] + 1; // Line 1 j = i + 1; // Line 2 A[j] = A[i] * 2; // Line 3 k = i; // Line 4 A[k] = A[k] + 1; // Line 5In the cont...
1 1 vote
3 3 answers
346
346 views
Consider the following $C$ code segment: x = y + 1; // Line 1 y = x - 2; // Line 2 z = x + y; // Line 3 x = 5; // Line 4 y =z * 2; // Line 5In the context of instruction-...
32 32 votes
5 5 answers
15.3k
15.3k views
Let $G=(V, \Sigma, S, P)$ be a context-free grammar in Chomsky Normal Form with $\Sigma=\{a, b, c\}$ and $V$ containing $10$ variable symbols including the start symbol $...
89 89 votes
9 answers 9 answers
38.8k
38.8k views
The program below uses six temporary variables $a, b, c, d, e, f$.a = 1 b = 10 c = 20 d = a + b e = c + d f = c + e b = c + e e = b + f d = 5 + e return d + fAssuming tha...
39 39 votes
4 answers 4 answers
20.4k
20.4k views
Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar production.$$\begin{array}{l|l} E\rightarrow numbe...
8 8 votes
8 8 answers
2.4k
2.4k views
Consider the control flow graph shown in the figure. Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the ba...
50 50 votes
3 answers 3 answers
13.7k
13.7k views
For a context free grammar, FOLLOW(A) is the set of terminals that can appear immediately to the right of non-terminal $A$ in some "sentential" form. We define two sets L...
47 47 votes
13 answers 13 answers
34.0k
34.0k views
Consider the following $\text{ANSI C}$ program:int main () { Integer x; return 0; }Which one of the following phases in a seven-phase $C$ compiler will throw an error?Lex...
54 54 votes
9 9 answers
28.3k
28.3k views
Consider the following statements regarding the front-end and back-end of a compiler.S1: The front-end includes phases that are independent of the target hardware.S2: The...
42 42 votes
4 answers 4 answers
20.7k
20.7k views
​​​​​​Consider the following $\text{ANSI C}$ code segment:z=x + 3 + y->f1 + y->f2; for (i = 0; i < 200; i = i + 2) { if (z i) { p = p + x + 3; q = q + y->f1; } else { p ...
64 64 votes
6 answers 6 answers
21.8k
21.8k views
In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?In both AST and CFG, let node $N_2$ be the successor of node...
80 80 votes
6 6 answers
28.2k
28.2k views
Which one of the following is TRUE at any valid state in shift-reduce parsing?Viable prefixes appear only at the bottom of the stack and not insideViable prefixes appear ...
12 12 votes
8 8 answers
2.2k
2.2k views
Consider the control flow graph given below.Which one of the following options is the set of live variables at the exit point of each basic block?$\mathrm{B} 1:\{\mathrm{...
3 3 votes
2 2 answers
329
329 views
Consider the following context-free grammar:$E \rightarrow T E^{\prime}$ $E^{\prime} \rightarrow+T E^{\prime} \mid \epsilon$ $T \rightarrow F T^{\prime}$ $T^{\prime} \rig...
2 2 votes
5 5 answers
638
638 views
Consider the following grammar $G$ with start symbol $E$ :$E \rightarrow T R$ $R \rightarrow+T R \mid \epsilon$ $T \rightarrow f$Which of the following statement(s) is/ar...
0 0 votes
1 1 answer
731
731 views
Consider a pipelined processor in which the execution (EX) stage is shared by all instructions. The execution stage takes different different time for different instruct...
0 0 votes
0 0 answers
63
63 views
Which of the following statements about lexical error handling is/are TRUE?A. Lexical analyzers may use finite automata with error transitions to recognize malformed toke...
0 0 votes
0 0 answers
37
37 views
Code improving transformation can be done at which of the following stages?A. Source codeB. Intermediate codeC. Target codeD. All of these
74 74 votes
6 answers 6 answers
30.1k
30.1k views
For computer based on three-address instruction formats, each address field can be used to specify which of the following:(S1) A memory operand(S2) A processor register(S...
4 4 votes
2 2 answers
454
454 views
Consider the following context-free grammar:Productions:$S \rightarrow A$$S \rightarrow B$$A \rightarrow a A b$$A \rightarrow \epsilon$$B \rightarrow c B d$$B \rightarrow...
5 5 votes
2 2 answers
527
527 views
Consider the following grammar. Uppercase letters are non-terminals, lowercase letters are terminals, and $\epsilon$ is the empty string.$S \rightarrow A B \mid g h$ $A \...
2 2 votes
2 2 answers
333
333 views
Consider the following grammar $G$ with non-terminals $\{S, A, B, C\}$ and terminals $\{a, b, c, d, g\}$ :$$\begin{aligned}& S \rightarrow A B \\& A \rightarrow a A \mid ...
3 3 votes
2 2 answers
328
328 views
Consider the following context-free grammar:$$\begin{aligned}& E \rightarrow T R \\& R \rightarrow+T R \mid \epsilon \\& T \rightarrow F Y \\& Y \rightarrow * F Y \mid \e...
10 10 votes
5 5 answers
2.7k
2.7k views
Consider the canonical $L R(0)$ parsing of the grammar below using terminals $\{a, b, c\}$ and non-terminals $\{A, B, C, S\}$ with $S$ as the start symbol.\[\begin{array}...
22 22 votes
11 11 answers
13.6k
13.6k views
Consider two grammars $G_{1}$ and $G_{2}$ with the production rules given below: $G_{1} : S \rightarrow$ $if$ $E$ $then$ $S$ $|$ $if$ $E$ $then$ $S$ $else$ $S$ $|$ $a$ ...
39 39 votes
4 answers 4 answers
9.3k
9.3k views
For the grammar below, a partial $LL(1)$ parsing table is also presented along with the grammar. Entries that need to be filled are indicated as $E1, E2,$ and $E3$. $\var...
124 124 votes
18 answers 18 answers
64.5k
64.5k views
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon and unit-production (i.e., of type $A \rightarrow \epsilo...
26 26 votes
3 answers 3 answers
17.7k
17.7k views
Which one of the following statements is $\text{TRUE}?$The $\textit{LALR}(1)$ parser for a grammar $\textit{G}$ cannot have reduce-reduce conflict if the $\textit{LR}(1)$...
0 0 votes
0 0 answers
74
74 views
Check if it's LR(1) or not? Please draw the DFA too.S ➔ S1 I 0S1 | 1
53 53 votes
7 answers 7 answers
25.5k
25.5k views
Some code optimizations are carried out on the intermediate code becauseThey enhance the portability of the compiler to the target processorProgram analysis is more accur...
0 0 votes
1 1 answer
722
722 views
Consider the following control flow graphThe live-variable analysis determines for each point $p$ in a program which variables are live at that point. A live variable v a...
24 24 votes
6 6 answers
8.4k
8.4k views
Which ONE of the following statements is FALSE regarding the symbol table?Symbol table is responsible for keeping track of the scope of variables.Symbol table can be impl...
9 9 votes
6 6 answers
2.6k
2.6k views
A lexical analyzer uses the following token definitions${letter → [A-Za-z]}$${digit → [0-9]}$${id → letter (letter | digit)^*}$${number → digit}$ ${ }^{+}$${ws → (blank |...
27 27 votes
6 6 answers
11.1k
11.1k views
​​Given a Context-Free Grammar $\text{G}$ as follows:\[\begin{array}{l}S \rightarrow A a|b A c| d c \mid b d a \\A \rightarrow d\end{array}\]Which ONE of the following st...
23 23 votes
8 8 answers
9.5k
9.5k views
​​Given the following syntax directed translation rules:Rule 1: $R \rightarrow A B\{B . i=R . i-1 ; A . i=B . i ; R . i=A . i+1 ;\}$Rule 2: $P \rightarrow C D\{P . i=C . ...
20 20 votes
4 4 answers
8.0k
8.0k views
​​​​Consider the following statements about the use of backpatching in a compiler for intermediate code generation:Backpatching can be used to generate code for Boolean e...
18 18 votes
2 answers 2 answers
7.5k
7.5k views
Refer to the given $3$-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer)1001: i = 1 1002: ...
21 21 votes
4 4 answers
7.0k
7.0k views
Which of the following statement(s) is/are TRUE while computing $\operatorname{First}$ and $\operatorname{Follow}$ during top down parsing by a compiler?For a production ...
23 23 votes
5 5 answers
7.0k
7.0k views
Which ONE of the following techniques used in compiler code optimization uses live variable analysis?Run-time function call managementRegister assignment to variablesStre...
0 0 votes
1 1 answer
201
201 views
To see more, click for all the questions in this category.