# Recent questions tagged compiler-design

0 votes
1 answer
1
The ‘K’ in LR (K) cannot be : $0$ $1$ $2$ None of these
0 votes
4 answers
2
Consider the following statements related to compiler construction: Lexical Analysis is specified by context-free grammars and implemented by pushdown automata. Syntax Analysis is specified by regular expressions and implemented by finite-state machine. Which of the above statement(s) is/are correct? Only I Only II Both I and II Neither I nor II
0 votes
3 answers
3
Which of the following statement(s) regarding a linker software is/are true ? A function of a linker is to combine several object modules into a single load module. A function of a linker is to replace absolute references in an object module by symbolic references to locations in other modules. Only I Only II Both I and II Neither I nor II
10 votes
4 answers
4
Consider the following statements. Symbol table is accessed only during lexical analysis and syntax analysis. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment. Errors violating the condition any variable must be ... of the above statements is/are TRUE? I only I and III only Ⅱ only None of Ⅰ, Ⅱ and Ⅲ
7 votes
3 answers
5
Consider the following grammar. $S \rightarrow aSB \mid d$ $B \rightarrow b$ The number of reduction steps taken by a bottom-up parser while accepting the string $aaadbbb$ is___________.
4 votes
3 answers
6
Consider the productions $A \rightarrow PQ$ and $A \rightarrow XY$. Each of the five non-terminals $A, P, Q, X$, and $Y$ has two attributes: $s$ is a synthesized attribute, and $i$ is an inherited attribute. Consider the following rules. Rule $1$ ... $1$ is $L$-attributed. Only Rule $2$ is $L$-attributed. Neither Rule $1$ nor Rule $2$ is $L$-attributed.
2 votes
3 answers
7
Which one indicates a technique of building cross compilers? Beta cross Canadian cross Mexican cross X-cross
1 vote
3 answers
8
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
2 votes
1 answer
9
Which of the following is a type of a out-of-order execution, with the reordering done by a compiler loop unrolling dead code elimination strength reduction software pipelining
2 votes
4 answers
10
In a two-pass assembler, resolution of subroutine calls and inclusion of labels in the symbol table is done during second pass first pass and second pass respectively second pass and first pass respectively first pass
1 vote
1 answer
11
The number of tokens in the following C code segment is switch(inputvalue) { case 1 : b =c*d; break; default : b =b++; break; } $27$ $29$ $26$ $24$
2 votes
2 answers
12
Given the grammar $s \rightarrow T ^{\ast} S\ \mid T$ $T \rightarrow U+T\ \mid U$ $U \rightarrow a \mid b$ Which of the following statements is wrong? Grammar is not ambiguous Priority of $+$ over $^{\ast}$ is ensured Right to left evaluation of $^{\ast}$ and $+$ happens None of these
1 vote
2 answers
13
A grammar is defined as $A \rightarrow BC$ $B \rightarrow x \mid Bx$ $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\}$
1 vote
0 answers
14
As in Ada, suppose that each expression must have a unique type, but that from a subexpression, by itself, all we can deduce is a set of possible types. That is, the application of function $E_{1}$ to argument $E_{2}$ ... and, once the unique type of the overall expression is determined, proceeds top-down to determine attribute $unique$ for the type of each subexpression.
0 votes
0 answers
15
Assuming that function $widen$ in Fig. $6.26$ can handle any of the types in the hierarchy of Fig. $6.25(a)$, translate the expressions below. Assume that c and d are characters, $s$ and $t$ are short integers, $i$ and $j$ are integers, and $x$ is a float. $x=s+c$ $i=s+c$ $x=(s+c)\ast(t+d)$
0 votes
0 answers
16
$A$ real array $A[i, j, k]$ has index $i$ ranging from $1$ to $4$, index $j$ ranging from $0$ to $4$, and index $k$ ranging from $5$ to $10$. Reals take $8$ bytes each. Suppose array $A$ is stored starting at byte $0$. Find the location of: $A[3,4,5]$ $A[1,2,7]$ $A[4,3,9]$ if $A$ is stored in column-major order.
0 votes
1 answer
17
$A$ real array $A[i, j, k]$ has index $i$ ranging from $1$ to $4$, index $j$ ranging from $0$ to $4$, and index $k$ ranging from $5$ to $10$. Reals take $8$ bytes each. Suppose array $A$ is stored starting at byte $0$. Find the location of: $A[3,4,5]$ $A[1,2,7]$ $A[4,3,9]$
0 votes
0 answers
18
An integer array $A[i, j]$ has index $i$ ranging from $1$ to $10$ and index $j$ ranging from $1$ to $20$. Integers take $4$ bytes each. Suppose array $A$ is stored starting at byte $0$. Find the location of: $A[4,5]$ $A[10,8]$ $A[3,17]$ if A is stored in column-major order.
0 votes
0 answers
19
An integer array $A[i, j]$ has index $i$ ranging from $1$ to $10$ and index $j$ ranging from $1$ to $20$. Integers take $4$ bytes each. Suppose array $A$ is stored starting at byte $0$. Find the location of: $A[4,5]$ $A[10,8]$ $A[3,17]$
0 votes
0 answers
20
Generalize formula $(6.7)$ to multidimensional arrays, and indicate what values can be stored in the symbol table and used to compute offsets. Consider the following cases: An array $A$ of two dimensions, in row-major form. The first dimension has indexes running from $l_{1}$ ... has indexes running from $l_{j}$ to $h_{j}$.The same as $(c)$ but with the array stored in column-major form.
0 votes
0 answers
21
Revise the translation of Fig. $6.22$ for array references of the Fortran style, that is, $id[E_{1}, E_{2},\cdot\cdot\cdot,E_{n}]$ for an $n-$dimensional array.
0 votes
0 answers
22
Use the translation of Fig. $6.22$ to translate the following assignments: $x=a[i]+b[j]$ $x=a[i][j]+b[i][j]$ $x=a[b[i][j]][c[[k]]$
0 votes
0 answers
23
Add to the translation of Fig. $6.19$ rules for the following productions: $E\rightarrow E_{1}\ast E_{2}$ $E\rightarrow + E_{1}\:$(unary plus)
0 votes
0 answers
24
Add to the translation of Fig. $6.19$ rules for the following productions: $E\rightarrow E_{1}\ast E_{2}$ $E\rightarrow + E_{1}\:$(unary plus)
0 votes
0 answers
25
Extend the handling of field names in Fig. $6.18$ to classes and single-inheritance class hierarchies. Give an implementation of class $Enu$ that allows linked symbol tables, so that a subclass can either redefine a field name or refer directly to a ... in a class, including inherited fields. Inherited fields must maintain the relative addresses they were assigned in the layout for the superclass.
0 votes
0 answers
26
Determine the types and relative addresses for the identifiers in the following sequence of declarations: float x; record { float x; float y; } p; record { int tag; float x; float y; } q;
0 votes
1 answer
27
Show how to transform a three-address code sequence into one in which each defined variable gets a unique variable name.
1 vote
1 answer
28
Translate the following arithmetic expression into: $a=b[i]+c[j]$ $a[i]=b\ast c-b\ast d$ $x=f(y+1)+2$ $x=\ast p + \&y$ A Syntax tree Quadruples Triples Indirect triples
0 votes
1 answer
29
Translate the arithmetic expression $a + -(b + c)$ into: A syntax tree. Quadruples. Triples. Indirect triples
0 votes
0 answers
30
Construct the DAG and identify the value numbers for the subexpressions of the following expressions, assuming $+$ associates from the left. $a+b+(a+b)$ $a+b+a+b$ $a+a+((a+a+a+(a+a+a+a))$