Recent questions tagged compiler

4 4 votes
3 3 answers
400
400 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...
1 1 vote
3 3 answers
343
343 views
Consider the following grammar:$E \rightarrow T R$$R \rightarrow+T R$$R \rightarrow \epsilon$$T \rightarrow F Y$$Y \rightarrow * F Y$$Y \rightarrow \epsilon$$F \rightarro...
1 1 vote
3 3 answers
384
384 views
Consider the following grammar: $$S \rightarrow A B A \rightarrow a|\epsilon B \rightarrow b| S$$Which of the following represents the correct FIRST(S)?$\{a, b, \epsilon\...
2 2 votes
3 3 answers
321
321 views
A lexical analyzer recognizes the following set of tokens defined by regular expressions:Token $1\left(T_1\right)$ : $a$ Token $2\left(T_2\right)$ : $a a$ Token 3 ( $T_3$...
2 2 votes
3 3 answers
363
363 views
Consider the following snippet of code in a C-like language:if(x_val >= 20.5) count = count + 1;Assuming the standard lexical rules (where keywords, identifiers, operator...
1 1 vote
2 2 answers
391
391 views
Consider the following C program fragment processed by a compiler that follows the standard phases of compilation. Focus only on lexical analysis (token generation).int m...
2 2 votes
2 2 answers
332
332 views
Consider the following expression:int x = 5, y = 2; int z = x+++y; /* Line 2 */How does the Lexical Analyzer generate tokens for the expression $\verb|x+++y|$ in Line $2$...
3 3 votes
3 3 answers
300
300 views
Which of the following is typically NOT a task performed by the compiler during the token generation phase?IDENTIFYING KEYWORDS AND IDENTIFIERS CHECKING IF AN EXPRESSION ...
3 3 votes
3 3 answers
266
266 views
Consider the following snippet of C codeint main() { /* Line 1 */ int a = 5, b = 10; /* Line 2 */ if (a < b) then { /* Line 3 */ a = a + 1; /* Line 4 */ ...
4 4 votes
3 3 answers
286
286 views
Consider the following snippet of C codeint main() { /* Line 1 */ int x = 10, y = 5; /* Line 2 */ int result; /* Line 3 */ reslt = x + y; /* Line 4 */ }Identi...
1 1 vote
4 4 answers
491
491 views
Consider the following grammar $G$ with the set of non-terminals $\{S, A, B\}$ and terminals $\{a, b, c, d\}$ :$$S \rightarrow A B c, A \rightarrow a|\epsilon, B \rightar...
2 2 votes
4 4 answers
600
600 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...
3 3 votes
3 3 answers
518
518 views
Which of the following statement(s) is/are FALSE while computing $\textbf{FIRST}$ and $\textbf{FOLLOW}$ sets for a Context-Free Grammar?If $X \rightarrow \alpha$ is a pro...
1 1 vote
2 2 answers
382
382 views
Which one of the following is FALSE?A flow graph is a directed graph where nodes represent basic blocks and edges represent the flow of control. Copy Propagation is an op...
1 1 vote
2 2 answers
340
340 views
Which one of the following is FALSE?Reaching Definitions analysis is a forward data flow analysis problem. Live Variable analysis is used to determine which variables hol...
1 1 vote
2 2 answers
297
297 views
A programmer writes the following invalid C statement: $\verb|int total_val#ue =10;|$ .Assuming the compiler adheres to a standard compilation model, which component is p...
0 0 votes
4 4 answers
296
296 views
Given the Prefix (Polish Notation) expression:$$+* / \mathbf{A} \mathbf{B} \mathbf{C}-\mathbf{D} \mathbf{E}$$And the following operand values: $A=12, B=4, C=2, D=10$, $E=...
4 4 votes
3 3 answers
363
363 views
Consider the tree shown below.Each leaf represents a numerical value, which can be chosen to be either $\mathbf{0}$ or $\mathbf{2}$.Over all possible choices of the value...
1 1 vote
2 2 answers
292
292 views
Consider the following ANSI C code segment: w = 5 - y->f_one - x - 2; for (j = 1; j < 150; j = j + 3) { if (j < w) { a = a + y->f_two; b = b + 5 -...
3 3 votes
3 3 answers
305
305 views
Consider line number $\textbf{4}$ of the following C-program. int main() { /* Line 1 */ int value, result; /* Line 2 */ value = 100; /* Line 3 */ result = val...
2 2 votes
3 3 answers
344
344 views
A lexical analyzer uses the following regular expressions (REs) to recognize four tokens, $T_1, T_2$, $T_3$, and $T_4$, over the alphabet $\Sigma=\{a, b, c\}$.$T_1:(a \mi...
2 2 votes
3 3 answers
315
315 views
Consider the following C code snippet:float val = 2.0; /* Check Condition */ if (val <= MAX) { val /= 2; }What is the total number of tokens identified by the lexical...
1 1 vote
4 4 answers
508
508 views
Consider the following canonical set of LR(0) items:$$I_5=\left\{\begin{array}{l}R \rightarrow x \cdot P y \\R \rightarrow x P \\P \rightarrow y\end{array}\right.$$Which ...
1 1 vote
2 2 answers
275
275 views
Consider the following basic block:$$\begin{aligned}& \mathrm{t} 1=\mathrm{a}+\mathrm{b} \\& \mathrm{t} 2=\mathrm{c}+\mathrm{d} \\& \mathrm{t} 3=\mathrm{t} 1 * 2 \\& \mat...
1 1 vote
2 2 answers
466
466 views
Consider the following basic block:$$\begin{aligned}& w=x+y \\& z=w * 2 \\& x=y+z \\& w=x-y\end{aligned}$$The minimum number of NODES and the total number of OPERATOR LAB...
2 2 votes
3 3 answers
385
385 views
Consider the intermediate code given below: (1) x = 1 (2) L0: y = 2 (3) if x < 5 goto L1 (4) x = x + 1 (5) goto L0 (6) L1: z = 0 (7) if y 0 goto L2 (8) y = y - 1 (9) L2:...
3 3 votes
5 5 answers
382
382 views
The number of tokens in the following C statement is:for (i = 0; i != 10; i++) { sum += i; } $18$ $21$ $16$ $19$
2 2 votes
3 3 answers
361
361 views
Consider the intermediate code given below: (1) i = 0 (2) t1 = 2 * i (3) j = 10 (4) L1: t2 = t1 + j (5) a[t2] = 5 (6) j = j - 1 (7) if j 0 goto L1 (8) t3 = 1 (9) L2: i =...
3 3 votes
3 3 answers
264
264 views
The number of tokens in the following C statement is$\verb|if(a b && c <= 10) { result = a + b; }|$
0 0 votes
1 1 answer
359
359 views
The program below uses six temporary variables $a, b, c, d, e, f$.a = 5 b = 1 c = a - b d = a + c e = b + d f = c + e a = 2 * d e = 10 return a + e + fAssuming that all o...