You are on page 1of 33

1.

In a single pass assembler, most of the forward references can be avoided by putting the restriction
a) On the number of strings/life reacts
b) Code segment to be defined after data segment
c) On unconditional rump
d) None of the mentioned
Answer b

2. The method which merges the bodies of two loops is


a) Loop rolling
b) Loop jamming
c) Constant folding
d) None of the mentioned
Answer b
3. Assembly code data base is associated with
a) Code is converted into assembly.
b) Table of rules in the form of patterns for matching with the uniform symbol table
to discover syntactic structure.
c) All of the mentioned
d) None of the mentioned
Answer: a

4. The process manager has to keep track of


a) Status of each program
b) Information to a programmer using the system
c) Both of the mentioned
d) None of the mentioned
Answer c

5. Function of the syntax phase is to


a) recognize the language and to cal the appropriate action routines that will
generate the intermediate form or matrix for these constructs
b) Build a literal table and an identifier table
c) Build a uniform symbol table
d) Parse the source program into the basic elements or tokens of the language

Answer: A

6 If E be a shifting operation applied to a function f, such that E(f) = f (x +β ), then


a) E (αf+β g) =α E(f) +β E (g)
b) E (αf +β g )=. ( α+ β )+ E (f + g)
c) E (αf +β g )=α E (f+gβ)
d) E (αf +β g )=αβ E (f + g)
Answer a

7. Pass I
a) Assign address to all statements
b) Save the values assigned to all labels for use in pass 2
c) Perform some processing
d) All of the mentioned
ANSWER D

8. Which table is a permanent database that has an entry for each terminal symbol?
a) Terminal Table
b) Literal Table
c) Identifier Table
d) None of the mentioned
ANSWER A

9. Which of the following functions is performed by loader?


a) Allocate memory for the programs and resolve symbolic references between
objects decks
b) Address dependent locations, such as address constants, to correspond to the
allocated space
c) Physically place the machine instructions and data into memory
d) All of the mentioned
ANSWER D

10. The root directory of a disk should be placed


a) At a fixed address in main memory
b) At a fixed location on the disk
c) Anywhere on the disk
d) None of the mentioned
ANSWER B

1. The segment base is specified using the register named is


a) ORG instructions
b) TITLE instruction
c) ASSUME instruction
d) SEGMENT instruction
Answer: a
2. In what module multiple instances of execution will yield the same result even if
one instance has not terminated before the next one has begun?
a) Non usable module
b) Serially usable
c) Re-enter-able
d) None of the mentioned
Answer: C
3. Dividing a project into segments and smaller units in order to simplify design and
programming efforts is called
a) Modular approach
b) Top down approach
c) Bottom up approach
d) Left right approach
Answer: a
4. Which one of the following is the tightest upper bound that represents the time
complexity of inserting an object into a binary search tree of n nodes?
a) O(1)
b) O(long)
c) O(n)
d) O(long)
ANSWER C

5. Which of the following is true for machine language?


a) Continuous execution of program segments
b) Depicting flow of data in a system
c) A sequence of instructions which solves a problem
d) The language which interacts with the computer using only the binary digits 1
and 0
Answer: d

6. Software that measures, monitors, and controls events is


a) System S/w
b) Real Time software
c) Scientific software
d) Business Software
ANSWER B
7. A linker is given object module for a set of programs that were compiled
separately. What is not true about an object module
a) Object code
b) Relocation bits
c) Names and locations of all external symbols denied in the object module
d) Absolute addresses of internal symbols
Answer: d

8. The table created by lexical analysis to describe all literals used in the source
program is
a) Terminal table
b) Literal table
c) Identifier table
d) Reductions
Answer: b

9. Which loader function is accomplished by loader?


a) Reallocation
b) Allocation
c) Linking
d) Loading
ANSWER D

10. Which is not true about syntax and semantic parts of a computer language?
a) Semantics is checked mechanically by a computer
b) Semantics is the responsibility of the programmer
c) All of the mentioned
d) None of the mentioned
Answer: d
2. Which of the following statement is true?
a) SLR powerful than LALR
b) LALR powerful than Canonical LR parser
c) Canonical LR powerful than LALR parser
d) The parsers SLR= Canonical LR=LALR
ANSWER Answer: c

3. Which of the following features cannot be captured by CFG ?


a) Syntax of if-then-else statements
b) Syntax of recursive procedures
c) A variable is declared before its use
d) Matching nested parenthesis
Answer: d

5. In which of the following no information hiding is done?


a) Compile prig 1, prig 2
b) Run test, prog
c) Load R1 , A
d) 001001000010101

ANSWER D

6. The graph that shows basic blocks and their successor relationship is called
a) Dag
b) Flow Graph
c) Control Graph
d) Hamilton Graph
Answer: b

7. The specific task storage manager performs


a) Allocation/ deal location of programs
b) Protection of storage area assigned to the program
c) Both of the mentioned
d) None of the mentioned
ANSWER C

8. When a computer is rebooted, a special type of loader is executed called


a) Compile and GO ” loader
b) Boot loader
c) Bootstrap Loader
d) Relating Loader

Answer: c

9. Disadvantage of ” Compile and GO ” loading scheme is that


a) Memory is wasted because the case occupied by the assembler is unavailable to
the object program
b) Necessary to translate the users program
c) It is very difficult to handle multiple segments, even when the source programs are
in different languages and to produce orderly modular programs
d) All of the mentioned
ANSWER D

10. Function of the storage assignment is


a) Assign storage to all variables referenced in the source program
b) Assign storage to all temporary locations that are necessary for intermediate
results
c) Assign storage to literals, and to ensure that the storage is allocated and
appropriate locations are initialized
d) All of the mentioned
ANSWER D

11. A non relocatable program is the one which


a) Cannot execute in any area of storage other than the one designated
b) Consists of a program and information for its relocation
c) None of the mentioned
d) All of the mentioned

Answer: a

12. A relocatable program form is one which


a) Cannot execute in any area of storage other than the one designated
b) Consists of a program and information for its relocation
c) None of the mentioned
d) All of the mentioned

Answer: c

3. A self-relocating program is one which


a) Cannot execute in any area of storage other than the one designated
b) Consists of a program and information for its relocation
c) None of the mentioned
d) All of the mentioned

Answer: c

4. Scissoring enables
a) A part of data to be displayed
b) Entire data to be displayed
c) Full data display on full screen
d) No data to be displayed

Answer: a

5. Which of the following can be accessed by transfer vector approach of linking?


a) External data segments
b) External sub-routines
c) Data located in other procedure
d) All of the mentioned

Answer: b

6. Relocation bits used by relocating loader are specified by


a) Relocating loader itself
b) Linker
c) Assembler
d) Macro processor

Answer: b

7. Generation of intermediate code based on a abstract machine model is useful in


compilers because
a) Implementation of lexical analysis and syntax analysis is made easier
b) Writing for intermediate code generation
c) Portability of the front end of the compiler
d) None of the mentioned

ANSWER A

8. Which of the following module does not incorporate initialization of values changed by
the module?
a) Non reusable module
b) Serially reusable module
c) Re-enterable module
d) All of the mentioned

Answer: a

9. An intermediate code form is


a) Postfix Notation
b) Syntax Trees
c) Three address
d) All of the mentioned

Answer: d

10. The best way to compare the different implementations of symbol table is to compare
the time required to
a) Add a new name
b) Make an enquiry
c) Add a new name and make an enquiry
d) All of the mentioned

ANS D

1. Dynamic linking can cause security concerns because


a) Security is dynamic
b) None of the mentioned
c) Both of the mentioned
d) Cryptographic procedures are not available for dynamic linking
ANSWER D
2. Which of the following statements is FALSE?
a) Both of the mentioned
b) In up-typed languages, values do not have any types
c) Dynamic languages have no variables types
d) None of the mentioned
Answer: c

3. S -> C C
C -> eC | 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)
Answer: c

4. S -> id: = E ”
newtemp ();
gen(t . place . place;); .place t} ”
.place .place;}
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 + t2; X = t3
Answer d

5. If the programming language uses static scoping and call by need parameter passing
mechanism, the values printed by the above program are
a) 115, 220
b) 25, 220
c) 25, 15
d) 115, 105
Answer d

6. If dynamic scoping is used and call by name mechanism is used, the values printed
will be
a) 115, 220
b) 25, 220
c) 25, 15
d) 115, 105
Answer b

7.

P x =new Q();
Q y =new Q();
P z =new Q();
x. f (1);((P) y). f (1);
z.f(1);

The output is
a) 1 2 1
b) 2 1 1
c) 2 1 2
d) 2 2 2

Answer:d
7. Which of the following is NOT an advantage of using shared, dynamically linked
libraries as compared to statically linked libraries?
a) Smaller sizes of executable
b) Lesser overall page fault rate in the system
c) Faster program start-up
d) Existing programs need not be re-linked to take advantage of newer versions of
libraries
Answer c

8. Which grammar violate rules of an operator grammar?


(i) P-> QR
(ii) P -> Q s R
(iii) P -> ε
(iv) P ->Q t
a) (i) only
b) (i) and (iii) only
c) (ii) and (iii) only
d) (iii) and (iv) only

Answer: b

9. Consider the grammar rule


E -> E1 − E2 for arithmetic expressions.
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 of evaluation of E1 and E2 is of no consequence

Answer: b

1. 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
Answer: a

2. Consider the grammar


E ->E + n | E # n | n
For a sentence n + n, 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
Answer d

3. S -> (S)| a
Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar n1
n2 and n3 respectively.
a) n1 < n2 < n3
b) n1 = n3 < n2
c) n1 = n2 = n3
d) n1 $ n3 $ n2

Answer b

Int main()
{ int 1,N;
Fro (I,1 N,1);
}
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

Answer c

4. 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
Answer: c

5. 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 ‘x’ 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

Answer: B

6. 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 ” ε}
Answer : A
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 these

Answer c

Here id is a taken 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 + *

Answer b

10. Consider the following C code segment.


for if i # i } } }
Which one to the following false?
a) The code contains loop-in variant computation
b) There is scope of common sub-expression elimination in this code
c) There is scope strength reduction in this code
d) There is scope of dead code elimination in this code

Answer d

1. Consider the following two statements:


P: Every regular grammar is LL(1)
Q: Every regular set has 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
Answer a

2. In a simplified computer the instructions are:


OP R j , Ri − Performs Rj OP Ri and stores the result in register Ri
OP m, Ri − Performs val OP Ri abd stores the result in Ri. value
denotes the content of memory location m.
MCVm, Ri −Moves the content off memory loction m to register Ri .
MCVm, Ri , m −Moves the content of register Ri to memory location m.
The computer has only two registers, and OP is either ADD or SUB. Consider the
following basic block:
t1 = a + b
t2 = c + d
t 3 = e − t2
t 4 = t 1 − t2
Assume that all operands are initially in memory. The final value of the
computation should be in memory. What is the minimum number of MOV
instructions in the code generated for this basic block?
a) 2
b) 3
c) 5
d) 6

Answer b

3. S->bA S->aB
A->a B->b
A->aS B->bS
A->bAA B->aBB
Which of the following strings is generated by the grammar?
a) aaaabb
b) aabbbb
c) aabbab
d) abbbba

Answer c

4. S->bA S->aB
A->a B->b
A->aS B->bS
A->bAA B->aBB

how many derivation trees are there?


a) 1
b) 2
c) 3
d) 4
answer b
5. 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 a 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

Answer d

6. Some code optimizations are carried out on the intermediate code because
a) They enhance the portability of the complier to other target processors
b) Program analysis is name accurate on intermediate code than on machine
code
c) The information from data flow analysis cannot otherwise be used for
optimization
d) The information from the front end cannot otherwise be used for optimization

Answer: b

7. Which of the following are true?


(i) A programming language option does not permit global variables of any king
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/function
(iii) Recursion in programming languages cannot be implemented with dynamic
storage allocation
(iv) Nesting of procedures/functions and recursion require a dynamic heap
allocation scheme and cannot be implemented with a stack-based allocation
scheme for activation records
(v) 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)
d) (ii), (iii) and (v) only

Answer a

8. An LALR(1) parser for a grammar 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

Answer: b

9. Which of the following statements are TRUE ?


I There exist parsing algorithms for some programming languages hose complex
are less than θ(n 3 )
II A programming language which allows recursion can be implemented with
static storage allocation
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

Answer: b

10. What data structure in a complier is used for managing information about
variables and their attributes?
a) Abstract syntax tree
b) Symbol table
c) Semantic stack
d) Parse table

Answer: b
1. Which languages necessarily need heap allocation in the runtime
environment?
a) Those that support recursion
b) Those that use dynamic scoping
c) Allow dynamic data structure
d) Those that use global variables

Answer: c
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?

Ans n-1

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.

Ans 1, 2, 3, and 4

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.
Answer A

Consider the date same as above question. The appropriate entries for E1, E2, and E3

are

Answer C

The grammar S → aSa | bS | c is


Answer Both LL(1)and LR(1)

Match all items in Group 1 with correct options from those given in Group 2.
Group 1 Group 2
P. Regular expression 1. Syntax analysis
Q. Pushdown automata 2. Code generation
R. Dataflow analysis 3. Lexical analysis
S. Register allocation 4. Code optimization

Answer

P-3, Q-1, R-4, S-2

Which of the following statements are TRUE?


I. There exist parsing algorithms for some programming languages
whose complexities are less than O(n3).
II. A programming language which allows recursion can be implemented
with static storage allocation.
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.

Answer I and IV

Which of the following describes a handle (as applicable to LR-parsing) appropriately?


Answer

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

An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
Answer the LR(1) parser for G has S-R conflicts

Which one of the following is a top-down parser?


Answer Recursive descent parser.

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

Answer it is ambiguous

Consider the following two statements:


P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Answer P is false and Q is true

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?
None of the above

A canonical set of items is given below


S --> L. > R
Q --> R.

Answer neither a shift-reduce nor a reduce-reduce conflict.

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

+ is right associative, while ∗ is left associative

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.
Answer {S → FR} and {R → ε }

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

Answer 2 3 4+*

The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar is
Answer ambiguous

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
Answer n, E + n and E × n

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

Answer n1 = n3 < n2

Consider the following expression grammar. The semantic 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?

Answer It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce
action

Consider the following expression grammar. The semantic 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?
Answer Equal precedence and right associativity; expression is evaluated to 9

Which of the following grammar rules violate the requirements of an operator grammar
? P, Q, R are nonterminals, and r, s, t are terminals.
1. P → Q R
2. P → Q s R
3. P → ε
4. P → Q t R r

Answer 1 and 3 only

Consider the grammar with the following translation rules and E as the start symbol.
E → E1 # T { E.value = E1.value * T.value }
| T{ E.value = T.value }
T → T1 & F { T.value = T1.value + F.value }
| F{ T.value = F.value }
F → num { F.value = num.value }
Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.

Answer 160
Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

Answer None of these

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:
Answer n1 is necessarily equal to n2

In a bottom-up evaluation of a syntax directed definition, inherited attributes can


Answer be evaluated only if the definition is L-attributed

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
{S' → e S, S'→ ε} and {S' → ε}

Consider the grammar shown below.


S → C C
C → c C | d
The grammar is
Answer LL(1)

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

Answer 9 5 + 2 +

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

Answer t1 = Y + Z; X = t1

Which of the following statements is false?


Answer An unambiguous grammar has same leftmost and rightmost derivation
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.
Answer Leftmost derivation

Given the following expression grammar:


E -> E * F | F + E | F
F -> F - F | id
which of the following is true?
Answer – has higher precedence than *

Which one of the following is True at any valid state in shift-reduce parsing?
Answer The stack contains only a set of viable prefixes

In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the
following is True?

Answer The maximum number of successors of a node in an AST and a CFG depends on the
input program

Match the following:


List-I List-II
A. Lexical analysis 1. Graph coloring
B. Parsing 2. DFA minimization
C. Register allocation 3. Post-order traversal
D. Expression evaluation 4. Production tree
Codes:
A B C D
(a) 2 3 1 4
(b) 2 1 4 3
(c) 2 4 1 3
(d) 2 3 4 1
Answer C
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?

Answer SLR, canonical LR

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 G.

Answer Neither S1 and S2

Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A}

and terminals {a, b}}. Using the above SDTS, the output
printed by a bottom-up parser, for the input aab is
Answer 2 3 1
Which one of the following grammars is free from left recursion?

Answer B

A CFG G is given with the following productions where S is the start symbol, A is a non-terminal
and a and b are terminals.
S→aS∣A
A→aAb∣bAa∣ϵ
For the correct answer in Q75, how many steps are required to derive the string and how many
parse trees are there?

Answer 6 and 1

Which of the following is the most powerful parsing method?


Answer Canonical LR

Which of the following statement is true?


Answer Canonical LR parser is more powerful than LALR parser.

Type checking is normally done during


Syntax directed translation
In the following grammar
X :: = X ⊕ Y / Y
Y :: = Z * Y / Z
Z :: = id
Which of the following is true? a. '⊕' is left associative while '*' is right associative b.
Both '⊕' and '*' are left associative c. '⊕' is right associative while '*' is left associative.

Answer a

Which of the following is essential for converting an infix expression to the postfix from efficiently
?
Answer An operator stack

The grammar whose productions are


<stmt> → if id then <stmt>
<stmt> → if id then <stmt> else <stmt>
<stmt> → id := id
is ambiguous because a) the sentence if a then if b then c:= d has two parse trees b)
the left most and right most derivations of the sentence if a then if b then c:= d give rise
to different parse trees c) the sentence if a then if b then c:= d else c:= f has more than
two parse trees d) the sentence if a then if b then c:= d else c:= f has two parse trees
answer D

Consider the following grammars (S1) :


A --> aBCD
B --> bc|c
C --> d|∈
D -> b
(S2) :
A --> aBCD
B --> bc|∈
C --> d|c
D -> b
(S3) :
A --> aBCD
B --> bc|∈
C --> d|∈
D -> b
(S4) :
A --> aBCD
B --> bc|c
C --> d|c
D -> b

Answer

Only (S1), (S3) and (S2), (S4)

All of the above.

Which one of the following statements is FALSE?

Answer Type checking is done before parsing

Consider the following parse tree for the expression a#b$c$d#e#f, involving two binary
operators $ and #.
Answer $ has higher precedence and is left associative; # is right associative

Which of the following statements is/are TRUE ? (i) The grammar S → SS | a is


ambiguous (where S is the start symbol). (ii) The grammar S → 0S1 | 01S | e is
ambiguous (the special symbol e represents the empty string and S is the start symbol).
(iii) The grammar (where S is the start symbol).
S → T/U
T → x S y ? xy ? e
U → yT
generates a language consisting of the string yxxyy.

All of (i), (ii) and (iii) are TRUE

Match the description of several parts of a classic optimizing compiler in List - I, with the names
of those parts in List -
II:

Answer (1)
Consider the following statements related to compiler construction : I. Lexical Analysis is
specified by context-free grammars and implemented by pushdown automata. II. Syntax
Analysis is specified by regular expressions and implemented by finite-state machine. Which of
the above statement(s) is/are correct ?

Answer Neither I nor II

Which of the following statement(s) regarding a linker software is/are true ? I A function of a
linker is to combine several object modules into a single load module. II A function of a linker is
to replace absolute references in an object module by symbolic references to locations in other
modules.
Answer Only I

Given the following expression grammar:


E → E ∗ F ∣ F + E ∣ F
F → F − F ∣ id
Which of the following is true?
Answer - has higher precedence than *

Which grammar rules violate the requirement of the operator grammar? A, B, C are
variables and a, b, c are terminals
1) A → BC
2) A → CcBb
3) A → BaC
4) A → ε
Answer 1 and 4 only

Yacc stands for


Answer yet another compiler compiler

Shift reduce parsing belongs to a class of


Answer bottom up parsing
Which of the following productions eliminate left recursion in the productions given below: S →
Aa | b A → Ac | Sd | ε
Answer S → Aa | b A → A' | bdA', A' → cA' | adA' | ε

Which one from the following is false?

A parsing algorithm which performs a left to right scanning and a right most deviation is RL (1)

Which phase of compiler generates stream of atoms?


Answer Syntax Analysis

Shift-Reduce parsers perform the following:


Answer Shift step that advances in the input stream by one symbol and Reduce step that
applies a completed grammar rule to some recent parse trees, joining them together as one tree
with a new root symbol.

Which of the following is true?

Canonical LR parser is LR (1) parser with single look ahead terminal


ANSWER ------------Both (A) and (B)

In a two-pass assembler, symbol table is


Answer Generated in first pass

How many tokens will be generated by the scanner for the following statement ? x = x ∗ (a + b)
– 5;
Answer 12

Incremental-Compiler is a compiler

Answer compiles only those portion of source code that have been modified.

DU-chains(Definition-Use) in compiler design


Answer All of the above
A bottom-up parser generates:

Answer Right-most derivation in reverse

You might also like