Instruction
- Total number of questions : 20
- Time allotted : 30:00 Minutes:Seconds.
- Each question carry 1 mark, no negative marks.
- DO NOT refresh the page.
- All the best
Compiler Design [ Question No: 1 To 20 ] :
A machine that sets condition codes as a side effect of arithmetic allows the generator to
The activation record for a procedure typically holds
Instruction scheduling and register allocation interact because
Alias analysis is described as conservative when it
Constant folding is the transformation that
A chained symbol table implementation searches
Match each phase with what it does to the symbol table.
List I
A. lexical analysis
B. semantic analysis
C. code generation
D. optimisation
List II
1. reads the storage offset assigned
2. installs the name and its lexeme
3. consults attributes to decide on transformations
4. records the type and checks declarations
A three address instruction of the form x = y + z is best described as
The reason compilers restrict themselves to L-attributed definitions is
A translation scheme in which every action appears at the right end of its production corresponds to
At every point during a successful shift reduce parse, the stack together with the remaining input forms
Assertion (A): Grammar transformations for LL parsing preserve the language but not the parse trees.
Reason (R): Left recursion elimination replaces left recursion with right recursion, which leans the tree the other way.
The number of lookahead tokens used by an LL(k) parser is
A useless nonterminal in a grammar is one that
The Thompson construction converts
Compilation time and quality of generated code are related in that
When a scope is exited, the symbol table entries for that scope are
Dead code elimination removes
A cross compiler is one that
The loader is responsible for
Total number of questions : 20
Number of answered questions : 0
Number of unanswered questions : 20
Compiler Design [ Question No: 1 To 20 ] :
A machine that sets condition codes as a side effect of arithmetic allows the generator to
Your Answer : (Not Answered)
Correct Answer : A
If the flags already reflect the value, the comparison is redundant. Tracking the state of the condition codes is a small but worthwhile part of a good back end. The saving is one instruction per comparison, which adds up inside a loop.
The activation record for a procedure typically holds
Your Answer : (Not Answered)
Correct Answer : A
Its layout is fixed by the calling convention and the compiler. Locals are addressed as offsets from a frame pointer or from the stack pointer directly. Recursion is exactly why a local cannot be given a fixed address.
Instruction scheduling and register allocation interact because
Your Answer : (Not Answered)
Correct Answer : C
A longer schedule keeps more values live at once and so needs more registers, which may force spilling. Doing allocation first instead constrains the schedule that can be produced. Some compilers interleave the two rather than choosing an order.
Alias analysis is described as conservative when it
Your Answer : (Not Answered)
Correct Answer : C
Assuming distinctness without proof would produce wrong code. Reporting a possible alias costs an optimisation, which is the acceptable side on which to err. Type based rules let compilers rule out some aliases without any analysis.
Constant folding is the transformation that
Your Answer : (Not Answered)
Correct Answer : C
Correct answer: works out at compile time the value of an expression built from literals
Constant folding evaluates \( 3 \times 4 \) to 12 during compilation. It is distinct from constant propagation, which replaces a variable by a constant known to be in it - the two are almost always run together, each exposing further opportunities for the other.
A chained symbol table implementation searches
Your Answer : (Not Answered)
Correct Answer : B
Following the chain outward realises the most closely nested rule directly. A failed lookup at every level means the name is undeclared and an error is reported. A placeholder entry is then usually installed to suppress repeated messages.
Match each phase with what it does to the symbol table.
List I
A. lexical analysis
B. semantic analysis
C. code generation
D. optimisation
List II
1. reads the storage offset assigned
2. installs the name and its lexeme
3. consults attributes to decide on transformations
4. records the type and checks declarations
Your Answer : (Not Answered)
Correct Answer : D
Each phase touches the table for its own purpose, writing what it knows and reading what an earlier phase recorded. Because the one structure is shared across the whole compiler, its design has to satisfy every one of those needs at once rather than being tuned for any single phase.
A three address instruction of the form x = y + z is best described as
Your Answer : (Not Answered)
Correct Answer : D
Correct answer: a binary assignment naming a destination and two operands
The form is called three address because it names three: the result and the two operands. Every complex expression is broken down into a sequence of such instructions with temporaries linking them, which is what makes the representation simple enough to optimise and to translate.
The reason compilers restrict themselves to L-attributed definitions is
Your Answer : (Not Answered)
Correct Answer : D
The restriction buys a guarantee of cheap evaluation. It is a limitation in principle, but in practice almost every translation a compiler needs can be written within it. The exceptions are unusual enough to be worth restructuring the grammar for.
A translation scheme in which every action appears at the right end of its production corresponds to
Your Answer : (Not Answered)
Correct Answer : B
Actions at the end can only use values already computed, which means only synthesised attributes. This is exactly the postfix translation scheme that a bottom up parser implements naturally. Anything more elaborate requires markers or an explicit tree.
At every point during a successful shift reduce parse, the stack together with the remaining input forms
Your Answer : (Not Answered)
Correct Answer : A
This invariant is what the whole method rests on. Each reduction moves backward one step along a rightmost derivation, so the concatenation of stack and input is always a right sentential form until the start symbol alone remains.
Assertion (A): Grammar transformations for LL parsing preserve the language but not the parse trees.
Reason (R): Left recursion elimination replaces left recursion with right recursion, which leans the tree the other way.
Your Answer : (Not Answered)
Correct Answer : D
Correct answer: Both A and R are true, and R is the correct explanation of A
Both are true and the reason gives the mechanism. Eliminating left recursion produces a grammar deriving the same strings but building right-leaning trees where the original built left-leaning ones. The language is preserved and the structure is not, which is exactly why associativity has to be restored by other means.
The number of lookahead tokens used by an LL(k) parser is
Your Answer : (Not Answered)
Correct Answer : A
Larger k accepts more grammars, but the table grows roughly exponentially in k. Most practical tools use one token, sometimes with special handling for a few awkward constructs. The special cases are usually documented alongside the grammar itself.
A useless nonterminal in a grammar is one that
Your Answer : (Not Answered)
Correct Answer : A
Correct answer: derives no terminal string or is unreachable from the start symbol
Either fault makes the nonterminal contribute nothing to the language: one that derives no terminal string can never complete a derivation, and one unreachable from the start symbol can never begin one. Both are removed before parsing, since they only complicate the tables and can mask genuine errors in the grammar.
The Thompson construction converts
Your Answer : (Not Answered)
Correct Answer : B
Correct answer: a regular expression into a nondeterministic finite automaton
Thompson’s construction builds an NFA piece by piece from the structure of the expression, giving each operator - union, concatenation, closure - a small fixed pattern of states joined by epsilon transitions. The result is nondeterministic; the subset construction is the separate step that makes it deterministic, and minimisation a third.
Compilation time and quality of generated code are related in that
Your Answer : (Not Answered)
Correct Answer : C
Correct answer: more thorough optimisation generally costs more compilation time
Optimisation requires analysis, and the more thorough analyses are expensive - data flow over the whole flow graph, interprocedural work, repeated passes as one transformation exposes another.
That is precisely why compilers expose levels rather than a single setting: a developer compiling repeatedly wants speed, and a release build can afford minutes. The relationship is a trade, not an independence, and certainly not the inverse the last option suggests.
When a scope is exited, the symbol table entries for that scope are
Your Answer : (Not Answered)
Correct Answer : B
Correct answer: removed or hidden so the enclosing declarations become visible again
A name declared in an inner scope must cease to be visible when that scope ends, and any outer declaration it concealed must become visible again.
The usual implementation is a stack of scopes, pushed on entry and popped on exit, or a chain of entries per name from which the innermost is unlinked. The entries may survive if debugging information needs them, but they are removed from the visible set - which is what scope means.
Dead code elimination removes
Your Answer : (Not Answered)
Correct Answer : A
Correct answer: code whose results are never used or that cannot be reached
Dead code is of two kinds and the option names both: unreachable code, which no path can arrive at, and code whose computed results are never subsequently used.
Commented-out text never reaches the compiler at all, having been removed by the scanner. Code after a return within a block is one instance of unreachability rather than the whole of the definition, and a procedure called once is a candidate for inlining, not for removal.
A cross compiler is one that
Your Answer : (Not Answered)
Correct Answer : B
Correct answer: runs on one machine and produces code for a different machine
A cross compiler executes on a host machine and emits code for a different target. It is the normal arrangement for embedded work, where the target may have no operating system, little memory and no development tools at all.
It is also how a new architecture is bootstrapped: the first compiler for it must run somewhere else. Nothing about it produces universal code, translates between source languages, or handles multiple languages at once.
The loader is responsible for
Your Answer : (Not Answered)
Correct Answer : A
Correct answer: placing the executable in memory and adjusting relocatable addresses
The loader operates at run time, not build time. It reads the executable, allocates memory, copies the image in and adjusts any addresses that depend on where it was placed.
Combining object modules is the linker's work, done earlier; macro expansion is the preprocessor's, done earlier still; and type checking belongs to the compiler's semantic analysis. The loader is the last stage of the chain and the only one that runs each time the program is started.
Marks
Total number of questions : 20
Number of answered questions : 0
Number of unanswered questions : 20