## Compiler-Design

 Question 1
Consider the grammar given below:
S → Aa
A → BD
B → b | ε
D → d | ε

Let a, b, d, and $be indexed as follows: Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d,$}, then the answer should be 3210)

 A 30 B 31 C 10 D 21
Compiler-Design       GATE 2019
Question 1 Explanation:
Follow(B) = First(D) Union Follow(A)
{Follow(B) = Follow(A) when D is epsilon}
Follow(B) = {d} Union {a} = {a,d}
 Question 2
Which one of the following kinds of derivation is used by LR parsers?
 A Leftmost in reverse B Rightmost in reverse C Leftmost D Rightmost
Compiler-Design       GATE 2019
Question 2 Explanation:
LR parsers have Rightmost derivation in reverse.
 Question 3
Consider the augmented grammar given below:
    S' → S
S → 〈L〉 | id
L → L,S | S


Let I0 = CLOSURE ({[S' → ·S]}). The number of items in the set GOTO (I0 , 〈 ) is: _____.

 A 4 B 5 C 6 D 7
Compiler-Design       GATE 2019
Question 3 Explanation:
I0 = CLOSURE ({[S' → ·S]}) Hence, the set GOTO (I0 , 〈 ) has 5 items.
 Question 4

Consider the following grammar and the semantic actions to support the inheriteatd type declaration attributes. Let X1, X2, X3, X4, X5 and X6 be the placeholders for the non-terminals D, T, L or L1 in the following table: Which one of the following are the appropriate choices for X1, X2, X3 and X4?

 A X1 = L, X2 = L, X3 = L1, X4 = T B X1 = L, X2 = T, X3 = L1, X4 = L C X1 = T, X2 = L, X3 = L1, X4 = T D X1 = T, X2 = L, X3 = T, X4 = L1
Compiler-Design       GATE 2019
Question 4 Explanation:
Since The production
L → L1, id {X3.type = X4.type } , this production has L and L1, hence X3 and X4 cannot be T.
So option 1, 3 and 4 cannot be correct.
 Question 5
Consider the following grammar.
S->aSB| d
B->b
The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is _______.
 A 7
Compiler-Design       Parsers       GATE 2020
Question 5 Explanation: 7 reductions total.
 Question 6
Consider the following statements.
I. Symbol table is accessed only during lexical analysis and syntax analysis.
II. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
III. Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis.
Which of the above statements is/are TRUE?
 A II only B I only C I and III only D None of I, II and III
Compiler-Design       Run-Time-Environment       GATE 2020
Question 6 Explanation:
I is wrong as Symbol table is also accessed during semantic analysis phase.
II is wrong as compilers which supports recursion require stack memory in run time environment.
III is wrong “any variable must be declared before its use” is a   semantic error and nit syntax error.
 Question 7
Consider the productions A⟶PQ and A⟶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: P.i = A.i + 2, Q.i = P.i + A.i, and A.s = P.s + Q.s
Rule 2: X.i = A.i + Y.s and Y.i = X.s + A.i
Which one of the following is TRUE?
 A Only Rule 2 is L-attributed. B Neither Rule 1 nor Rule 2 is L-attributed. C Both Rule 1 and Rule 2 are L-attributed. D Only Rule 1 is L-attributed.
Compiler-Design       Synthesized-Attribute       GATE 2020
Question 7 Explanation:
In rule 2 for production A-> XY  the attribute “i” is calculated from the right sibling Y in
X.i= A.i + Y.s  which is violating the L attribute definition, as in L attribute calculating attribute vale from RHS sibling is not allowed.
 Question 8
Which one of the following statements is FALSE?
 A Context-free grammar can be used to specify both lexical and syntax rules. B Type checking is done before parsing. C High-level language programs can be translated to different Intermediate Representations. D Arguments to a function can be passed using the program stack.
Compiler-Design       Compilers       Gate 2018
Question 8 Explanation:
Type checking is done in semantic analysis phase after syntax analysis phase (i.e., after parsing).
 Question 9

Consider the following parse tree for the expression a#b$c$d#e#f, involving two binary operators $and #. Which one of the following is correct for the given parse tree?  A$ has higher precedence and is left associative; # is right associative B # has higher precedence and is left associative; $is right associative C$ has higher precedence and is left associative; # is left associative D # has higher precedence and is right associative; $is left associative Compiler-Design Associativity-and-Precedence Gate 2018 Question 9 Explanation: Since$ will be evaluated before # so $has higher precedence and the left$ i.e., in b$c$d the left “$” (i.e., b$c) will be evaluated first so it is left associative, whereas # is right associative (as in d#e#f) , the right one (i.e., e#f) will be evaluated first.
 Question 10

A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}.

T1: a?(b∣c)*a
T2: b?(a∣c)*b
T3: c?(b∣a)*c

Note that ‘x?’ means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix.

If the string bbaacabc is processes by the analyzer, which one of the following is the sequence of tokens it outputs?

 A T1T2T3 B T1T1T3 C T2T1T3 D T3T3
Compiler-Design       Compilers       Gate 2018
Question 10 Explanation:
a? means either 0 or 1 occurrence of “a”, so we can write T1, T2 and T3 as:
T1 : (b+c)*a + a(b+c)*a
T2 : (a+c)*b + b(a+c)*b
T3 : (b+a)*c + c(b+a)*c
Now the string is: bbaacabc
Token that matches the longest possible prefix
We can observe that the longest possible prefix in string is : bbaac which can be generated by T3.
After prefix we left with “abc” which is again generated by T3 (as longest possible prefix).
 Question 11

Consider the following intermediate program in three address code

           p = a - b
q = p * c
p = u * v
q = p + q


Which of the following corresponds to a static single assignment form of the above code?

 A B C D Compiler-Design       Static-single-assignment       Gate 2017 set-01
Question 11 Explanation:
Static Single Assignment is used for intermediate code in compiler design.
In Static Single Assignment form (SSA) each assignment to a variable should be specified with distinct names.
We use subscripts to distinguish each definition of variables.
In the given code segment, there are two assignments of the variable p
p = a-b
p = u*v
and two assignments of the variable q
q = p*c
q = p+q
So we use two variables p1, p2 for specifying distinct assignments of p and q1, q2 for each assignment of q.
Static Single Assignment form(SSA) of the given code segment is:
p1 = a-b
q1 = p1 * c
p2 = u * v
q2 = p2 + q1
Note:
As per options, given in GATE 2017 answer is B.
p3 = a - b
q4 = p3 * c
p4 = u * v
q5 = p4 + q4
 Question 12
 A {R} B {w} C {w, y} D {w, $} Compiler-Design First-and-Follow Gate 2017 set-01 Question 12 Explanation: In the production: P → xQRS, FOLLOW (Q) = FIRST (R) FIRST (R) = {w, ϵ} >br> Since FIRST (R) = {ϵ}, so FOLLOW (Q) → {w} ∪ FIRST(S) FIRST(S) = {y} So, FOLLOW (Q) = {w, y}  Question 13 Consider the following grammar:  stmt → if expr then expr else expr; stmt | ȯ expr → term relop term | term term → id | number id → a | b | c number → [0-9]  where relop is a relational operator (e.g., <, >, …), ȯ refers to the empty statement, and if, then, else are terminals. Consider a program P following the above grammar containing ten if terminals. The number of control flow paths in P is ________. For example, the program  if e1 then e2 else e3  has 2 control flow paths, e1 e2 and e1 e3.  A 1024 B 1025 C 1026 D 1027 Compiler-Design Parsers Gate 2017 set-01 Question 13 Explanation: To get 10 'if' we need to use grammar to get, if then else ; stmt if then else ; if then else . stmt : : : (keep doing 10 times to get 10 'if') We know that every if statement has 2 control flows as given in question. Hence, We have 2 control flow choices for 1st 'if' We have 2 control flow choices for 2nd 'if' : : : We have 2 control flow choices for 10th 'if' Since all the choices are in one single structure or combination, so total choices are 2 × 2 × 2 × ........ 10 times = 210 = 1024  Question 14 Consider the expression (a-1)*(((b+c)/3)+d)). Let X be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture, in which (i) only load and store instructions can have memory operands and (ii) arithmetic instructions can have only register or immediate operands. The value of X is ___________.  A 2 B 3 C 4 D 5 Compiler-Design Register-Allocation Gate 2017 set-01 Question 14 Explanation: (a-1)*(((b+c)/3)+d) Question 15 Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it: A P→(ii), Q→(iii), R→(iv), S→(i) B P→(ii), Q→(i), R→(iii), S→(iv) C P→(iii), Q→(iv), R→(i), S→(ii) D P→(i), Q→(iv), R→(ii), S→(iii) Compiler-Design Compilers GATE 2017(set-02) Question 15 Explanation: Character stream is input to lexical analyzer which produces tokens as output. So Q → (iv). Token stream is forwarded as input to Syntax analyzer which produces syntax tree as output. So, S → (ii). Syntax tree is the input for the semantic analyzer, So P → (iii). Intermediate representation is input for Code generator. So R → (i).  Question 16 Which of the following statements about parser is/are CORRECT? I. Canonical LR is more powerful than SLR. II. SLR is more powerful than LALR. III. SLR is more powerful than Canonical LR.  A I only B II only C III only D II and III only Compiler-Design Parsers GATE 2017(set-02) Question 16 Explanation: Canonical LR is more powerful than SLR as every grammar which can be parsed by SLR parser, can also be parsed by CLR parser. The power in increasing order is: LR(0) < SLR < LALR < CLR Hence only I is true.  Question 17 Consider the following expression grammar G: E → E - T | T T → T + F | F F → (E) | id Which of the following grammars is not left recursive, but is equivalent to G?  A B C D Compiler-Design Left-Recursive-Grammar GATE 2017(set-02) Question 17 Explanation: Consider the production (given below) which has left recursion. S→Sα | β The equivalent production (after removing left recursion) is S→βS1 S1→αS1 | ϵ Hence after removing left recursion from: E→ E-T | T, here α = -T and β = T E→TE1 E1→ -TE1 | ϵ After removing left recursion from: T→T+F | F, here α=+F and β=F T→FT1 T1→ +FT1 | ϵ Replace E1 = X and T1 = Y We have, E→TX X→-TX | ϵ T→FY Y→+FY | ϵ F→(E)| id  Question 18 Consider the following code segment. x = u - t; y = x * v; x = y + w; y = t - z; y = x * y;  The minimum number of variables required to convert the above code segment to static single assignment form is ________.  A 10 B 11 C 12 D 13 Compiler-Design Static-single-assignment 2016 set-01 Question 18 Explanation: In Static Single Assignment form (SSA) each assignment to a variable should be specified with distinct names. Generally, subscripts are used to distinguish each definition of variables. In the given code segment, there are two assignments of the variable x x = u - t; x = y + w; and three assignments of the variable y. y = x * v; y = t - z; y = x * y Hence, two variables viz x1, x2 should be used for specifying distinct assignments of x and for y it is named as y1, y2 and y3 for each assignment of y. Hence, total number of variables is 10 (x1, x2, y1, y2, y3, t, u, v, w, z), and there are 5 temporary variables. Static Single Assignment form (SSA) of the given code segment is: x1 = u - t; y1 = x1 * v; x2 = y1 + w; y2 = t - z; y3 = x2 * y2;  Question 19 The attributes of three arithmetic operators in some programming language are given below. Operator Precedence Associativity Arity + High Left Binary − Medium Right Binary ∗ Low Left Binary  The value of the expression 2 – 5 + 1 – 7 * 3 in this language is __________.  A 9 B 10 C 11 D 12 Compiler-Design Associativity-and-Precedence 2016 set-01 Question 19 Explanation: + has highest precedence, so it will be evaluated first. 2 − 5 + 1 − 7 * 3 = 2 − (5 + 1) − 7 * 3 = 2 − 6 − 7 * 3 Now, − has more precedence than *, so sub will be evaluated before * and – has right associative so (6 − 7) will be evaluated first. 2 − 6 − 7 * 3 = (2 − (6 − 7)) * 3 = (2 – (−1)) * 3 = 3 * 3 = 9  Question 20 Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A} and terminals {a,b}.  S → aA { print 1 } S → a { print 2 } A → Sb { print 3 }  Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:  A 1 3 2 B 2 2 3 C 2 3 1 D syntax error Compiler-Design Syntax-Directed-Translation 2016 set-01 Question 20 Explanation: By using bottom up parser, the output will be “2 3 1” Question 21 Match the following: (P) Lexical analysis (i) Leftmost derivation (Q) Top down parsing (ii) Type checking (R) Semantic analysis (iii) Regular expressions (S) Runtime environments (iv) Activation records   A P ↔ i, Q ↔ ii, R ↔ iv, S ↔ iii B P ↔ iii, Q ↔ i, R ↔ ii, S ↔ iv C P ↔ ii, Q ↔ iii, R ↔ i, S ↔ iv D P ↔ iv, Q ↔ i, R ↔ ii, S ↔ iii Compiler-Design Compilers GATE 2016 set-2 Question 21 Explanation: Regular expressions are used in lexical analysis. Top down parsing has left most derivation of any string. Type checking is done in semantic analysis. Activation records are loaded into memory at runtime.  Question 22 Which one of the following grammars is free from left recursion?  A B C D Compiler-Design Left-Recursive-Grammar GATE 2016 set-2 Question 22 Explanation: The grammar in option A has direct left recursion because of production (A→Aa). The grammar in option C has indirect left recursion because of production, (S→Aa and A→Sc). The grammar in option D also has indirect left recursion because of production, (A→Bd and B→Ae).  Question 23 Which one of the following is True at any valid state in shift-reduce parsing?  A Viable prefixes appear only at the bottom of the stack and not inside B Viable prefixes appear only at the top of the stack and not inside C The stack contains only a set of viable prefixes D The stack never contains viable prefixes Compiler-Design Parsers GATE 2015 (Set-01) Question 23 Explanation: A handle is actually on the top of the stack. A viable prefixes is prefix of the handle and so can never extend to the right of handle, i.e., top of stack. So set of viable prefixes is in stack.  Question 24 The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r/3 + s – t * 5 + u * v/w is _________.  A 8 B 9 C 10 D 11 Compiler-Design Static-single-assignment GATE 2015 (Set-01) Question 24 Explanation: We will need one temporary variable for storing the result of every binary operation as Static Single Assignment implies the variable cannot be repeated on left hand side of assignment. The given expression: q+r/3+s−t∗5+u∗v/w t1=r/3; t2=t∗5; t3=u∗v; t4=t3/w; t5=q+t1; t6=t5+s; t7=t6−t2; t8=t7+t4; So in total we need 8 temporary variables. If it was not mentioned as static single assignment then answer would have been 3 because we can re-use the same temporary variable several times.  Question 25 Let an represent the number of bit strings of length n containing two consecutive 1s. What is the recurrence relation for an?  A an-2+an-1+2n-2 B an-2+2an-1+2n-2 C 2an-2+an-1+2n-2 D 2an-2+2an-1+2n-2 Compiler-Design Live-Variable GATE 2015 (Set-01) Question 25 Explanation: For string of length 1, there is '0' consecutive 1's. So, a1 = 0 For string of length 2, a2 = 1 Similarly, a3 = 3 a4 = 8 Only (A) will satisfy the above values.  Question 26 A variable x is said to be live at a statement Si in a program if the following three conditions hold simultaneously: 1. There exists a statement Sj that uses x 2. There is a path from Si to Sj in the flow graph corresponding to the program 3. The path has no intervening assignment to x including at Si and Sj A p, s, u B r, s, u C r, u D q, v Compiler-Design Live-Variable GATE 2015 (Set-01) Question 26 Explanation: In compilers, live variable analysis is a classic data flow analysis to calculate the variables that are live at each point in the program. A variable is live at some point if it holds a value that may be needed in the future, of equivalently if its value may be read before the next time the variable is written to. → '1' can be assigned by the p and s and there is no intermediate use of them before that. → And p and s are not to be live in the both 2 & 3. → And q also assigned to u not live in 2 & 3. → And v is live at 3 not at 2. → u is live at 3 and also at 2, if we consider a path of length 0 from 2-8. Finally r, u is the correct one.  Question 27 In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?  A In both AST and CFG, let node, N2 be the successor of node N1. In the input program, the code corresponding to N2 is present after the code corresponding in N1. B For any input program, neither AST nor CFG will contain a cycle C The maximum number of successors of a node in an AST and a CFG depends on the input program D Each node is AST and CFG corresponds to at most one statement in the input program Compiler-Design Syntax-tree-and-context-flow-graph GATE 2015 -(Set-2) Question 27 Explanation: Optional (A) is not true when CFG contains cycle Option (B) is false as CFG can contain cycle Option (D) is false as a single node can contain block of statements.  Question 28  A P-2,Q-3,R-1,S-4 B P-2,Q-1,R-4,S-3 C P-2,Q-4,R-1,S-3 D P-2,Q-3,R-4,S-1 Compiler-Design Compilers GATE 2015 -(Set-2) Question 28 Explanation: P) Lexical analysis is related with FA and Regular expressions. Q) Expression can be evaluated with postfix traversals. R) Register allocation can be done by graph colouring. S) The parser constructs a production tree. Hence, answer is ( C ).  Question 29  A 5 and 7 B 6 and 7 C 5 and 5 D 7 and 8 Compiler-Design Control-Flow-Graph GATE 2015 -(Set-2) Question 29 Explanation: Question 30 Among simple LR (SLR), canonical LR, and look-ahead LR (LALR), which of the following pairs identify the method that is very easy to implement and the method that is the most powerful, in that order?  A SLR, LALR B Canonical LR, LALR C SLR, canonical LR D LALR, canonical LR Compiler-Design Parsers GATE 2015(Set-03) Question 30 Explanation: SLR is very easy to implement and CLR is most powerful method.  Question 31 Consider the following grammar G.  S → F ⎪ H F → p ⎪ c H → d ⎪ c Where S, F and H are non-terminal symbols, p, d and c are terminal symbols. Which of the following statement(s) is/are correct? S1: LL(1) can parse all strings that are generated using grammar G. S2: LR(1) can parse all strings that are generated using grammar  A Only S1 B Only S2 C Both S1 and S2 D Neither S1 nor S2 Compiler-Design Parsers GATE 2015(Set-03) Question 31 Explanation: For LL(1), For first production, So, there is 'c' common in both the first(s) in the production of S. So not LL(1). For LR(1), Since R-R conflict is present. So, not LR(1). Hence, Option (D) is the correct answer.  Question 32 Which one of the following is FALSE?  A A basic block is a sequence of instructions where control enters the sequence at the beginning and exits at the end. B Available expression analysis can be used for common subexpression elimination. C Live variable analysis can be used for dead code elimination. D x=4*5⇒x=20 is an example of common subexpression elimination. Compiler-Design Code-Optimization GATE 2014(Set-01) Question 32 Explanation: x=4* 5 ⇒ x=20 is an example of common subexpression elimination is a false statement. Common subexpression elimination (CSE) is a compiler optimization that searches for instances of identical expressions (i.e., they all evaluate to the same value), and analyzes whether it is worthwhile replacing them with a single variable holding the computed value. For ex: Consider the following code: m=y+z * p n= y+z *k The common subexpression is “y+z” we can be calculate it one time and replace in both expression temp = y+z m = temp*p n = temp*k  Question 33 A canonical set of items is given below S --> L. > R Q --> R. On input symbol < the set has  A a shift-reduce conflict and a reduce-reduce conflict. B a shift-reduce conflict but not a reduce-reduce conflict. C a reduce-reduce conflict but not a shift-reduce conflict. D neither a shift-reduce nor a reduce-reduce conflict. Compiler-Design Parsers GATE 2014(Set-01) Question 33 Explanation: The input symbol is “<” which is not in canonical set of item, so it is neither a shift-reduce nor a reduce-reduce conflict with reference to “<” symbol. But if it would have asked about “>” then it will be a SR conflict.  Question 34 Let L be a language and L' be its complement. Which one of the following is NOT a viable possibility?  A Neither L nor is recursively enumerable (r.e.). B One of L and is r.e. but not recursive; the other is not r.e. C Both L and are r.e. but not recursive. D Both L and are recursive. Compiler-Design Closure-Property GATE 2014(Set-01) Question 34 Explanation: If both L and L’ are recursively enumerable, then L must be recursive. Hence, both L and L´ are recursively enumerable, but not recursive is not a viable possibility.  Question 35 Which of the regular expressions given below represent the following DFA? I) 0*1(1+00*1)* II) 0*1*1+11*0*1 III) (0+1)*1  A I and II only B I and III only C II and III only D I, II, and III Compiler-Design Regular-Expressions GATE 2014(Set-01) Question 35 Explanation: The DFA accepts the language “all strings ending with 1”. So the regular expression corresponding to DFA is (0+1)*1. Now, by using state elimination method, So the DFA also has another equivalent regular expression: 0*1(1+00*1)*. But the regular expression (0*1*1+11*0*1) is not equivalent to DFA, as the DFA also accept the string “11011” which cannot be generated by this regular expression.  Question 36 Consider the grammar defined by the following production rules, with two operators ∗ and +  S --> T * P T --> U | T * U P --> Q + P | Q Q --> Id U --> Id  Which one of the following is TRUE?  A + is left associative, while ∗ is right associative B + is right associative, while ∗ is left associative C Both + and ∗ are right associative D Both + and ∗ are left associative Compiler-Design Associativity-and-Precedence Gate 2014 Set -02 Question 36 Explanation: In production: T ⟶ T * U, since T is left recursive, hence * is left associative. P ⟶ Q + P, here P is right recursive, so + is right associative.  Question 37 Which one of the following is NOT performed during compilation?  A Dynamic memory allocation B Type checking C Symbol table management D Inline expansion Compiler-Design Run-Time-Environments Gate 2014 Set -02 Question 37 Explanation: Dynamic memory allocation is not performed during compilation, it occurs at run time only. At the time of compilation, compiler only compiles the instructions for dynamic memory allocation, like calloc, malloc….  Question 38 For a C program accessing X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits.  t0 = i ∗ 1024 t1 = j ∗ 32 t2 = k ∗ 4 t3 = t1 + t0 t4 = t3 + t2 t5 = X[t4] Which one of the following statements about the source code for the C program is CORRECT?  A X is declared as “int X”. B X is declared as “int X”. C X is declared as “char X”. D X is declared as “char X”. Compiler-Design Intermediate-Code Gate 2014 Set -02 Question 38 Explanation: Consider a 3-D array: arr[i][j][k] Arr, this 3-D array contains 1 two dimensional array as i value is zero ( if i =1 then it has 2, two D array ), & the two dimension array has 2 row and 3 column. So, In a 3-D array, i represent number of 2D arrays, j represent number of rows and k represent number of columns. Number of 2 D array (M)=1 Number of rows (R)=2 Number of columns (C)=3 As arrays are stored in row major order, so this 2 dimension array will be stored as: Assume base address of Arr is 1000. The address of required position is calculated as: Arr[i][j][k]= Arr+ [i*(R*C)+(j*C)+k]*4 // multiplication to 4 is due to int takes 4 Bytes. Arr= 1000+[0*(2*3)+(1*3)+1]*4 =1000+[ 0+3+1 ]*4 =1000+4*4 =1016 As you can see that in the given example of row order storing of array also has address of Arr is 1016. Now coming to the question: X [ i ][ j ][ k ] is calculated by 3 address code X[t4] X [ i ][ j ][ k ] = X [ t4 ] // by substituting in reverse =X [ t3 + t2] =X [ t1 + t0 + k*4] =X [ t0 + t1 + k*4] // t0 and t1 swapped as swapping doesn't have any impact =X [ i*1024 + j*32 + k*4] =X [ i*256 + j*8 +k] *4 // taking 4 (common) outside = X [ i*(32*8)+ (j*8) +k] *4 By comparing the above line with ....... Arr[i][j][k]= Arr+ [i*(R*C)+(j*C)+k]*4 We get R=32, C=8 It means the the declared array has 32 rows and 8 columns and since multiplication by 4 (common outside) so it was declared as INT. But how many number of 2D arrays in this 3D array, we don't know. Since option A is the only option with configuration: INT arr[ ] [ 32 ] [ 8]. So it is right option.  Question 39 Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the maximum possible value of the expression represented by the tree is ___. A 6 B 7 C 8 D 9 Compiler-Design General Gate 2014 Set -02 Question 39 Explanation:  Question 40 One of the purposes of using intermediate code in compilers is to  A make parsing and semantic analysis simpler. B improve error recovery and error reporting. C increase the chances of reusing the machine-independent code optimizer in other compilers. D improve the register allocation. Compiler-Design Code-Generation-and-Code-Optimization Gate 2014 Set -03 Question 40 Explanation: Intermediate code is generated after semantic analysis. The intermediate code is independent of machine. By converting source code to intermediate code a machine independent code optimizer may be written. Thus increase the chances of reusing the machine-independent code optimizer in other compilers.  Question 41 Which of the following statements are CORRECT? 1)Static allocation of all data areas by a compiler makes it impossible to implement recursion. 2)Automatic garbage collection is essential to implement recursion. 3)Dynamic allocation of activation records is essential to implement recursion. 4)Both heap and stack are essential to implement recursion.  A 1 and 2 only B 2 and 3 only C 3 and 4 only D 1 and 3 only Compiler-Design General Gate 2014 Set -03 Question 41 Explanation: The statement, static allocation of all data areas by a compiler makes it impossible to implement recursion is true, as recursion requires memory allocation at run time, so it requires dynamic allocation of memory. Hence, Dynamic allocation of activation records is essential to implement recursion is also a true statement.  Question 42 A system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are initially empty. What is the total number of page faults that will occur while processing the page reference string given below? 4, 7, 6, 1, 7, 6, 1, 2, 7, 2  A 6 B 7 C 8 D 9 Compiler-Design Page-Replacement-Algorithm Gate 2014 Set -03 Question 42 Explanation: 6 page faults will occur using LRU.  Question 43 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 → є and A → a) to parse a string with n tokens?  A n/2 B n-1 C 2n-1 D 2n Compiler-Design Parsing-and-Syntax-Directed-Graph Gate 2013 Question 43 Explanation: Since it is given that the grammar cannot have: 1) epsilon production 2) production of the form A → a Consider the grammar: S → Sa | a If we were to derive the string “aaa” whose length is 3 then the number of reduce moves that would have been required are shown below: S→ Sa →Saa →aaa This shows us that it has three reduce moves. The string length is 3 and the number of reduce moves is also 3. So presence of such kinds of production might give us the answer “n” for maximum number of reduce moves. But these productions are not allowed as per the question. Also note that if a grammar does not have unit production then the maximum number of reduce moves can not exceed “n” where “n” denotes the length of the string. 3) No unit productions Consider the grammar: S→ A A→ B B→C C→a If we were to derive the string “a” whose length is 1 then the number of reduce moves that would have been required are shown below: S→ A A→ B B→C C→a This shows us that it has four reduce moves. The string length is 1 and the number of reduce moves is 4. So presence of such kind of productions might give us the answer “n+1” or even more, for maximum number of reduce moves. But these productions are not allowed as per the question. Now keeping in view the above points suppose we want to parse the string “abcd”. (n = 4) using bottom-up parsing where strings are parsed finding the rightmost derivation of a given string backwards. So here we are concentrating on deriving right most derivations only. We can write the grammar which accepts this string which in accordance to the question, (i.e., with no epsilon- and unit-production (i.e., of type A → є and A → B) and no production of the form A→a) as follows: S→aB B→bC C→cd The Right Most Derivation for the above is: S → aB (Reduction 3) → abC (Reduction 2) → abcd (Reduction 1) We can see here the number of reductions present is 3. We can get less number of reductions with some other grammar which also doesn’t produce unit or epsilon productions or production of the form A→a: S→abA A→ cd The Right Most Derivation for the above is: S → abA (Reduction 2) → abcd (Reduction 1) Hence 2 reductions. But we are interested in knowing the maximum number of reductions which comes from the 1st grammar. Hence total 3 reductions as maximum, which is (n – 1) as n = 4 here.  Question 44 Consider the following two sets of LR(1) items of an LR(1) grammar. X -> c.X, c/d X -> .cX, c/d X -> .d, c/d X -> c.X,$
X -> .cX, $X -> .d,$
Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?
1. Cannot be merged since look aheads are different.
2. Can be merged but will result in S-R conflict.
3. Can be merged but will result in R-R conflict.
4. Cannot be merged since goto on c will lead to two different sets.

 A 1 only B 2 only C 1 and 4 only D 1, 2, 3 and 4
Compiler-Design       Parsing-and-Syntax-Directed-Graph       Gate 2013
Question 44 Explanation:
The two sets in LR(1) items can be merged if they only differ with look aheads symbols, so statement 1 is false.
In the given LR(1) items there is not any reduce move, so after merging it will not have SR conflict and hence statement 2 and statement 3 are false.
Statement 4 is also wrong, because goto is carried on Non-Terminals symbols, not on terminal symbols, and c is a terminal symbol.
Hence all statements are false.
 Question 45
Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.
Program main;
Var ...

Procedure A1;
Var ...
Call A2;
End A1

Procedure A2;
Var ...

Procedure A21;
Var ...
Call A1;
End A21

Call A21;
End A21

Call A1;
End main.

Consider the calling chain : Main->A1->A2->A21->A1 The correct set of activation records along with their access links is given by :
 A B C D Compiler-Design       Run-Time-Environments       Gate 2012
Question 45 Explanation: Main → A1 → A2 → A21 → A1
Since, Activation records are created at procedure exit time.
A1 & A2 are defined under Main ( ). So A1 & A2 access links are pointed to main.
A21 is defined under A2, hence its access link will point to A2.
 Question 46
 A FIRST(A) = {a,b,ε} = FIRST(B) FOLLOW(A) = {a,b} FOLLOW(B) = {a,b,$} B FIRST(A) = {a,b,$} FIRST(B) = {a,b,ε} FOLLOW(A) = {a,b} FOLLOW(B) = {$} C FIRST(A) = {a,b,ε} = FIRST(B) FOLLOW(A) = {a,b} FOLLOW(B) = ∅ D FIRST(A) = {a,b} = FIRST(B) FOLLOW(A) = {a,b} FOLLOW(B) = {a,b} Compiler-Design Parsers Gate 2012 Question 46 Explanation: FIRST (P): is the set of terminals that begin the strings derivable from non terminal P. If P derives epsilon then we include epsilon in FIRST(P). FOLLOW(P): is the set of terminals that can appear immediately to the right of P in some sentential form. FIRST(A) = FIRST (S) FIRST (S) = FIRST (aAbB) and FIRST (bAaB) and FIRST (ϵ) FIRST(S) = {a, b, ϵ} FIRST (B) = FIRST (S) = {a, b, ϵ}= FIRST (A) FOLLOW(A) = {b} // because of production S→a A b B FOLLOW(A) = {a} // because of production S→ b A a B So FOLLOW (A) = {a, b} FOLLOW (B) = FOLLOW (S) // because of production S→ a A b B FOLLOW (S) = FOLLOW (A) // because of production A → S So FOLLOW (S) = {$, a, b}= FOLLOW(B)
 Question 47
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. is the empty string, $indicates end of input, and, | separates alternate right hand sides of productions. Note:In the table second column first row it's not "A" it's "a".  A E1: S → aAbB,A → S E2: S → bAaB,B→S E3: B → S B E1: S → aAbB,S→ ε E2: S → bAaB,S → ε E3: S → ε C E1: S → aAbB,S → ε E2: S → bAaB,S→ε E3: B → S D E1: A → S,S →ε E2: B → S,S → ε E3: B →S Compiler-Design Parsers Gate 2012 Question 47 Explanation: The entries in E1, E2 and E3 is related to S and B, so we have to take only those production which have S and B in LHS. S→ aAbB | bAaB | ε The production S→ aAbB will go under column FIRST (aAbB) = a, so S→ aAbB will be in E1. S→ bAaB will go under column FIRST(bAaB) = b, so S→ bAaB will be in E2. S→ ε will go under FOLLOW (S) = FOLLOW(B) = {a, b,$ } , So S→ ε will go in E1, E2 and under column of $. So E1 will have: S→ aAbB and S→ ε. E2 will have S→ bAaB and S→ ε. Now, B→ S will go under FIRST (S) = {a, b, ε} Since FIRST(S) = ε so B→ S will go under FOLLOW (B) = {a, b,$}
So E3 will contain B→ S.
 Question 48
The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?
 A Finite state automata B Deterministic pushdown automata C Non-Deterministic pushdown automata D Turing machine
Compiler-Design       Compilers       Gate 2011
Question 48 Explanation:
Lexical Analysis is implemented by finite automata
 Question 49
In a compiler, keywords of a language are recognized during
 A parsing of the program B the code generation C the lexical analysis of the program D dataflow analysis
Compiler-Design       Compilers       Gate 2011
Question 49 Explanation:
Any identifier is also a token so it is recognized in lexical Analysis
 Question 50
Consider two binary operators ‘’ and ‘’ with the precedence of operator being lower than that of the operator . Operator is right associative while operator , is left associative. Which one of the following represents the parse tree for expression (73432)?
 A B C D Compiler-Design       Parsers       Gate 2011
Question 50 Explanation:
7 ↓ 3 ↑ 4 ↑ 3 ↓ 2
⇒ 7 ↓ (3 ↑ (4 ↑ 3)) ↓ 2
⇒ 7 ↓ (3 ↑ (4 ↑ 3))) ↓ 2 as ↓ is left associative
 Question 51
Consider evaluating the following expression tree on a machine with load-store architecture in which memory can be accessed only through load and store instructions. The variables a, b, c, d and e initially stored in memory. The binary operators used in this expression tree can be evaluate by the machine only when the operands are in registers. The instructions produce results only in a register. If no intermediate results can be stored in memory, what is the minimum number of registers needed to evaluate this expression? A 2 B 9 C 5 D 3
Compiler-Design       Register-Allocation       Gate 2011
Question 51 Explanation:
Load R1, a ; R1 ← M[a]
Load R2, b ; R2 ← M[b]
Sub R1, R2 ; R1 ← R1 – R2
Load R2, c ; R2 ← M[c]
Load R3, d ; R3 ← M[d]
Add R2, R3 ; R2 ← R2 + R3
Load R3, e ; R3 ← M[e]
Sub R3, 3 ; R3 ← R3 – R2
Add R1, R3 ; R1 ← R1 + R3
Total 3 Registers are required minimum
 Question 52
Which data structure in a compiler is used for managing information about variables and their attributes?
 A Abstract syntax tree B Symbol table C Semantic stack D Parse Table
Compiler-Design       Compilers       2010
Question 52 Explanation:
Symbol tables are data structures that are used by compilers to hold information about source-program constructs. The information is collected incrementally by the analysis phases of a compiler and used by the synthesis phases to generate the target code. Entries in the symbol table contain information about an identifier such as its character string (or lexeme) , its type, its position in storage, and any other relevant information.
 Question 53
Which languages necessarily need heap allocation in the runtime environment?
 A Those that support recursion B Those that use dynamic scoping C Those that allow dynamic data structures D Those that use global variables
Compiler-Design       Run-Time-Environments       2010
Question 53 Explanation:
Dynamic memory is allocated on the heap by the system. So the languages which allow dynamic data structure require heap allocation at runtime.
 Question 54
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+f
Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling?
 A 2 B 3 C 4 D 6
Compiler-Design       Register-Allocation       2010
Question 54 Explanation:
Here a, b, and c all have 3 different values so we need atleast 3 registers r1, r2 and r3.
Assume 'a' is mapped to r1, 'b' to r2 and 'c' to r3.
d = a + b, after this line if u notice 'a' is never present on right hand side, so we can map 'd' to r1.
e = c + d, after this line 'd' is never present on rhs, so we can map 'e' to r1.
at this time mapping is
r1 --- e
r2 --- b
r3 --- c
We have 3 registers for e, b and c.
f = c + e
b = c + e
These two are essentially doing same thing, after these two line 'b' and 'f' are same so we can skip computing 'f' or need not give any new register for 'f'. And wherever 'f' is present we can replace it with 'b', because neither of 'f' and 'b' are changing after these two lines, so value of these will be 'c+e' till the end of the program.
At second last line "d = 5 + e"
here 'd' is introduced, we can map it to any of the register r1 or r3, because after this line neither of 'e' or 'c' is required. Value of 'b' is required because we need to return 'd+f', and 'f' is essentially equal to 'b'
finally code becomes
r1 = 1
r2 = 10
r3 = 20
r1 = r1 + r2
r1 = r3 + r1
r2 = r3 + r1
r2 = r3 + r1
r1 = r2 + r2
r3 = 5 + r1
return r3 + r2
Therefore minimum 3 registers needed.
 Question 55
The grammar S → aSa|bS|c is
 A LL(1) but not LR(1) B LR(1) but not LR(1) C Both LL(1) and LR(1) D Neither LL(1) nor LR(1)
Compiler-Design       Parsers       2010
Question 55 Explanation:
The LL(1) parsing table for the given grammar is: As there is no conflict in LL(1) parsing table, hence the given grammar is LL(1) and since every LL(1) is LR(1) also, so the given grammar is LL(1) as well as LR(1).
 Question 56
Match all items in Group 1 with correct options from those given in Group A P-4, Q-1, R-2, S-3 B P-3, Q-1, R-4, S-2 C P-3, Q-4, R-1, S-2 D P-2, Q-1, R-4, S-3
Compiler-Design       Compilers       2009
Question 56 Explanation:
Lexical analysis phase uses regular expression to identify the pattern of tokens, PDA is used in CFG and hence syntax analysis phase is related to PDA. Data flow analysis is done in code optimization phase and register allocation is related to code generation phase.
 Question 57
Which of the following statements are TRUE? I.There exist parsing algorithms for some programming languages whose complexities are less than q (n3 ). II.A programming language which allows recursion can be implemented with static storage III.No L-attributed definition can be evaluated in the framework of bottom-up parsing. IV.Code improving transformations can be performed at both source language and intermediate code level
 A I and II B I and IV C III and IV D I, III and IV
Compiler-Design       Parsers       2009
Question 57 Explanation:
Statement II is false, as a programming language which allows recursion requires dynamic storage allocation. Statement III is false, as L-attributed definition (assume for instance the L-attributed definition has synthesized attribute only) can be evaluated in bottom up framework.
Statement I is true, as the bottom up and top down parser take O(n) time to parse the string , i.e. only one scan of input is required.
Statement IV is true,Code improving transformations can be performed at both source language and intermediate code level. For example implicit type casting is also a kind of code improvement which is done during semantic analysis phase and intermediate code optimization is a topic itself which uses various techniques to improve the code such as loop unrolling, loop invariant.
 Question 58
Which of the following describes a handle (as applicable to LR-parsing) appropriately?
 A It is the position in a sentential form where the next shift or reduce operation will occur. B It is non-terminal whose production will be used for reduction in the next step. C It is a production that may be used for reduction in a future step along with a position in the sentential form where the next shift or reduce operation will occur. D It is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found.
Compiler-Design       Parsers       Gate-2008
Question 58 Explanation:
A handle is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found.
 Question 59
Some code optimizations are carried out on the intermediate code because
 A They enhance the portability of the compiler to other target processors B Program analysis is more accurate on intermediate code than on machine code C The information from dataflow analysis cannot otherwise be used for optimization D The information from the front end cannot otherwise be used for optimization
Compiler-Design       Compilers       Gate-2008
Question 59 Explanation:
The code-optimization on intermediate code generation will always enhance the portability of the compiler to target processors. The main reason behind this is, as the intermediate code is independent of the target processor on which the code will be executed, so the compiler is able to optimize the intermediate code more conveniently without bothering the underlying architecture of target processor.
 Question 60
Which of the following are true? I.A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation II.Multi-level access link (or display) arrangement is needed to arrange activation records only if the programming language being implemented has nesting of procedures/functions III.Recursion in programming languages cannot be implemented with dynamic storage allocation IV.Nesting procedures/functions and recursion require a dynamic heap allocation scheme and cannot be implemented with a stack-based allocation scheme for activation records V.Programming languages which permit a function to return a function as its result cannot be implemented with a stack-based storage allocation scheme for activation records
 A II and V only B I, III and IV only C I, II and V only D II, III and V only
Compiler-Design       Run-Time-Environments       Gate-2008
Question 60 Explanation:
II. Multilevel access link (or display) arrangement is needed to arrange Activation Records only if the programming language being implemented has nesting of procedures and functions.
V. PL’s which permits a function to return a function as its result cannot be implemented with a stack-based storage allocation scheme for activation records.
II & V are True.
 Question 61
An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
 A the SLR(1) parser for G has S-R conflicts B the LR(1) parser for G has S-R conflicts C the LR(0) parser for G has S-R conflicts D the LALR(1) parser for G has reduce-reduce conflicts
Compiler-Design       Parsres       Gate-2008
Question 61 Explanation:
LALR(1) parser is obtained by minimising the LR(1) parser and hence they both uses LR(1) items. Now consider if LR(1) parser has SR conflict, for ex:
Consider a state in LR(1) parser:
S-> x.yA, a
A-> x. , y
This has both shift and reduce conflict on symbol “y”.
Since LR(1) already has SR conflict , so resulting LALR(1) (after merging) will also have SR conflict.
Now if LR(1) doesn’t have SR conflict then it is guaranteed that the LALR(1) will never have SR conflict. The reason behind this is, as we merge those state only which has same set of canonical items except look ahead and the LR(1) canonical items has DFA (means from one state to other state the transition is from unique symbol) , so after merging also we will never see any shift conflict, only reduce-reduce may occur.
Hence An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if the LR(1) parser for G has S-R conflicts.
 Question 62
Which one of the following is a top-down parser?
 A Recursive descent parser. B Operator precedence parser. C An LR(k) parser. D An LALR(k) parser.
Compiler-Design       Parsers       Gate-2007
Question 62 Explanation:
Recursive descent parser is top down parser, while others are bottom up parser.
 Question 63
Consider the grammar with non-terminals N = {S,C,S1 },terminals T={a,b,i,t,e}, with S as the start symbol, and the following set of rules:
S --> iCtSS1|a
S1 --> eS|ε
C --> b
The grammar is NOT LL(1) because:
 A it is left recursive B it is right recursive C it is ambiguous D it is not context-free
Compiler-Design       Parsers       Gate-2007
Question 63 Explanation:
The given grammar is not left recursive and also it is context free (Type 2 grammar), so option A and D is wrong. Being a right recursive grammar is not an issue for LL(1) grammar. So even if given grammar is right recursive, this is not a reason for NOT LL(1).
This grammar has two parse tree for string “ibt ibt aea”. Question 64
Consider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?
 A Both P and Q are true B P is true and Q is false C P is false and Q is true D Both P and Q are false
Compiler-Design       Parsers       Gate-2007
Question 64 Explanation:
Every regular grammar is LL(1) is false, as the grammar may have left recursion or left factoring or also it is possible that grammar is ambiguous.
For ex: Consider a regular grammar
S->aS | a | ϵ
this grammar is ambiguous as for string "a" two parse tree is possible. Hence it is regular but not LL(1).
But every regular set has a language acceptor as DFA , so every regular set must have atleast one grammar which is unambiguous.
Hence, every regular set has LR(1) grammar.
 Question 65
Consider the CFG with {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S as the start symbol and the following set of production rules
S --> aB        S --> bA
B --> b         A --> a
B --> bS        A --> aS
B --> aBB       A --> bAA
Which of the following strings is generated by the grammar?
 A aaaabb B aabbbb C aabbab D abbbba
Compiler-Design       Grammar       Gate-2007
Question 65 Explanation:
The string “aabbab” can be derived by following steps:
S -> aB [Using S --> aB]
-> aaBB [Using B --> aBB]
-> aabB [Using B --> b]
-> aabbS [Using B --> bS]
-> aabbaB [Using S --> aB]
-> aabbab [Using B --> b]
 Question 66
Consider the CFG with {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S as the start symbol and the following set of production rules
S --> aB        S --> bA
B --> b         A --> a
B --> bS        A --> aS
B --> aBB       A --> bAA
Which of the following strings is generated by the grammar?
 A 1 B 2 C 3 D 4
Compiler-Design       Grammar       Gate-2007
Question 66 Explanation:
There exist two parse tree for the string “aabbab” using LMD (left most derivation) Question 67
Consider an ambiguous grammar G and its disambiguated version D. Let the language recognized by the two grammars be denoted by L(G) and L(D) respectively. Which one of the following is true ?
 A L (D) ⊂ L (G) B L (D) ⊃ L (G) C L (D) = L (G) D L (D) is empty
Compiler-Design       Grammar       Gate 2007-IT
Question 67 Explanation:
By changing the corresponding grammar, the language will not be changed.
For example, by converting NFA to DFA language will not be changed.
 Question 68
Consider the following grammar.
S -> S * E
S -> E
E -> F + E
E -> F
F -> id
Consider the following LR(0) items corresponding to the grammar above.
(i) S -> S * .E
(ii) E -> F. + E
(iii) E -> F + .E
Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
 A (i) and (ii) B (ii) and (iii) C (i) and (iii) D None of the above
Compiler-Design       Parsers       Gate-2006
Question 68 Explanation:
As we can see in the below given LR(0) items, that all three belongs to different state (sets). Question 69
Consider the following translation scheme. S → ER R → *E{print("*");}R | ε E → F + E {print("+");} | F F → (S) | id {print(id.value);} Here id is a token that represents an integer and id.value represents the corresponding integer value. For an input '2 * 3 + 4', this translation scheme prints
 A 2 * 3 + 4 B 2 * +3 4 C 2 3 * 4 + D 2 3 4+*
Compiler-Design       Syntax-Directed-Translation       Gate-2006
Question 69 Explanation: Now perform post order evaluation, you will get output as,
2 3 4 + *
 Question 70
Consider the following C code segment.
 for (i = 0, i
Which one of the following is false?
 A The code contains loop invariant computation B There is scope of common sub-expression elimination in this code C There is scope of strength reduction in this code D There is scope of dead code elimination in this code
Compiler-Design       Code-Optimization       Gate-2006
Question 70 Explanation:
→ 4*j is a common sub-expression. So there is a scope of elimination. So B is correct.
→ 5*i can be moved out of inner loop. So can be i%2, here loopinvarient computation can be done, so option A is correct.
→ 4*i, 5*j can also be replaced so there is a scope of strength reduction. So C is true.
→ But there is no dead code to eliminate, we can replace the variable representation only.
 Question 71
Consider the following grammar:
S → FR
R → S | ε
F → id
In the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $] respectively.  A {S → FR} and {R → ε} B {S → FR} and { } C {S → FR} and {R → *S} D {F → id} and {R → ε} Compiler-Design Parsers Gate-2006 Question 71 Explanation: Predictive parsing table for the mentioned grammar: The representation M[X,Y] means X represents Variable (rows) and Y represents terminals (columns). The productions are filled in parsing table by the below mentioned rules: For every production P → α, we have: Rule 1: If P → α is a production then add this production for each terminal “t” which is in FIRST of [α] i.e., ADD P → α to M[P, a] Rule 2: If “ϵ” belongs to FIRST of [P] then add P → α to M[P, b] where “b” represents terminals FOLLOW[P]. By the above rules, we can see that production S → FR will go M[S, a] where “a” is FIRST [FR] which is equal to FIRST[F] = id, So S → FR will go in M[S,id]. Since in the production R→ϵ , FIRST[ϵ] = ϵ, hence the production will go in M[R, b] where “b” represents terminals FOLLOW[R] and FOLLOW[R] =$, so production R→ϵ will go in M[R,$]  Question 72 Consider the following code written in a pass-by-reference language like FORTRAN and these statements about the code. subroutine swap(ix,iy) it = ix L1 : ix = iy L2 : iy = it end ia = 3 ib = 8 call swap (ia, 1b+5) print *, ia, ib end S1: The compiler will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the cell swap S2: On execution the code will generate a runtime error on line L1 S3: On execution the code will generate a runtime error on line L2 S4: The program will print 13 and 8 S5: The program will print 13 and -2 Exactly the following set of statement(s) is correct:  A S1 is false and S2 is false B S1 is false and S2 is true C S1 is true and S2 is false D S1 is true and S2 is true Compiler-Design Code-Optimization Gate-2006 Question 72 Explanation: We cannot compare the program on the basis of runtime with respect to any inputs. So, given statement is wrong. S1: Let us assume an array = {1,2,3,4,5} and i=0. Let j = i+2 = 0+2 = 2 For the respective example work1 and work2 results 1 and 0, so S1 statement is False.  Question 73 The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar is:  A ambiguous B left-recursive C right-recursive D an operator-grammar Compiler-Design Parsers Gate-2005 Question 73 Explanation: The given grammar can be turned into a infinite parse tree. So it is ambiguous. It have A → AA has left recursion.  Question 74 Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.  E → number E.val = number. val | E '+' E E(1).val = E(2).val + E(3).val | E '×' E E(1).val = E(2).val × E(3).val The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?  A It detects recursion and eliminates recursion B It detects reduce-reduce conflict, and resolves C It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action D It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action Compiler-Design Parsres Gate-2005 Question 74 Explanation: Yacc favours shift move in case of SR conflict.  Question 75 Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.  E → number E.val = number. val | E '+' E E(1).val = E(2).val + E(3).val | E '×' E E(1).val = E(2).val × E(3).val Assume the conflicts in Part (a) of this question are resolved and an LALR(1) parser is generated for parsing arithmetic expressions as per the given grammar. Consider an expression 3 × 2 + 1. What precedence and associativity properties does the generated parser realize?  A Equal precedence and left associativity; expression is evaluated to 7 B Equal precedence and right associativity; expression is evaluated to 9 C Precedence of '×' is higher than that of '+', and both operators are left associative; expression is evaluated to 7 D Precedence of '+' is higher than that of '×', and both operators are left associative; expression is evaluated to 9 Compiler-Design Parsers Gate-2005 Question 75 Explanation: First of all, it is ambiguous grammar. Hence, equal precedence and associativity. Now as Yacc resolved it with shift move we will shift until the last operator and then we will start reducing. Hence, the answer is 9 and right associative.  Question 76 Consider line number 3 of the following C- program.  int main ( ) { /* Line 1 */  int I, N; /* Line 2 */  fro (I = 0, I < N, I++); /* Line 3 */ } Identify the compiler's response about this line while creating the object-module  A No compilation error B Only a lexical error C Only syntactic errors D Both lexical and syntactic errors Compiler-Design Compilers Gate-2005 Question 76 Explanation: There is no error in the above code. Actually it is a link error. Here compiler fro is a function which is not declared. Hence, it will not produce any error. It will only throw a warning in C.  Question 77 Consider the grammar E → E + n | E × n | n For a sentence n + n × n, the handles in the right-sentential form of the reduction are  A n, E + n and E + n × n B n, E + n and E + E × n C n, n + n and n + n × n D n, E + n and E × n Compiler-Design Grammar Gate-2005 Question 77 Explanation: E → E * n {Applying E → E*n} → E + n * n {Applying E → E + n} → n + n * n {Applying E → n} We use n, E+n, E×n reductions to get a sentence n+n*n.  Question 78 Consider the grammar S → (S) | a Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good  A n1 < n2 < n3 B n1 = n3 < n2 C n1 = n2 = n3 D n1 ≥ n3 ≥ n2 Compiler-Design Parsers Gate-2005 Question 78 Explanation: → SLR(1) and LALR(1) both are be the states of LR(0) items then SLR(1) = LALR(1). → LR(1) be the states of LR(1) items. → LR(0) items never be greater than LR(1) items then SLR(1) = LALR(1) < LR(1) n1 = (n3) < (n2)  Question 79  A (i) only B (i) and (iii) only C (ii) and (iii) only D (iii) and (iv) only Compiler-Design Parsers Gate-2004 Question 79 Explanation: Operator values doesn't contains nullable values and two adjacent non-terminals on RHS production. i) On RHS it contains two adjacent non-terminals. ii) Have nullable values.  Question 80 Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the reference will be resolved at  A Edit time B Compile time C Link time D Load time Compiler-Design Compilers Gate-2004 Question 80 Explanation: The link time can gives the reference to the executable file when the functions are present in the other modules.  Question 81 Consider the grammar rule E → E1 - E2 for arithmetic expressions. The code generated is targeted to a CPU having a single user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have any common sub-expression, in order to get the shortest possible code  A E1 should be evaluated first B E2 should be evaluated first C Evaluation of E1 and E2 should necessarily be interleaved D Order to evaluation of E1 and E2 is of no consequence Compiler-Design Target-Code-Generation Gate-2004 Question 81 Explanation: After evaluating E2 first and then E1, we will have E2 in the register and then we can simply do SUB operation with E2 which will be in memory. And if we do E1 first and then E2, then we must move E2 to memory and again bring back E1 to the register before doing SUB operation, which will increase load.  Question 82  A 200 B 180 C 160 D 40 Compiler-Design Grammar Gate-2004 Question 82 Explanation: Given expression is 2 # 3 & 5 # 6 & 4 → Here # means multiplication (*) & means addition (+) → & is having more precedence because it is far from starting symbol, here # and & are left associatives. 2 # 3 & 5 # 6 & 4 ⇒ (2 * (3+5)) * (6+4) ⇒ (2 * 8) * (10) ⇒ 16 * 10 = 160  Question 83  A {w|Na(w) > 3Nb(w)} B {w|Nb(w) > 3Na(w)} C {w|Na(w) = 3k, k Î {0, 1, 2, ...}} D {w|Nb(w) = 3k, k Î {0, 1, 2, ...}} Compiler-Design Grammar Gate-2004 Question 83 Explanation: S→bS S→baA S→babA S→babaB S→babaa n(a)=3; n(b)=2 Option A: Na(w) > 3Nb(w) 3 > 3(2) 3 > 6 (✖️) Option B: Nb(w) > 3Nb(w) 2 > 3(2) 2 > 6 (✖️) Option D: Nb(w) = 3k 2 = 3k(✖️) S = aA S→aA S→abA S→abaB S→abaa n(a)=3 |n(a)|=3 → Answer: Option C(✔️)  Question 84 Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?  A Removing left recursion alone B Factoring the grammar alone C Removing left recursion and factoring the grammar D None of the above Compiler-Design Grammar Gate-2003 Question 84 Explanation: D is correct answer, as it is not necessary that if grammar is not having left recursion or left factoring then it is guaranteed to be LL(1). There are so many grammars which is not left recursive as well as do not having left factoring but still they are not LL(1).  Question 85 Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is  A n1 is necessarily less than n2 B n1 is necessarily equal to n2 C n1 is necessarily greater than n2 D None of the above Compiler-Design Parsers Gate-2003 Question 85 Explanation: No. of states in SLR and LALR are equal and no. of states in SLR and LALR are less than or equal to LR(1).  Question 86 In a bottom-up evaluation of a syntax directed definition, inherited attributes can  A always be evaluated B be evaluated only if the definition is L-attributed C be evaluated only if the definition has synthesized attributes D never be evaluated Compiler-Design Syntax-Directed-Translation Gate-2003 Question 86 Explanation: L-Attributed grammar can able to inherits either inherited attributes (or) synthesized attributes. L-Attributed definitions are a class of syntax directed definitions whose attributes can be evaluated by a single traversal of the parse-tree.  Question 87 Which of the following statements is FALSE?  A In statically typed languages, each variable in a program has a fixed type B In un-typed languages, values do not have any types C In dynamically typed languages, variables have no types D In all statically typed languages, each variable in a program is associated with values of only a single type during the execution of the program Compiler-Design Run-Time-Environments Gate-2003 Question 87 Explanation: Dynamic typed languages are those languages in which variable must necessarily be defined before they are used. Then dynamic typed languages have types.  Question 88 Consider the grammar shown below S → i E t S S' | a S' → e S | ε E → b In the predictive parse table. M, of this grammar, the entries M[S', e] and M[S',$] respectively are
 A {S'→e S} and {S'→ε} B {S'→e S} and { } C {S'→ε} and {S'→ε} D {S'→e S, S'→ε} and {S'→ε}
Compiler-Design       Parsers       Gate-2003
Question 88 Explanation:
First(S) = {1,a}
First(S') = {e,ε}
First(E) = {b}
Follow(S') = {e,\$}
Only when 'First' contains ε, we need to consider FOLLOW for getting the parse table entry. Hence, option (D) is correct.
 Question 89
Consider the grammar shown below.
S → C C
C → c C | d
The grammar is
 A LL(1) B SLR(1) but not LL(1) C LALR(1) but not SLR(1) D LR(1) but not LALR(1)
Compiler-Design       Parsers       Gate-2003
Question 89 Explanation: Hence, it is LL(1).
 Question 90
Consider the translation scheme shown below
S → T R
R → + T {print ('+');} R | ε
T → num {print (num.val);}
Here num is a token that represents an integer and num.val represents the corresponding integer value. For an input string '9 + 5 + 2', this translation scheme will print
 A 9 + 5 + 2 B 9 5 + 2 + C 9 5 2 + + D + + 9 5 2
Compiler-Design       Syntax-Directed-Translation       Gate-2003
Question 90 Explanation: Now traverse the tree and whatever comes first to print, just print it.
Answer will be 9 5 + 2 +.
 Question 91
Consider the syntax directed definition shown below.
S → id : = E  {gen (id.place = E.place;);}
E → E1 + E2   {t = newtemp ( ); gen (t = El.place + E2.place;); E.place = t}
E → id     {E.place = id.place;}`
Here, gen is a function that generates the output code, and newtemp is a function that returns the name of a new temporary variable on every call. Assume that ti's are the temporary variable names generated by newtemp. For the statement 'X: = Y + Z', the 3-address code sequence generated by this definition is
 A X = Y + Z B t1 = Y + Z; X = t1 C t1= Y; t2 = t1 + Z; X = t2 D t1 = Y; t2 = Z; t3 = t1 + t2; X = t3
Compiler-Design       Syntax-Directed-Translation       Gate-2003
Question 91 Explanation: Question 92
Which of the following is NOT an advantage of using shared, dynamically linked libraries as opposed to using statically linked libraries?
 A Smaller sizes of executable files B Lesser overall page fault rate in the system C Faster program startup D Existing programs need not be re-linked to take advantage of newer versions of libraries
Compiler-Design       Run-Time-Environments       Gate-2003
Question 92 Explanation:
 Question 93
 A Theory Explanation is given below.
Compiler-Design       Descriptive       Gate-2002
 Question 94
 A 3 B 26 C 10 D 21
Compiler-Design       Compilers       Gate-2000
Question 94 Explanation:
We have six different types of tokens are available
(i) Keyword
(ii) Identifier
(iii) Constant
(iv) Variable
(v) String
(vi) Operator
Print = Token 1
( = Token 2
"i=%d%x" = Token 3 [Anything inside " " is one Token]
, = Token 4
i = Token 5
, = Token 6
& = Token 7
i = Token 8
) = Token 9
; = Token 10
Here, totally 10 Tokens are present in the equation.
 Question 95
Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order.
 A Leftmost derivation B Leftmost derivation traced out in reverse C Rightmost derivation D Rightmost derivation traced out in reverse
Compiler-Design       Parsers       Gate-2000
Question 95 Explanation:
Top-down parser - Leftmost derivation
Bottom-Up parser - Reverse of rightmost derivation
 Question 96
 A * has higher precedence than + B - has higher precedence than * C + and – have same precedence D + has higher precedence than *
Compiler-Design       Grammar       Gate-2000
Question 96 Explanation:
The operator which is in low level that can have high preference.
Order of precedence is *, +, -.
Here * and + have equal preference, '-' can have higher precedence than + and *.
 Question 97
 A Theory Explanation is given below.
Compiler-Design       Descriptive       Gate-2000
 Question 98
Which of the following is the most powerful parsing method?
 A LL (1) B Canonical LR C SLR D LALR
Compiler-Design       Parsers       Gate-1999
Question 98 Explanation:
Canonical LR is most powerful.
LR > LALR > SLR
 Question 99
The number of tokens in the Fortran statement DO 10 I = 1.25 is
 A 3 B 4 C 5 D None of the above
Compiler-Design       Compilers        Gate-1999
Question 99 Explanation:
DO → 1
10 → 2
I → 3
= → 4
1.25 → 5
 Question 100
In a resident – OS computer, which of the following systems must reside in the main memory under all situations?
Compiler-Design       Run-Time-Environments       Gate-1998
Question 100 Explanation:
In many operating system loader is permanently resident in memory.
Some OS may allow virtual memory may allow the loader to be located in a region of memory that is in page table.
 Question 101
Which of the following statements is true?
 A SLR parser is more powerful than LALR B LALR parser is more powerful than Canonical LR parser C Canonical LR parser is more powerful than LALR parser D The parsers SLR, Canonical CR, and LALR have the same power
Compiler-Design       Parsers       Gate-1998
Question 101 Explanation:
LR > LALR > SLR
Canonical LR parser is more powerful than LALR parser.
 Question 102
Type checking is normally done during
 A lexical analysis B syntax analysis C syntax directed translation D code optimization
Compiler-Design       Compilers       Gate-1998
Question 102 Explanation:
Type checking is normally done during syntax directed translation.
 Question 103
 A ‘⊕’ is left associative while ‘*’ is right associative B Both ‘⊕’ and ‘*’ is left associative C ‘⊕’ is right associative while ‘*’ is left associative D None of the above
Compiler-Design       Grammar       Gate-1997
Question 103 Explanation: ⊕ is left associative.
* is right associative.
 Question 104

A language L allows declaration of arrays whose sizes are not known during compilation. It is required to make efficient use of memory. Which one of the following is true?

 A A compiler using static memory allocation can be written for L B A compiler cannot be written for L; an interpreter must be used C A compiler using dynamic memory allocation can be written for L D None of the above
Compiler-Design       Run-Time-Environments       Gate-1997
Question 104 Explanation:
Compiler is use dynamic memory allocation then the memory will be allocated to an array at runtime.
 Question 105
The conditional expansion facility of macro processor is provided to
 A test a condition during the execution of the expanded program B to expand certain model statements depending upon the value of a condition during the execution of the expanded program C to implement recursion D to expand certain model statements depending upon the value of a condition during the process of macro expansion
Compiler-Design       Macros       Gate-1997
Question 105 Explanation:
Macro is expanded during the process of Macro expansion.
 Question 106
Heap allocation is required for languages
 A that support recursion B that support dynamic data structures C that use dynamic scope rules D None of the above
Compiler-Design       Run-Time-Environments       Gate-1997
Question 106 Explanation:
Heap allocation is required for languages that support dynamic data structures.
 Question 107
 A 1, 2, 1, 2 B 2, 1, 2, 1 C 2, 1, 1, 2 D 1, 2, 2, 2
Compiler-Design       Assembler       Gate-1996
Question 107 Explanation:
The functionalities from pass 1 and pass 2 are:
Pass 1:
1) Assign addresses to all statements in the program.
2) Save the values assigned to all labels for use in pass 2.
3) Perform some processing of assembler directives.
Pass 2:
1) Assemble instructions.
2) Generate data values defined by BYTE, WORD etc.
3) Perform processing of assembler directives not done during pass 1.
4) Write the program and assembling listing.
 Question 108
 A (ii) only B (i) only C both (i) and (ii) D None of the above
Compiler-Design       Macros       Gate-1996
Question 108 Explanation:
If M2 macro is called with X=0, then it will go into an infinite loop.
 Question 109
A linker is given object modules for a set of programs that were compiled separately. What information need to be included in an object module?
 A Object code B Relocation bits C Names and locations of all external symbols defined in the object module D Absolute addresses of internal symbols
Compiler-Design       Run-Time-Environments       Gate-1995
Question 109 Explanation:
In object module it includes names and locations of all external symbols defined in the object module.
To link to external symbols it must know the location of external symbols.
 Question 110
 A 23131 B 11233 C 11231 D 33211
Compiler-Design       Parsers       Gate-1995
Question 110 Explanation: ⇒ 23131
Note SR is bottom up parser.
 Question 111
Generation of intermediate code based on an abstract machine model is useful in compilers because
 A it makes implementation of lexical analysis and syntax analysis easier B syntax-directed translations can be written for intermediate code generation C it enhances the portability of the front end of the compiler D it is not possible to generate code for real machines directly from high level language programs
Compiler-Design       Compilers       Gate-1994
Question 111 Explanation:
In Intermediate code optimizations can also enhances the probability of optimizer.
 Question 112
 A (i) - (d), (ii) - (a), (iii) - (b), (iv) - (c)
Compiler-Design       General       Gate-1994
Question 112 Explanation:
Backus Normal Form (BNF) is a notation technique for context free grammars, often used to describe the syntax of languages used in computing.
Yacc (Yet Another Compiler- Compiler) is a computer program for the UNIXoperating system. It is a LALR parser generator, generating a parser, the part of a compiler that tries to make syntactic sense of the source code, specially a LALR parser, based on an analytic grammar. Yacc is written in portable C.
 Question 113
 A The program leads to compile time error B The program leads to run time error C The program outputs 5.2 D The program produces error relating to nil pointer dereferencing E None of the above
Compiler-Design       Compilers       Gate-1993
Question 113 Explanation:
Note: Out of syllabus.
 Question 114
A part of the system software, which under all circumstances must reside in the main memory, is:
 A text editor B assembler C linker D loader E none of the above
Compiler-Design       General       Gate-1993
Question 114 Explanation:
In a program the loader that can loads the object of the program from secondary memory into the main memory to execute the corresponding program. Then the loader is to be resides in the main memory.
 Question 115
Consider the SLR(1) and LALR (1) parsing tables for a context free grammar. Which of the following statements is/are true?
 A The go to part of both tables may be different. B The shift entries are identical in both the tables. C The reduce entries in the tables may be different. D The error entries in the tables may be different. E B, C and D.
Compiler-Design       Parsers       Gate-1992
Question 115 Explanation:
Goto parts and shift entry must be same.
Reduce entry and error entry may be different due to conflicts.
 Question 116
The process of assigning load addresses to the various parts of the program and adjusting the code and date in the program to reflect the assigned addresses is called
 A Assembly B Parsing C Relocation D Symbol resolution
Compiler-Design       Run-Time-Environments       Gate-2001
Question 116 Explanation:
Relocation can change the assigned address of data and code in the program.
 Question 117
Which of the following statements is false?
 A An unambiguous grammar has same leftmost and rightmost derivation B An LL(1) parser is a top-down parser C LALR is more powerful than SLR D An ambiguous grammar can never be LR(k) for any k
Compiler-Design       Parsers       Gate-2001
Question 117 Explanation:
Option B: LL parser is a top-down parser for a subset of context-free languages. It parses the input from Left to right, performing Left most derivation of the sentence.
Option C: LALR is more powerful than SLR.
Option D: An ambiguous grammar can never be LR (k) for any k, because LR(k) algorithm aren’t designed to handle ambiguous grammars. It would get stuck into undecidability problem, if employed upon an ambiguous grammar, no matter how large the constant k is.
 Question 118
 A Theory Explanation is given below.
Compiler-Design       Parsers       Gate-2001
 Question 119
 A Theory Explanation is given below.
Compiler-Design       Syntax-Directed-Translation       Gate-2001
 Question 120
 A Theory Explanation is given below.
Compiler-Design       Grammar       Gate-2001
 Question 121
The arithmetic expression : (a + b) * c - d / e * * f is to be evaluated on a two-address machine, where each operands, the number of registers required to evaluate this expression is ______. The number of memory access of operand is __________.
 A 3 , 4
Compiler-Design       Operands       Gate-1991
Question 121 Explanation:
** is used for exponentiation.
So, in total 3 registers are required and 6 memory operations in total to fetch all operands.
 Question 122
A given set of processes can be implemented by using only parbegin/parend statement, if the precedence graph of these processes is ________
 A properly nested.
Compiler-Design       Precedence-Graph       Gate-1991
Question 122 Explanation:
A given set of processes canf th be implemented by using only parbegin/parends statement, if the presedence graph of these processes is properly nested.
 Question 123
 A matches the parameters of the macro-definition with locations of the parameters of the macro call B matches external names of one program with their location in other programs C matches the parameters of subroutine definition with the location of parameters of subroutine call D acts as link between text editor and the user E acts as a link between compiler and user program.
Question 123 Explanation:
Linked editor can be able to perform
1) external symbol resolution
2) relocation
 Question 124
 A Recursive descent parsing cannot be used for grammar with left recursion. B The intermediate form the representing expressions which is best suited for code optimization is the post fix form. C A programming language not supporting either recursion or pointer type does not need the support of dynamic memory allocation. D Although C does not support call by name parameter passing, the effect can be correctly simulated in C. E No feature of Pascal violates strong typing in Pascal. F A and D
Compiler-Design       Parsers       Gate-1991
Question 124 Explanation:
(A) It is true. Left recursive grammar if used directly in recursive descent parsing causes an infinite loop. So, left recursion must be removed before giving to a recursive descent parser.
(B) False.
(C) It is false. The language can have dynamic data types which required dynamically growing memory when data type size increases.
(D) Is true and using macro we can do this.
(E) Out of syllabus now.
 Question 125
 A (a) - (q), (b) - (r), (c) - (s), (d) - (p)
Compiler-Design       Match-the-Following       Gate-1990
Question 125 Explanation:
Pointer data type - Dynamic data structure
Activation record - Recursion
Repeat until - Non-deterministic loop
Coercion - Type conversion
 Question 126
 A (a) - (s), (b) - (p), (c) - (q), (d) - (r)
Compiler-Design       Match-the-Following       Gate-1990
Question 126 Explanation:
Lexical analysis - Finite automaton
Code optimization - DAG
Code generation - Syntax tree
Abelian groups - Push down automaton
 Question 127
Merging states with a common core may produce __________ conflicts and does not produce ___________ conflicts in an LALR purser.
 A Reduce-Reduce, Shift-Reduce
Compiler-Design       Parsers       Gate-1989
Question 127 Explanation:
Merge states with a common core may produce Reduce-Reduce conflicts and does not produce Shift-Reduce conflicts in an LALR parser.
 Question 128
In a compiler the module the checks every character of the source text is called:
 A The code generator. B The code optimiser. C The lexical analyser. D The syntax analyser.
Compiler-Design       Compilers       GATE-1987
Question 128 Explanation:
Lexical analyzer phase checks every character of text to identify tokens.
 Question 129
An operator precedence parser is a
 A Bottom-up parser. B Top-down parser. C Back tracking parser. D None of the above.
Compiler-Design       Parsers       GATE-1987
Question 129 Explanation:
An operator precedence parser is a Bottom-up parser.
 Question 130
Using longer identifiers in a program will necessarily lead to:
 A Somewhat slower compilation B A program that is easier to understand C An incorrect program D None of the above
Compiler-Design       Compilers       GATE-1987
Question 130 Explanation:
Lexical analyzer will take more time to recognize the longer identifiers.
There are 130 questions to complete.