Compiler Mcqs Last Updated Solved Complete
Compiler Mcqs Last Updated Solved Complete
A. 2
B. 3
C. 4
D. 5
2. A fragment of code that resides in the loop and computes the same value at each iteration is called a?
A. Induction analysis
B. Strength reduction
C. loop-invariant code
3. A variable is called an _________ variable if its value is altered within the loop by a loop-invariant
value.
A. Invariant
B. induction
C. strength
D. loop
4. Dead code plays no role in any program operation and therefore it can simply be eliminated.
A. TRUE
B. FALSE
A. local optimization
B. loop optimization
C. constant folding
A. loop optimization
B. local optimization
D. constant folding
7. In analyzing the compilation of PL/I program, the term Machine independent optimization is
associated with
8. Before generating intermediate code, the compiler can modify the intermediate code by address
calculations and improving loops.
A. TRUE
B. FALSE
D. Cannot say
9. The compiler can make use of memory hierarchy and CPU registers.
A. TRUE
B. FALSE
D. Cannot say
10. A compiler for a high-level language that runs on one machine and produces code for a different
machine is called
A. optimizing compiler
C. cross compiler
D. multipass compiler
1. In how many types parsing is divided?
A. 2
B. 3
C. 4
D. 5
2. When the parser starts constructing the parse tree from the start symbol and then tries to transform
the start symbol to the input, it is called?
A. bottom-up parsing
B. top-down parsing
C. Both A and B
3. In ___________________, if one derivation of a production fails, the syntax analyzer restarts the
process using different rules of same production
A. Bottom-up Parsing
C. Backtracking
4. A form of recursive-descent parsing that does not require any back-tracking is known as?
A. predictive parsing
B. non-predictive parsing
C. recursive parsing
D. non-recursive parsing
5. Compute E.value for the root of the parse tree for the expression:2 # 3 & 5 # 6 &4.
A. 40
B. 80
C. 120
D. 160
6. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.
A. n1 is necessarily less than n2
B. n1 is necessarily equal to n2
7. the predictive parser puts some constraints on the grammar and accepts only a class of grammar
known as LL(k) grammar.
A. TRUE
B. FALSE
9. Which of the following derivations does a top-down parser use while parsing an input string?
A. Leftmost derivation
C. Rightmost derivation
10. Relocation is the process of replacing symbolic references or names of libraries with actual usable
addresses in memory before running a program.
A. TRUE
B. FALSE
A. first
B. second
C. third
D. fourth
A. remove whitespace
B. removing comments
A. it generates an exception
B. it generates an warning
C. it generates an error
4. When the lexical analyzer read the source-code, it scans the code?
A. line by line
B. word by word
C. letter by letter
5. Which tool/computer program for generating lexical analyzers (scanners or lexers) written by Vern
Paxson in C around 1987?
A. FLEX
B. GLEX
C. CLEX
D. SLEX
Ans : A
Explanation: FLEX (fast lexical analyzer generator) is a tool/computer program for generating lexical
analyzers (scanners or lexers) written by Vern Paxson in C around 1987.
6. The function ________ is automatically generated by the flex when it is provided with a .l file
A. flex()
B. yylex()
C. lex()
D. nnlex()
7. In the input file, In which section Anything written in this brackets is copied directly to the file
lex.yy.c?
A. Rules Section
B. Definition Section
A. %%
B. $$
C. %%%%
D. $$$$
A. Linear list
B. Search tree
C. Hash Table
D. Self Organisation
10. System program such a compiler are designed so that they are ________
A. Re-enterable
B. Non-Usable
C. Serially usable
D. None of the above
A. 2
B. 3
C. 4
D. 5
A. non-terminals
B. terminal symbols
C. productions
D. start symbol
C. Both A and B
A. Derivation Tree
B. Analyzers Tree
C. Parse Tree
D. Ambiguity Tree
A. terminals
B. non-terminals
C. sub-terminals
D. half-terminals
A. 2
B. 3
C. 4
D. 5
8. When the parser starts constructing the parse tree from the start symbol and then tries to transform
the start symbol to the input, it is called?
B. Backtracking
C. Top-down Parsing
D. Bottom-up Parsing
A. Lexical Analysis
B. Syntax Analysis
D. Code generation
C. Symbol table is created by the compiler which contains the list of lexemes or tokens.
A. Type mismatch
B. Undeclared variable
A. Domain grammer
B. Attribute grammar
C. Object grammar
D. Value grammer
4. Semantic analyzer attaches attribute information with AST, which are called?
A. Analyzer attribute
B. Attributed AST
C. Analyzer AST
D. AST
5. Which attributes get values from the attribute values of their child nodes?
A. Synthesized attributes
B. Inherited attributes
C. S-attributed SDT
D. L-attributed SDT
6. Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values
from right siblings?
A. T-attributed SDT
B. A-attributed SDT
C. S-attributed SDT
D. L-attributed SDT
A. T-attributed SDT
B. A-attributed SDT
C. S-attributed SDT
D. R-attributed SDT
A. Scope resolution
B. Type checking
C. Array-bound checking
B. Logical connectives
C. Semantics
1. Which of the following known as the text part of a program that does not change at runtime. Its
memory requirements are known at the compile time?
A. Code
B. Procedures
C. Variables
A. TRUE
B. FALSE
C. A procedure has a start with delimiter but not end with delimiter.
D. A procedure has a not start with delimiter but end with delimiter.
3. In activation record, Which of the following Stores the address of activation record of the caller
procedure?
A. Access Link
B. Actual Parameters
C. Control Link
D. Temporaries
4. Whenever a procedure is executed, its activation record is stored on the stack, also known as?
A. Access Stack
B. Control stack
C. Formal Stack
D. Return Stack
5. _________ are known at the runtime only, unless they are global or constant.
A. values
B. Object
C. Variables
A. r-value
B. k-value
C. l-value
D. t-value
C. Variables whose values or addresses are being passed to the called procedure are called Formal
Parameter.
8. In which mechanism, the calling procedure passes the r-value of actual parameters and the compiler
puts that into the called procedure’s activation record?
A. Pass by Reference
B. Pass by Name
C. Pass by Copy-restore
D. Pass by Value
9. In which mechanism, the name of the procedure being called is replaced by its actual body?
A. Pass by Reference
B. Pass by Name
C. Pass by Copy-restore
D. Pass by Object
7 = x + y;
A. l-value error
B. r-value error
C. Infinite loop
D. Both A and B
2. ___________ is a tool that depicts the structure of basic blocks, helps to see the flow of values
flowing among the basic blocks, and offers optimization too.
A. DAG
B. CAG
C. SAG
D. PAG
Explanation: Directed Acyclic Graph (DAG) is a tool that depicts the structure of basic blocks, helps to
see the flow of values flowing among the basic blocks, and offers optimization too.
A. identifiers
B. names
C. constants
A. a
B. INC a
C. DEC a
D. MUL a
C. Strength reduction
D. Code Generator
void add_ten(int x)
return x + 10;
B. Unreachable code
7. How many descriptors are used for track both the registers (for availability) and addresses (location of
values) while generating the code?
A. 2
B. 3
C. 4
D. 5
8. __________ are used to keep track of memory locations where the values of identifiers are stored.
A. Register descriptor
B. Address descriptor
C. Both A and B
9. Code generator uses ______ function to determine the status of available registers and the location
of name values.
A. setReg
B. cinReg
C. pfReg
D. getReg
B. 3-address code
B. 3
C. 4
D. 5
A. Low-Level Language
B. Middle-Level Language
C. High-Level Language
D. Decimal-Format
A. assembler
B. compiler
C. interpreter
D. linker
4. A compiler that runs on platform (A) and is capable of generating executable code for platform (B) is
called ?
A. cross-compiler
B. complex-compiler
C. object-compiler
D. post-compiler
5. Which of the following is used to link all the parts of the program together for execution?
A. loader
B. linker
C. memory
D. preprocessor
A. Interpreter
B. Assembler
C. Loader
D. Preprocessor
A. Yes
B. No
C. Depends on compiler
D. Don't know
A. terminate program
B. stops execution
D. give warning
A. terminate program
B. stops execution
D. give warning
A. data file
B. task file
C. object file
D. program file
B. Transition function
A. Square
B. Circle
C. Double Circle
D. Rhombus
A. States
B. Start state
C. Intermediate states
D. Transition
A. 1
B. 2
C. 3
D. 4
5. In Final state, The number of odd arrows are one greater than even, i.e. odd = even+1?
A. TRUE
B. FALSE
A. 3
B. 4
C. 5
D. 6
A. 0
B. 1
C. 2
D. 3
8. Languages of a automata is
A. If it halts
B. If it is accepted by automata
A. Type 0
B. Type 1
C. Type 2
D. Type 3
A. regular language
B. regular grammar
C. regular notations
D. regular operation
A. regular language
B. regular grammar
C. regular notations
D. regular operation
A. LM = {st | s is in L and t is in M}
B. L+M
C. L*M
D. L U M = {s | s is in L or s is in M}
4. Concatenation (.) has the ________ highest precedence
A. first
B. second
C. third
D. fourth
View Answer
A. *
B. |
C. plus(+)
D. .
6. The RE in which any number of 0′s is followed by any number of 1′s followed by any number of 2′s is?
A. (0+1+2)*
B. 0*1*2*
C. 0* + 1 + 2
D. (0+1)*2*
7. Which of the following is NOT the set of regular expression R = (ab + abb)* bbab?
A. ababbbbab
B. abbbab
C. ababbabbbab
D. abababab
8. Consider the production of the grammar S->AA A->aa A->bb Describe the language specified by the
production grammar.
A. L = {aaaa,aabb,bbaa,bbbb}
B. L = {abab,abaa,aaab,baaa}
C. L = {aaab,baba,bbaa,bbbb}
D. L = {aaaa,abab,bbaa,aaab}
9. If R is regular language and Q is any language (regular/ non regular), then Pref (Q in R) is
_____________
A. Non-regular
B. Equal
C. Infinite
D. Regular
10. The non terminal that gives null will said to have a null production
A. TRUE
B. FALSE
Implicit conversion
Coercions
both a and b
None of the above
_____________________________________________________________________________________
Syntax directed translation scheme is desirable because
Hardware
Compiler
Registers
None of the above
_____________________________________________________________________________________
Inherited attribute is a natural choice in
Dominators
Reducible graphs
Depth first ordering
All of these
_____________________________________________________________________________________
Reduction in strength means
cannot be made to execute in any area of storage other than the designated for it at the time of its coding
or translation
Consists of a program and relevant information for its relocation
Can itself perform the relocation of its address sensitive protions
All of the above
_____________________________________________________________________________________
The lexical analyzer takes_________as input and produces a stream of_______as output.
Source program,tokens
Token,source program
Either A and B
None of the above
_____________________________________________________________________________________
Intermediate code generation phase gets input from
Lexical analyzer
Syntax analyzer
Semantic analyzer
Error handling
_____________________________________________________________________________________
A grammar is meaningless
linker
loader
compiler
assembler
_____________________________________________________________________________________
Which of the following is used for grouping of characters into tokens?
Parser
Code optimization
Code generator
Lexical analyzer
_____________________________________________________________________________________
Whether a given pattern constitutes a token or not depends on the
Source language
Target language
Compiler
All of these
_____________________________________________________________________________________
A optimizing compiler
Hash table
Search tree
Self organizing list
Linear list
_____________________________________________________________________________________
Three address code involves
Exactly 3 address
At most most 3 address
No unary operators
None of these
_____________________________________________________________________________________
A
B
C
D
_____________________________________________________________________________________
A compiler is
A program that place program into memory and prepares them for execution
A program that automates the translation of assembly language into machine language
program that accepts program written in high level language and produces an object program
A program that appears to execute a source program as if it were machine language
_____________________________________________________________________________________
In a bottom up evaluation of a syntax direction definition ,inherited attributes can
Always be evaluated
Be evaluated only if the definition is L -attributed
Be evaluated only if the definition has synthesized attributes
None of the above
_____________________________________________________________________________________
Which of the following actions an operator precedence parser may take to recover from an error ?
DAG
Flow chart
Control graph
Hamiltonian graph
_____________________________________________________________________________________
Generation of intermediate code based on a abstract machine model is useful in compilers because
It is simple ti implement
It never gets into an infinite loop
Both A and B
None of these
_____________________________________________________________________________________
In operator precedence parsing , precedence relations are defoned
Postfix notation
Syntax trees
Three address code
All of these
_____________________________________________________________________________________
Code can be optimized at
A
B
C
D
_____________________________________________________________________________________
Pee hole optimization
Loop optimization
Local optimization
Constant folding
Data flow analysis
_____________________________________________________________________________________
In which way(s) a macroprocessor for assembly language can be implemented ?
Optimizing compiler
One pass compiler
Cross compiler
Multipass compiler
_____________________________________________________________________________________
Which of the following is used for grouping of characters into tokens (in a computer)
A parser
Code optimizer
Code generator
Scanner
_____________________________________________________________________________________
Local and loop optimization in turn provide motivation for
Application software
A system software
A hardware component
All of the above
_____________________________________________________________________________________
Which of the following is the most powerful parser?
SLR
LALR
Canonical LR
Operator precedence
_____________________________________________________________________________________
Which of the following are language processors?
Assembler
Compilers
interpreters
All of these
_____________________________________________________________________________________
Relocating bits used by relocating loader are specified by
LL grammar
Ambiguous grammar
LR grammar
None of the above
_____________________________________________________________________________________
A compiler that runs on one machine and produces code for a different machine is called
Cross compilation
One pass compilation
Two pass compilation
None of the above
_____________________________________________________________________________________
_________or scanning is the process where the stream of characters making up the source program is read from left to right and
grouped into tokens.
Lexical analysis
Diversion
Modeling
None of the above
_____________________________________________________________________________________
Input to code generator
Source code
Intermediate code
Target code
All of the above
_____________________________________________________________________________________
In analysis the compilation PL/I program the description Create of more optimal matrix is associated with
re-allocation
allocation
linking
loading
If conversion from one type to another type is done automatically by the compiler then,it is
called
Implicit conversion
coercions
both a and b
None of the above
Hardware
Compiler
Registers
None of the above
Dominators
Reducible graphs
Depth first ordering
All of these
cannot be made to execute in any area of storage other than the designated for it at the time of its
coding or translation
Consists of a program and relevant information for its relocation
Can itself perform the relocation of its address sensitive protions
All of the above
The lexical analyzer takes_________as input and produces a stream of_______as output.
Source program,tokens
Token,source program
Either A and B
None of the above
Lexical analyzer
Syntax analyzer
Semantic analyzer
Error handling
A grammar is meaningless
linker
loader
compiler
assembler
Parser
Code optimization
Code generator
Lexical analyzer
Source language
Target language
Compiler
All of these
A optimizing compiler
Hash table
Search tree
Self organizing list
Linear list
______________________________________________________________________________
_______
Three address code involves
Exactly 3 address
At most most 3 address
No unary operators
None of these
______________________________________________________________________________
_______
A
B
C
D
______________________________________________________________________________
_______
A compiler is
A program that place program into memory and prepares them for execution
A program that automates the translation of assembly language into machine language
program that accepts program written in high level language and produces an object program
A program that appears to execute a source program as if it were machine language
______________________________________________________________________________
_______
In a bottom up evaluation of a syntax direction definition ,inherited attributes can
Always be evaluated
Be evaluated only if the definition is L -attributed
Be evaluated only if the definition has synthesized attributes
None of the above
______________________________________________________________________________
_______
Which of the following actions an operator precedence parser may take to recover from an
error ?
DAG
Flow chart
Control graph
Hamiltonian graph
______________________________________________________________________________
_______
Generation of intermediate code based on a abstract machine model is useful in compilers
because
It is simple ti implement
It never gets into an infinite loop
Both A and B
None of these
______________________________________________________________________________
_______
In operator precedence parsing , precedence relations are defoned
Postfix notation
Syntax trees
Three address code
All of these
______________________________________________________________________________
_______
Code can be optimized at
Loop optimization
Local optimization
Constant folding
Data flow analysis
______________________________________________________________________________
_______
In which way(s) a macroprocessor for assembly language can be implemented ?
Optimizing compiler
One pass compiler
Cross compiler
Multipass compiler
______________________________________________________________________________
_______
Which of the following is used for grouping of characters into tokens (in a computer)
A parser
Code optimizer
Code generator
Scanner
______________________________________________________________________________
_______
Local and loop optimization in turn provide motivation for
Application software
A system software
A hardware component
All of the above
SLR
LALR
Canonical LR
Operator precedence
Assembler
Compilers
interpreters
All of these
Cross compilation
One pass compilation
Two pass compilation
None of the above
_________or scanning is the process where the stream of characters making up the source
program is read from left to right and grouped into tokens.
Lexical analysis
Diversion
Modeling
None of the above
Input to code generator
Source code
Intermediate code
Target code
All of the above
In analysis the compilation PL/I program the description Create of more optimal matrix is
associated with
re-allocation
allocation
linking
loading
41.
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∣ϵ
a. 3
b. 26
c. 10
d. 21
d. dataflow analysis
3. 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?
d. Turing Machine
4. 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. 2^n
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?
a. 1 only
b. 2 only
c. 1 and 4 only
d. 1, 2, 3, and 4
7. Match all items in Group 1 with correct options from those given in Group 2.
Group 1 Group 2
I. There exist parsing algorithms for some programming languages whose complexities are less than
O(n^3).
II. A programming language which allows recursion can be implemented with static storage allocation.
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
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
10. An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
c. An LR(k) parser
d. An LALR(k) parser
12. 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
a. it is left recursive
b. it is right recursive
c. it is ambiguous
d. It is not context-free
S -> S * E
S -> E
E -> F + E
E -> F
F -> id
(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)
S --> L. > R
Q --> R.
16. 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
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 { }
d. {F → id} and {R → ε}
a. 2*3+4
b. 2 * +3 4
c. 23*4+
d. 2 3 4+*
19. 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
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
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
22. Consider the following expression grammar. The seman-tic rules for expression calculation are
stated next to each grammar production.
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?
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
23. Consider the following expression grammar. The seman-tic rules for expression calculation are
stated next to each grammar production.
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?
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
24. 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
a. 1 only
b. 1 and 3 only
c. 2 and 3 only
d. 3 and 4 only
25. Consider the grammar with the following translation rules and E as the start symbol.
| T{ E.value = T.value }
| F{ T.value = F.value }
Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.
a. 200
b. 180
c. 160
d. 40
26. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
d. None of these
27. 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:
b. n1 is necessarily equal to n2
d. none of these
a. always be evaluated
b. be evaluated only if the definition is L--attributed
d. never be evaluated
29. 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
b. {S' → e S} and {}
S→CC
C→cC|d
The grammar is
a. LL(1)
S→TR
R → + T {print ('+');} R | ε
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. 95+2+
c. 952++
d. ++952
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
34. 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
c. Rightmost derivation
E -> E * F | F + E | F
F -> F - F | id
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
37. 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 to 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 in AST and CFG corresponds to at most one statement in the input program
List-I List-II
Codes:
ABCD
(a) 2 3 1 4
(b) 2 1 4 3
(c) 2 4 1 3
(d) 2 3 4 1
39. 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
d. LALR, canonical LR
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.
a. Only S1
b. Only S2
c. Both S1 and S2
d. Neither S1 and S2
41.For the correct answer in Q75, how many steps are required to derive the string and how many parse
trees are there?
a. 6 and 1
b. 6 and 2
c. 7 and 2
d. 4 and 2
42. Some code optimizations are carried out on the intermediate code because
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
a. A basic block is a sequence of instructions where control enters the sequence at the beginning
and exits at the end
c. increase the chances of reusing the machine-independent code optimizer in other compilers
45. 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
1. i = 1
2. j = 1
3. t1 = 5 * i
4. t2 = t1 + j
5. t3 = 4 * t2
6. t4 = t3
7. a[t4] = –1
8. j = j + 1
9. if j <= 5 goto(3)
10. i = i + 1
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively,
are
a. 5 and 7
b. 6 and 7
c. 5 and 5
d. 7 and 8
x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;
The minimum number of total variables required to convert the above code segment to static single
assignment form is
a. 6
b. 8
c. 9
d. 10
48. Which of the following derivations does a top-down parser use while parsing an input string?
a. Leftmost derivation
c. Rightmost derivation
50. 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
a. Only (I)
d. None of these
a. Context-free grammar can be used to specify both lexical and syntax rules.
53. A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b
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 mat
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
54. Match the description of several parts of a classic optimizing compiler in List - I, with the names of those parts
a. (1)
b. (2)
c. (3)
d. (4)
a. A parse tree
b. Intermediate code
c. Machine code
d. A stream of tokens
56. The number of tokens in the following C statement is printf("i=%d, &i=%x", i&i);
a. 13
b. 6
c. 10
d. 9
57. A particular BNF definition for a "word" is given by the following rules. Which of the following lexical entries ca
I. pick
II. picks
III. c44
a. I, II and III
b. I and II only
58. For the grammar below, a partial LL(1) parsing table is also presented along with the grammar. Entries that ne
ε is the empty string, $ indicates end of input, and, | separates alternate right hand sides of productions.
a. A
b. B
c. C
1. compiler work, source code into____?.
A. Machine code
B. Executable code
C. Binary code
D. Both B and C
E. Both A and C
A. 11
B. 31
C. 4
D. 10
E. none of these
a) Unambiguous
b) Ambiguous
c) Both A and B
d) None of these
A. Machine code
B. Binary code
C. tokens
D. Both A and B
E. None of these
A. 6
B. 8
C. 2
D. 3
E. None of these
A. ECL
B. TTL
C. Both A and B
D. None of these
A. Syntax error
B. Logical error
A. syntax
B. testing
C. lexiacal
D. Both A and C
E. None of these
A. semantic
B. lexical
C. syntax
D. Both A and B
A. Parsing
B. Analysing
C. Translating
D. All of these