Computer Science and Information Technology - Compiler Design
Exam Duration: 45 Mins Total Questions : 30
A top-down parser generates
- (a)
left most derivation
- (b)
right most derivation
- (c)
right most derivation in reverse
- (d)
left most derivation in reverse
Shift reduce parser are
- (a)
top-down parsers
- (b)
bottom-up parsers
- (c)
top-down or bottom-up parsers
- (d)
None of the above
Which of the following is incorrect ?
- (a)
L-attributed definitions are class of syntax directed definitions whose attributes can always be evaluated in depth first order.
- (b)
Every S attributed definition is L attributed
- (c)
A syntax directed definition is L attributed if each inherited attributed of Xj, \(1 \le j \le \) n, on the right side of A \(\rightarrow\)X1X2, .....Xa, depends only on the inherited attributed of A
- (d)
All of the above
Which is a permanent database in the general model of compiler ?
- (a)
Literal table
- (b)
Identifier table
- (c)
Terminal table
- (d)
Reductions
Back patching is useful for handling
- (a)
conditional jumps
- (b)
unconditional jumps
- (c)
backward references
- (d)
forward references
Which of the following immediate code representative is suitable for optimizing compiler ?
(i) Quadruples
(ii) Triples
(iii) Indirect triples
- (a)
(i), (ii) and (iii)
- (b)
(i) and (iii)
- (c)
(iii) and (ii)
- (d)
(i) and (ii)
In which type of loader, the assembler run in one part of memory and place the assembled machine unstructions and data as they are assembled directly into assigned memory location ?
- (a)
Compile and go loader
- (b)
general loader
- (c)
Absolute loader
- (d)
None of these
Which of the following system programs for going to the production of object code to generate absolute machine code and load into the physical main storage location from which it will be executed immediately upon completion of the assembly ?
- (a)
Two-pass assembler
- (b)
Load and go assembler
- (c)
Microprocessor
- (d)
Compiler
In analyzing the compilation of PL/l program, the term 'machine independent optimization' is associated with
- (a)
recognition of basic syntactic construction through reductions
- (b)
recognition of basic elements and creation of uniform symbols
- (c)
creation of more optimal matrices
- (d)
use of macroprocessor to produce more optimal assembly code.
In analyzing the compilation of PL/l program, the description 'created of more optimal matrix' is associated aith
- (a)
assembly and output
- (b)
code generation
- (c)
syntax analysis
- (d)
machine indepedent optimization
Operator precedence parsing method is parsing method. Which of the following statements is felse about it ?
1. It is bottom-up parsing method.
2. It must conain \(\epsilon \) - production
3. It doesn't contain two adjacent non-terminal symbols.
- (a)
1 only
- (b)
2 only
- (c)
3 only
- (d)
1 and 3
Which of the following derivations does a top-down parser, use while parsing as input string ? The input is assumed to be scanned in left to right order.
- (a)
Left most derivetion
- (b)
Left most derivetion traced out in reverse
- (c)
Right most derivation
- (d)
Right most derivation traced out in reverse
Generation of intermediate code based on a abstract machine model is useful in compiler 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 languages programs
A compiler which allows only the modified section of the source code to be recompiled is called as
- (a)
incremental compiler
- (b)
reconfigurable compiler
- (c)
dynamic compiler
- (d)
subjective compiler
Pick the machine independent phase(s) of the compiler.
- (a)
Syntax analysis
- (b)
Lexical analysis
- (c)
Intermediate code generation
- (d)
All of the above
The value of K, in LR (K) cannot be
- (a)
0
- (b)
1
- (c)
2
- (d)
None of these
Which of the following is the most general phase structured grammar ?
- (a)
Regular
- (b)
Context tree
- (c)
Context sensitive
- (d)
None of the above
A grammar will be meaningless
- (a)
if terminal set and non-terminal set are not disjoint
- (b)
if the left handside of a production has a single terminal
- (c)
if the left handside of a production has no non-terminal
- (d)
All of the above
Consider the following left associative operators, in decreasing order of precedence :
- subtraction (highest precedence)
* multiplication
$ exponentiation (lowest precedence)
What is the result of the following expression ?
3 - 2 * 4 $ 2 $ 3
- (a)
-61
- (b)
64
- (c)
512
- (d)
4096
Consider the following C fragment :
for (int x = 0 ; x <=n ; x+ +)
Which type of error detected by the C compiler for the above code ?
- (a)
Lexical error
- (b)
Syntactic error
- (c)
Semantic error
- (d)
Logical error
Consider the grammar :
S \(\rightarrow \) (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 \(\ge \) n3 \(\ge \) n2
A garbage is
- (a)
unallocated storage
- (b)
allocated storage with all access paths to its destroyed
- (c)
allocated storage
- (d)
uninitialized storage
If w is a string of terminals and A, B are the non-terminals, then which of the following are right linear grammars ?
- (a)
A \(\rightarrow \) Bw
- (b)
A \(\rightarrow \) Bw \(|\) w
- (c)
A \(\rightarrow \) wB \(|\) w
- (d)
None of these
Consider the following statements :
S1 : The set of string described by a rule is called pattern associated with the token.
S2 : A lexeme is a sequence of character in the source program that is matched by pattern for a token.
Which of the above statements is/are true ?
- (a)
Both S1 and S2 are true
- (b)
S1 is true S2 is false
- (c)
S2 is true S1 is false
- (d)
Both S1 and S2 are false
Which one of the following is valid ssumption prior to code ganeration ?
(i) Prior to code genaration, the front end has scanned, parsed and translated the source program into a reasonably detaied intermediate representation.
(ii) The necessary type checking has taken place
(iii) The input is free from errors.
- (a)
(i), (ii) and (iii)
- (b)
(ii) and (iii)
- (c)
(i) and (iii)
- (d)
(i) and (ii)
In case of symbol table, we need to be able to
(i) determine whether a given name is in the tble
(ii) add a new name to the table
(iii) add new information for a given name
(iv) delete a name or group of names from the table
- (a)
(i), (ii), (iii) and (iv)
- (b)
(ii), (iii) and (iv)
- (c)
(iii) and (iv)
- (d)
(i), (iii) and (iv)
Match the List I with List II and select the correct answer using the codes given below the lists.
List I | List II |
A. MIN (A, 2* (3 + B) | Insertion errors |
B. D0 10, l = 1, 100 | 2. Replacement errors |
C. l = 1: J = 2 ; | 3. Transposition errors |
4. Deletion errors |
- (a)
A B C 4 1 2 - (b)
A B C 2 2 3 - (c)
A B C 2 3 1 - (d)
A B C 4 2 4
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
Consider the following step of shift-reduce parser.
Stack | Input |
$$ | $ |
Then , in this configuration the parser
- (a)
halts
- (b)
announces successful completion of parsing
- (c)
Both (a) and (b)
- (d)
Neither (a) nor (b)
Consider the CFG with {S, A, B} as the non-terminal alphabets, {a, b} as the terminal alphebets, S as the start symbol and the following set of production rules
S \(\rightarrow \) bA S \(\rightarrow \) aB
A \(\rightarrow \) a B \(\rightarrow \) b
A \(\rightarrow \) aS B \(\rightarrow \) bS
S \(\rightarrow \) bAA B \(\rightarrow \) aBB
How many derivation trees are there ?
- (a)
1
- (b)
2
- (c)
3
- (d)
4