Question 1 |

Consider the following augmented grammar with \{ \#, @, <, >, a, b, c \} as the set of terminals.

\begin{array}{l} S' \rightarrow S \\ S \rightarrow S \# cS \\ S \rightarrow SS \\ S \rightarrow S @ \\ S \rightarrow < S > \\ S \rightarrow a \\ S \rightarrow b \\ S \rightarrow c \end{array}

Let I_0 = \text{CLOSURE}(\{S' \rightarrow \bullet S\}). The number of items in the set \text{GOTO(GOTO}(I_0 \lt ), \lt ) is ___________

\begin{array}{l} S' \rightarrow S \\ S \rightarrow S \# cS \\ S \rightarrow SS \\ S \rightarrow S @ \\ S \rightarrow < S > \\ S \rightarrow a \\ S \rightarrow b \\ S \rightarrow c \end{array}

Let I_0 = \text{CLOSURE}(\{S' \rightarrow \bullet S\}). The number of items in the set \text{GOTO(GOTO}(I_0 \lt ), \lt ) is ___________

6 | |

7 | |

8 | |

9 |

Question 1 Explanation:

Question 2 |

For a statement S in a program, in the context of liveness analysis, the following sets are defined:

USE(S) : the set of variables used in S

IN(S) : the set of variables that are live at the entry of S

OUT(S) : the set of variables that are live at the exit of S

Consider a basic block that consists of two statements, S1 followed by S2. Which one of the following statements is correct?

USE(S) : the set of variables used in S

IN(S) : the set of variables that are live at the entry of S

OUT(S) : the set of variables that are live at the exit of S

Consider a basic block that consists of two statements, S1 followed by S2. Which one of the following statements is correct?

OUT(S1) = IN (S2) | |

OUT (S1) = IN (S1) \cup USE (S1) | |

OUT (S1) =IN (S2) \cup OUT (S2) | |

OUT (S1) = USE (S1)\cup IN (S2) |

Question 2 Explanation:

Question 3 |

In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?

Three address code | |

Abstract Syntax Tree (AST) | |

Control Flow Graph (CFG) | |

Symbol table |

Question 3 Explanation:

Question 4 |

Consider the following 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?Lexical analyzer | |

Syntax analyzer | |

Semantic analyzer | |

Machine dependent optimizer |

Question 4 Explanation:

Question 5 |

Consider the following C code segment:

a = b + c;

e = a + 1;

d = b + c;

f = d + 1;

g = e + f;

In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is _____________

a = b + c;

e = a + 1;

d = b + c;

f = d + 1;

g = e + f;

In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is _____________

11 | |

6 | |

5 | |

10 |

Question 5 Explanation:

Question 6 |

Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code

\begin{array}{lll} P & \rightarrow & D^* E^* \\ D & \rightarrow & \textsf{int ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ int\}} \\ D & \rightarrow & \textsf{bool ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ bool\}} \\ E& \rightarrow & E_1 +E_2 \{ \text{check that } E_1. \text{type}=E_2. \text{type} = \textsf{int}; \text{set } E.\text{type }:= \textsf{int} \} \\ E & \rightarrow & !E_1 \{ \text{check that } E_1. \text{type} = \textsf{bool}; \text{ set } E.\text{type} := \textsf{bool} \} \\ E & \rightarrow & \textsf{ID} \{ \text{set } E. \text{type } := \textsf{int} \} \end{array}

With respect to the above grammar, which one of the following choices is correct?

\begin{array}{lll} P & \rightarrow & D^* E^* \\ D & \rightarrow & \textsf{int ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ int\}} \\ D & \rightarrow & \textsf{bool ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ bool\}} \\ E& \rightarrow & E_1 +E_2 \{ \text{check that } E_1. \text{type}=E_2. \text{type} = \textsf{int}; \text{set } E.\text{type }:= \textsf{int} \} \\ E & \rightarrow & !E_1 \{ \text{check that } E_1. \text{type} = \textsf{bool}; \text{ set } E.\text{type} := \textsf{bool} \} \\ E & \rightarrow & \textsf{ID} \{ \text{set } E. \text{type } := \textsf{int} \} \end{array}

With respect to the above grammar, which one of the following choices is correct?

The actions can be used to correctly type-check any syntactically correct program | |

The actions can be used to type-check syntactically correct integer variable declarations and integer expressions | |

The actions can be used to type-check syntactically correct boolean variable declarations and boolean expressions. | |

The actions will lead to an infinite loop |

Question 6 Explanation:

Question 7 |

Consider the following statements.

S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).

S2: For any context-free grammar, there is a parser that takes at most O(n^3) time to parse a string of length n.

Which one of the following options is correct?

S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).

S2: For any context-free grammar, there is a parser that takes at most O(n^3) time to parse a string of length n.

Which one of the following options is correct?

S1 is true and S2 is false | |

S1 is false and S2 is true | |

S1 is true and S2 is true | |

S1 is false and S2 is false |

Question 7 Explanation:

Question 8 |

Consider the following statements.

S1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.

S2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.

Which one of the following options is correct?

S1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.

S2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.

Which one of the following options is correct?

S1 is true and S2 is false | |

S1 is false and S2 is true | |

S1 is true and S2 is true | |

S1 is false and S2 is false |

Question 8 Explanation:

Question 9 |

A grammar is defined as

A \rightarrow B C

B \rightarrow x \mid B x

C \rightarrow B \mid D

D \rightarrow y \mid Ey

E \rightarrow z

The non terminal alphabet of the grammar is

A \rightarrow B C

B \rightarrow x \mid B x

C \rightarrow B \mid D

D \rightarrow y \mid Ey

E \rightarrow z

The non terminal alphabet of the grammar is

\{A, B, C, D, E\} | |

\{B, C, D, E\} | |

\{A, B, C, D, E,x,y,z\} | |

\{x,y,z\} |

Question 9 Explanation:

Question 10 |

A given grammar is called ambiguous if

two or more productions have the same non-terminal on the left hand side | |

a derivation tree has more than one associated sentence | |

there is a sentence with more than one derivation tree corresponding to it | |

brackets are not present in the grammar |

Question 10 Explanation:

There are 10 questions to complete.