- Compiler Design MCQ
Compiler translates the source code to
Both B and C
4Which of the following groups is/are token together into semantic structures?
Lexical analyzer
3Compiler should report the presence of __________ in the source program, in translation process.
Errors
3What is the output of lexical analyzer?
A list of tokens
2How many parts of compiler are there?
2
2Grammar of the programming is checked at _______ phase of compiler.
Syntax analysis
2_________ is a process of finding a parse tree for a string of tokens.
Parsing
1What is the action of parsing that translates the source program into proper syntactic classes?
Lexical analysis
1Compiler can check ________ error.
Syntax
2Lexical analysis is about breaking a sequence of characters into
Tokens
4________ is considered as a sequence of characters in a token.
Lexeme
3What is the name of the process that determining whether a string of tokens can be generated by a grammar?
Parsing
4A _________ is a software utility that translates code written in higher language into a low level language.
Compiler
2Task of a compiler is to
Translate the whole program to machine language
2In a computer system, number of compilers for a particular programming language may be
Many
4Natural language constructs are
May be Unambiguous or ambiguous
3Minimum number of states required to accept string with substring 110, where ∑={0,1}
4
1Languages of an automata is
If it is accepted by automata
1The basic limitation of finite automata is that
It can’t remember arbitrary large amount of information.
1Which phase of compiler does NOT use symbol table?
None of the other options
4Which phase of compiler is Syntax Analysis?
Second
2Output of the syntax analysis is called
Parse tree
1Output file of Lex is _____ the input file is Myfile
Myfile.yy.c
2A regular expression represents
Constituent strings of a language
3When expression sum=3+2 is tokenized then what is the token category of 3
Integer literal
3For the Fortran language statement “DO 5 I = 1.25” returns token IDENTIFIER for DO 5 I after looking upto
.
3Which of the following are Lexemes?
All of the mentioned
4Which of the following is an application of Finite Automaton?
All of the mentioned
4The maximum number of transition which can be performed over a state in a DFA? ∑= {a, b, c}
3
3NFA, in its name has ’non-deterministic’ because of :
The choice of path is non-deterministic
2Consider the following statements about the context free grammar G = {S → SS, S → ab, S → ba, S → Ε} I. G is ambiguous II. G produces all strings with equal number of a’s and b’s III. G can be accepted by a deterministic PDA. Which combination below expresses all the true statements about G?
I and III only
2Consider 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?
aabbab
3S -> aSa|bSb|a|b; The language generated by the above grammar over the alphabet {a,b} is the set of
All odd length palindromes
2The grammar {E -> E + E | E * E | id} is
Ambiguous
1Which of the following are always unambiguous
Producing one left-most and one right-most derivation
1A grammar with production rules { A-> Ba | Cb, B ->CA, C -> c | ε} contains
Left recursion
2For the grammar rules {S -> Aa | bB, A -> c |^}, FIRST(S) is
{a,b, c}
3A grammar that produces more than one parse tree for some sentence is called as
Ambiguous
1_______ is the most general phase structured grammar.
Context sensitive
1Find the language generated by S-> aSa | b
Same number of a's with a 'b' in center
2Which is not a part of a grammar production ?
Temporaries
1The following notation denotes _________ G=(V, T, P, S)
Context free grammar
2Derivation produced by a top-down parser is
Leftmost
1Derivation produced by a bottom-down parser is
Rightmost derivation in reverse
2For top-down parsing left recursion removal is
Mandatory
1A grammar is ambiguous if
More than one left most derivations exist
2A predictive parser
Needs backtracking
1In shift-reduce parsing, handle is at
Top of the stack
1Construction of parsing table in which strategies do not need the Follow set?
Canonical LR and LALR
2Amount of look ahead in LALR parser is
1
1Which of the following pairs is the most powerful
Canonical LR
2What is the similarity between LR, LALR and SLR
Use same algorithm, but different parsing table.
1In how many types parsing is divided?
2
1When 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?
top-down parsing
2In __________, if one derivation of a production fails, the syntax analyzer restarts the process using different rules of same production
Backtracking
3A form of recursive-descent parsing that does not require any back-tracking is known as?
predictive parsing
1Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.
n1 is necessarily equal to n2
2The predictive parser puts some constraints on the grammar and accepts only a class of grammar known as LL(k) grammar.
1Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
None of the above
4Which of the following derivations does a top-down parser use while parsing an input string?
Leftmost derivation
1What is true about Syntax Directed Definitions?
CFG + Semantic rules = Syntax Directed Definitions
3Which of the following error is expected to recognize by semantic analyzer?
All of the above
4____________ is a medium to provide semantics to the context-free grammar
Attribute grammar
2Semantic analyzer attaches attribute information with AST, which are called?
Attributed AST
2Which attributes get values from the attribute values of their child nodes?
Synthesized attributes
1Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?
L-attributed SDT
4If an SDT uses only synthesized attributes, it is called as?
S-attributed SDT
3Which of the following tasks should be performed in semantic analysis?
All of the above
4What is meant by compositional semantics?
Determining the meaning
1What is true about Attribute Grammar?
All of the above
4Errors are
human made programming mistakes
2Static errors are detected at
compile time
1The output of LR(1) Parser is
parse tree
2Dynamic errors are detected at
run time
2Error recovery actions in a lexical analyzer is
panic mode
1Deleting extra characters is _________ type of error recovery
panic mode
1Transposing adjacent character is __________ type of error recovery
panic mode
1The output of LL Parser is
parse tree
2Inserting missing symbol is ________ type of error recovery.
panic mode
1Replacing incorrect character by a correct character is _______ type of error recovery.
panic mode
1Writing productions for possible errors is ________ type of error recovery
error productions
3Use of global variables to define error occurrence is _________ type of error recovery method.
global correction
4A good error handler must
should recover from each error quickly
1The output of LR(0) Parser is
parse tree
2A good error handler must
not significantly slow down the processing of the correct program
2A program without syntax errors but with incorrect output is an example for
logical error
2Errors that are caused because of improper understanding of the rules of the programming language is called
sytax error
1Errors that are caused because of lack of idea of the solution is called
logical error
2A parser detects an error when
there is no legal move from current configuration
3which of the following is an example of semantic error?
type mismatch of operands
2The load instruction is mostly used to designate a transfer from memory to a processor register known as _______
Accumulator
1The specific task storage manager performs
both 1 and 2
4When a computer is first turned on or restarted, a special type of absolute loader is executed called
Boot strap loader
3Function of the storage assignment is
all of these
4A non relocatable program is the one which
cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation
1A relocatable program form is one which
can be processed to relocate it to a desired area of memory
3A self-relocating program is one which
can itself perform the relocation of its address sensitive portions
3The best way to compare the different implementations of symbol table is to compare the time required to
all of these
4Which 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?
Code
1A procedure has a start and an end delimiter and everything inside it is called the body of the procedure.
1In activation record, Which of the following Stores the address of activation record of the caller procedure?
Control Link
3Whenever a procedure is executed, its activation record is stored on the stack, also known as?
Control stack
2What is true about Formal Parameters?
These variables are declared in the definition of the called function.
1For maximum speed of execution of target code , temporary variables be best allocated to
CPU registers
3In which mechanism, the calling procedure passes the r-value of actual parameters and the compiler puts that into the called procedure’s activation record?
Pass by Value
4In which mechanism, the name of the procedure being called is replaced by its actual body?
Pass by Name
2In Directed Acyclic Graph, Leaf nodes represent?
All of the above
4__________ are used to keep track of memory locations where the values of identifiers are stored.
Address descriptor
2Choose the statement which is incorrect with respect to dynamic memory allocation.
Execution of the program is faster than that of static memory allocation
3Dynamic memory allocation is implemented using --------
Stacks and heaps
4The memory for variable is allocated before the execution of a program is called------allocation.
static
1In--------allocation,a memory can be allocated or deallocated at arbitrary points during its execution.
program controlled
4In --------memory allocation, storage is allocated at run-time i.e. memory binding are established and destroyed during the execution of a program.
dynamic
1Which of the following is drawback of static allocation strategy?
All of the above
4Which field is not present in activation record?
Register allocation
2Which is not part of runtime memory subdivision?
Access link
4Which language necessarily need heap allocation in the run time environment?
Those that support recursion
1Which of the following expression have no l-value?
3
3The size field of activation record can be determined at-----------
Compile time
2Which of the following symbol table implementation makes efficient use of memory?
Hash table
3Which one of the following is FALSE?
x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination
4One of the purposes of using intermediate code in compilers is to-----
increase the chances of reusing the machine-independent code optimizer in other compilers
3Which one of the following is false?
There is scope of dead code elimination in this code
4Consider 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
E2 should be evaluated first
2In compiler terminology reduction in strength means-----
replacing a costly operation by a relatively cheaper one
4Substitution of values for names (whose values are constants) is done in----------
Constant folding
3Which of the following comment about peep-hole optimization is true?
It is applied to small part of the code and applied repeatedly
1Which of the following statements about peephole optimization is False?
It can be applied to the portion of the code that is not contiguous
4The identification of common sub-expression and replacement of run time computations by compile-time computations is------
Constant folding
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.
DAG
1Code optimization is responsibility of--------
System programmer
2Dead-code elimination in machine code optimization refersto -----------
Removal of values that never get used.
2Which of the following statement is false?
Flow graph is used to represent DAG.
1The -------- is the final phase of compiler.
Code generation
2Substitution of values for names (whose values are constants) is done in----------
Constant folding
3Which of the following comment about peep-hole optimization is true?
It is applied to small part of the code and applied repeatedly
1Graph used to represent semantic network is ----
Directed graph
2Structure preserving transformations on basic blocks are
All the above
4The graph that shows basic blocks and their successor relationship is called
Flow graph
2Relocation bits used by relocating loader are specified by
linker
2In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction ?
Replace P * 32 by P < < 5
2Substitution of values for names (whose values are constants like pi= 3.14) is done in
Constant folding
3In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.
Loop jamming
4Loop unrolling is a code optimization technique:
That avoids tests at every iteration of the loop.
1Dead-code elimination in machine code optimization refers to :
Removal of values that never get used.
2Some code optimizations are carried out on the intermediate code because
5x * 2 can be replaced by x << 1 is an example of?
Strength reduction
3The__________ are used to keep track of memory locations where the values of identifiers are stored.
Address descriptor
2Which of the following is not a form of Intermediate representation?
Directed cyclic Graph
3A fragment of code that resides in the loop and computes the same value at each iteration is called a?
loop-invariant code
3Question Statement - mandatory (statement delivered to the candidate)
Correct choice - mandatoryA compiler is defined as
Part of system software
1Suppose there is a compiler for C language that can generate code for Computer A. Which of the following statements is true
It can be used only for computers with similar processor and operating system
3Which of the following data structures may be good if there are frequent search for data items followed by insertion and deletion?
Hash Table
4Task of an interpreter is to
Translate one statement at a time and execute it
2If an Infinite language is passed to Machine M, the subsidiary which gives a finite solution to the infinite input tape is ______________
Compiler
1Finite automata requires minimum _______ number of stacks.
0
2A programming language does not allow integer division operation. This is generally detected in the phase of
Semantic Analysis
3Which of these is not true about Symbol Table
Perform the processing of the assembler directives
3A compiler can check
Syntax error
2Error recovery helps to
Report multiple errors
1Loops are the major targets for optimization since
Loop body is repeated to several times
2For maximum speed of execution of target code , temporary variables be best allocated to
CPU registers
3Intermediate code helps in
Retargeting code
3The sum of minimum and maximum number of final states for a DFA n states is equal to:
n+1
1A Language for which no DFA exist is a________
Non-Regular Language
2The maximum sum of in degree and out degree over a state in a DFA can be determined as:______ where ∑= {a, b, c, d}
depends on the Language
4A regular expression for accepting strings with exactly one 1 more than 0’s is
Not Possible
4Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*
The set of all strings containing at least two 0’s.
3Finite automata is an implementation of
Regular expression
1The automation which allows transformation to a new state without consuming any input symbols:
NFA
1Which of the following conflicts is not possible in shift-reduce parsing
Shift-shift conflict
3Which one of the following is true at any valid state in shift-reduce parsing
Stack contains only viable prefixes
3For the grammar S → AB | C A → bA | a B → abbS | bS | ε C → bC | ε Follow(A) is
a , b , $
2Shift reduce parsers are
Bottom up Parser
2In Operator Precedence parsing handle is
Between <· and ·>
3By considering the rule B → abbS, which of the precedence relations between a and b can be inferred?
a ≐ b and b≐ b
2An operator-precedence parser is a
All the other options
4For the grammar rule B → abbS | bS, Firstop(B) equals
{a , b , S}
3For the grammar A → BCx | y B → yA | ε C → Ay | x In Predictive Parsing table the cell having multiple entries is
M[B, y]
3Bottom up parsing involves
Both shift reduce and handle pruning
4For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is
C → .cC; c,d
3For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is
C → .d; c,d
3In SLR parsing to get a shift-reduce conflict for state I on terminal symbol ‘a’,
A -> α.β with First(β) containing ‘a’ should be in I and A ->δ. be in I with Follow(A) having ‘a’
3In state I we have the items A -> α. and B -> δ., First(A), Follow(A) and Follow(B) contains the symbol ‘a’. This leads to
Reduce – reduce conflict
2Between SLR, Canonical LR and LALR, which have same number of states
SLR and LALR
1In SLR parsing for the grammar E' → E E → aEbE | bEaE | ε In state 0, for inputs 'a' and 'b'
Both will have shift-reduce conflict
1In SLR parsing for the grammar S → B | SabS B → bB | ε In state 0, for inputs 'a' and 'b'
Only 'a' will have shift-reduce conflict
2A can be A-> derivable if and only if __________
A-> A is actually a production
1The context free languages are closed under:
Kleene
3Which of the following strings do not belong the given regular expression? (a)*(a+cba)
acbacba
4Error handling and recovery is done by _________ phase
semantic
3Error recovery is
resume program execution after taking corrective actions
2Which is not a error recovery strategies in syntax analysis phase
error correction
3Error recovery is not possible in _____ type of grammar
None of the mentioned
4What is the index number of the last element of an array with 29 elements?
28
2What is meaning of the following? int *ptr[20];
Array of integer pointer of size 20
3Synthesized attribute can be easily simulated by a
LR grammar
3Intermediate code generation phase gets input from
Semantic analyzer
3Which is not true about syntax and semantic parts of a computer language?
None of the mentioned
4Intermediate code helps in
Retargeting code
3Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?
L-attributed SDT
4What value does the variable z have after ALL of the code above executes? int x; int y; int z; x=3; y=4; z = ++x * y++;
16
3What is the max no. of dimensions an array may have?
No limit
4An intermediate code form is
All of these
4Type checking is normally done during-----------
Syntax directed translation
3Three address code generated temporary name are made up for the __________ of the syntax tree.
Interior node
1Expressions that govern the flow of control that may be Boolean expressions containing_________ and _________ operators.
Relational & logical
2Listing pointers to triples, rather than listing triples themselves is implementation of
Indirect Triple
3_____________creates a new symbol table & returns a pointer to the new table.
mktable(previous)
1___________creates a new entry for procedure name in the symbol table pointed to by table
enterproc(table, name, new table)
4Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?
p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4
2In which storage allocation strategy size is required at compiler time?
Static allocation
1Which of the following fields are of activation record?
All of the above
4A _______tree is used to depict the way control enters and leaves activations
Activation
1In activation tree each node represent---------
Activation of a procedure
2In activation tree each root represent--------
Activation of main program
1In activation trees the node for a is the parent of node for b if and only if--------
If control flows from activation of a to b
2In activation trees, the node for a is to the left of node for b if and only if--
If lifetime of a occurs before lifetime of b
1Flow of control in a program corresponds to which traversal of activation tree?
Depth first traversal
1A(n)--------can be used to keep track of live procedure activations
Control stack
3If the occurrence of name in procedure is in the scope of declaration within the procedure then it is said to be------
Local
1Information needed by execution of a procedure is managed using a contiguous block of storage called-----
Both A and B
3In activation record, optional control link points to------
Activation record of caller
1The field of actual parameter in activation record is used by which procedure-----------
Called procedure
2Consider an assignment statement like a[i]:=a[j] then here a[i] represent------and a[j] represent-------
Storage location and value
2In which allocation, names are bound to storage as program is compiled-----
Stack
3Call by reference also called as----
Both A and B
3Triple is a record structure with three fields-------
op, arg1, arg2
1One of the purposes of using intermediate code in compilers is to---------
increase the chances of reusing the machine-independent code optimizer in other compilers
3Which one of the following is not type of intermediate code representations?
Preorder
3Consider the intermediate code given below: 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 11. if i < 5 goto(2) The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are------
6 and 7
2Consider the following source code : c = a + b d = c c = c – e a = d – e b = b * e b = d/b Which of the following is correct optimization of given code?
None of the above
4Consider the code segment int i, j, x, y, m, n; n=20; for (i = 0, i < n; i++) { for (j = 0; j < n; j++) { if (i % 2) { x + = ((4*j) + 5*i); y += (7 + 4*j); } } } m = x + y; Which one of the following is false.
There is scope of dead code elimination in this code
4Peephole optimization is form of------
Local optimization
2Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?
p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4
2Some code optimizations are carried out on the intermediate code because------
They enhance the portability of the compiler to other target processors
1In compiler terminology reduction in strength means-----
replacing a costly operation by a relatively cheaper one
4Match 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
2 4 1 3
3Consider the following C code segment.for (i = 0, i<n; i++) { for (j=0; j<n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } }} Which one of the following is false?
There is scope of dead code elimination in this code
4The following code is an example of? void add_ten(int x) { return x + 10; printf(""value of x is %d"", x); }
Unreachable code
2A variable is called an _________ variable if its value is altered within the loop by a loop-invariant value.
induction
2Dead code plays no role in any program operation and therefore it can simply be eliminated.
1In analyzing the compilation of PL/I program, the term Machine independent optimization is assosiated with
creation of more optical matrix
1The compiler can make use of memory hierarchy and CPU registers.
1A compiler for a high-level language that runs on one machine and produces code for a different machine is called
cross compiler
3What will be error here? 7 = x + y;
l-value error
1The location of memory (address) where an expression is stored is known?
l-value error
2A pictorial representation of the value computed by each statement in the basic block is
DAG
2In a two pass assembler the object code generation is done during the ?
Second pass
2Yet Another Compiler’s Compiler is a tool for
Syntax analysis
4Question Statement - mandatory (statement delivered to the candidate)
Correct choice - mandatoryCompiler translates the source code to
Both B and C
4Which of the following groups is/are token together into semantic structures?
Lexical analyzer
3Compiler should report the presence of __________ in the source program, in translation process.
Errors
3What is the output of lexical analyzer?
A list of tokens
2How many parts of compiler are there?
2
2Grammar of the programming is checked at _______ phase of compiler.
Syntax analysis
2_________ is a process of finding a parse tree for a string of tokens.
Parsing
1What is the action of parsing that translates the source program into proper syntactic classes?
Lexical analysis
1Compiler can check ________ error.
Syntax
2Lexical analysis is about breaking a sequence of characters into
Tokens
4________ is considered as a sequence of characters in a token.
Lexeme
3What is the name of the process that determining whether a string of tokens can be generated by a grammar?
Parsing
4A _________ is a software utility that translates code written in higher language into a low level language.
Compiler
2Task of a compiler is to
Translate the whole program to machine language
2In a computer system, number of compilers for a particular programming language may be
Many
4Natural language constructs are
May be Unambiguous or ambiguous
3Minimum number of states required to accept string with substring 110, where ∑={0,1}
4
1Languages of an automata is
If it is accepted by automata
1The basic limitation of finite automata is that
It can’t remember arbitrary large amount of information.
1Which phase of compiler does NOT use symbol table?
None of the other options
4Which phase of compiler is Syntax Analysis?
Second
2Output of the syntax analysis is called
Parse tree
1Output file of Lex is _____ the input file is Myfile
Myfile.yy.c
2A regular expression represents
Constituent strings of a language
3When expression sum=3+2 is tokenized then what is the token category of 3
Integer literal
3For the Fortran language statement “DO 5 I = 1.25” returns token IDENTIFIER for DO 5 I after looking upto
.
3Which of the following are Lexemes?
All of the mentioned
4Which of the following is an application of Finite Automaton?
All of the mentioned
4The maximum number of transition which can be performed over a state in a DFA? ∑= {a, b, c}
3
3NFA, in its name has ’non-deterministic’ because of :
The choice of path is non-deterministic
2Consider the following statements about the context free grammar G = {S → SS, S → ab, S → ba, S → Ε} I. G is ambiguous II. G produces all strings with equal number of a’s and b’s III. G can be accepted by a deterministic PDA. Which combination below expresses all the true statements about G?
I and III only
2Consider 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?
aabbab
3S -> aSa|bSb|a|b; The language generated by the above grammar over the alphabet {a,b} is the set of
All odd length palindromes
2The grammar {E -> E + E | E * E | id} is
Ambiguous
1Which of the following are always unambiguous
Producing one left-most and one right-most derivation
1A grammar with production rules { A-> Ba | Cb, B ->CA, C -> c | ε} contains
Left recursion
2For the grammar rules {S -> Aa | bB, A -> c |^}, FIRST(S) is
{a,b, c}
3A grammar that produces more than one parse tree for some sentence is called as
Ambiguous
1_______ is the most general phase structured grammar.
Context sensitive
1Find the language generated by S-> aSa | b
Same number of a's with a 'b' in center
2Which is not a part of a grammar production ?
Temporaries
1The following notation denotes _________ G=(V, T, P, S)
Context free grammar
2Derivation produced by a top-down parser is
Leftmost
1Derivation produced by a bottom-down parser is
Rightmost derivation in reverse
2For top-down parsing left recursion removal is
Mandatory
1A grammar is ambiguous if
More than one left most derivations exist
2A predictive parser
Needs backtracking
1In shift-reduce parsing, handle is at
Top of the stack
1Construction of parsing table in which strategies do not need the Follow set?
Canonical LR and LALR
2Amount of look ahead in LALR parser is
1
1Which of the following pairs is the most powerful
Canonical LR
2What is the similarity between LR, LALR and SLR
Use same algorithm, but different parsing table.
1In how many types parsing is divided?
2
1When 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?
top-down parsing
2In __________, if one derivation of a production fails, the syntax analyzer restarts the process using different rules of same production
Backtracking
3A form of recursive-descent parsing that does not require any back-tracking is known as?
predictive parsing
1Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.
n1 is necessarily equal to n2
2The predictive parser puts some constraints on the grammar and accepts only a class of grammar known as LL(k) grammar.
1Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
None of the above
4Which of the following derivations does a top-down parser use while parsing an input string?
Leftmost derivation
1What is true about Syntax Directed Definitions?
CFG + Semantic rules = Syntax Directed Definitions
3Which of the following error is expected to recognize by semantic analyzer?
All of the above
4____________ is a medium to provide semantics to the context-free grammar
Attribute grammar
2Semantic analyzer attaches attribute information with AST, which are called?
Attributed AST
2Which attributes get values from the attribute values of their child nodes?
Synthesized attributes
1Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?
L-attributed SDT
4If an SDT uses only synthesized attributes, it is called as?
S-attributed SDT
3Which of the following tasks should be performed in semantic analysis?
All of the above
4What is meant by compositional semantics?
Determining the meaning
1What is true about Attribute Grammar?
All of the above
4Errors are
human made programming mistakes
2Static errors are detected at
compile time
1The output of LR(1) Parser is
parse tree
2Dynamic errors are detected at
run time
2Error recovery actions in a lexical analyzer is
panic mode
1Deleting extra characters is _________ type of error recovery
panic mode
1Transposing adjacent character is __________ type of error recovery
panic mode
1The output of LL Parser is
parse tree
2Inserting missing symbol is ________ type of error recovery.
panic mode
1Replacing incorrect character by a correct character is _______ type of error recovery.
panic mode
1Writing productions for possible errors is ________ type of error recovery
error productions
3Use of global variables to define error occurrence is _________ type of error recovery method.
global correction
4A good error handler must
should recover from each error quickly
1The output of LR(0) Parser is
parse tree
2A good error handler must
not significantly slow down the processing of the correct program
2A program without syntax errors but with incorrect output is an example for
logical error
2Errors that are caused because of improper understanding of the rules of the programming language is called
sytax error
1Errors that are caused because of lack of idea of the solution is called
logical error
2A parser detects an error when
there is no legal move from current configuration
3which of the following is an example of semantic error?
type mismatch of operands
2The load instruction is mostly used to designate a transfer from memory to a processor register known as _______
Accumulator
1The specific task storage manager performs
both 1 and 2
4When a computer is first turned on or restarted, a special type of absolute loader is executed called
Boot strap loader
3Function of the storage assignment is
all of these
4A non relocatable program is the one which
cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation
1A relocatable program form is one which
can be processed to relocate it to a desired area of memory
3A self-relocating program is one which
can itself perform the relocation of its address sensitive portions
3The best way to compare the different implementations of symbol table is to compare the time required to
all of these
4Which 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?
Code
1A procedure has a start and an end delimiter and everything inside it is called the body of the procedure.
1In activation record, Which of the following Stores the address of activation record of the caller procedure?
Control Link
3Whenever a procedure is executed, its activation record is stored on the stack, also known as?
Control stack
2What is true about Formal Parameters?
These variables are declared in the definition of the called function.
1For maximum speed of execution of target code , temporary variables be best allocated to
CPU registers
3In which mechanism, the calling procedure passes the r-value of actual parameters and the compiler puts that into the called procedure’s activation record?
Pass by Value
4In which mechanism, the name of the procedure being called is replaced by its actual body?
Pass by Name
2In Directed Acyclic Graph, Leaf nodes represent?
All of the above
4__________ are used to keep track of memory locations where the values of identifiers are stored.
Address descriptor
2Choose the statement which is incorrect with respect to dynamic memory allocation.
Execution of the program is faster than that of static memory allocation
3Dynamic memory allocation is implemented using --------
Stacks and heaps
4The memory for variable is allocated before the execution of a program is called------allocation.
static
1In--------allocation,a memory can be allocated or deallocated at arbitrary points during its execution.
program controlled
4In --------memory allocation, storage is allocated at run-time i.e. memory binding are established and destroyed during the execution of a program.
dynamic
1Which of the following is drawback of static allocation strategy?
All of the above
4Which field is not present in activation record?
Register allocation
2Which is not part of runtime memory subdivision?
Access link
4Which language necessarily need heap allocation in the run time environment?
Those that support recursion
1Which of the following expression have no l-value?
3
3The size field of activation record can be determined at-----------
Compile time
2Which of the following symbol table implementation makes efficient use of memory?
Hash table
3Which one of the following is FALSE?
x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination
4One of the purposes of using intermediate code in compilers is to-----
increase the chances of reusing the machine-independent code optimizer in other compilers
3Which one of the following is false?
There is scope of dead code elimination in this code
4Consider 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
E2 should be evaluated first
2In compiler terminology reduction in strength means-----
replacing a costly operation by a relatively cheaper one
4Substitution of values for names (whose values are constants) is done in----------
Constant folding
3Which of the following comment about peep-hole optimization is true?
It is applied to small part of the code and applied repeatedly
1Which of the following statements about peephole optimization is False?
It can be applied to the portion of the code that is not contiguous
4The identification of common sub-expression and replacement of run time computations by compile-time computations is------
Constant folding
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.
DAG
1Code optimization is responsibility of--------
System programmer
2Dead-code elimination in machine code optimization refersto -----------
Removal of values that never get used.
2Which of the following statement is false?
Flow graph is used to represent DAG.
1The -------- is the final phase of compiler.
Code generation
2Substitution of values for names (whose values are constants) is done in----------
Constant folding
3Which of the following comment about peep-hole optimization is true?
It is applied to small part of the code and applied repeatedly
1Graph used to represent semantic network is ----
Directed graph
2Structure preserving transformations on basic blocks are
All the above
4The graph that shows basic blocks and their successor relationship is called
Flow graph
2Relocation bits used by relocating loader are specified by
linker
2In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction ?
Replace P * 32 by P < < 5
2Substitution of values for names (whose values are constants like pi= 3.14) is done in
Constant folding
3In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.
Loop jamming
4Loop unrolling is a code optimization technique:
That avoids tests at every iteration of the loop.
1Dead-code elimination in machine code optimization refers to :
Removal of values that never get used.
2Some code optimizations are carried out on the intermediate code because
5x * 2 can be replaced by x << 1 is an example of?
Strength reduction
3The__________ are used to keep track of memory locations where the values of identifiers are stored.
Address descriptor
2Which of the following is not a form of Intermediate representation?
Directed cyclic Graph
3A fragment of code that resides in the loop and computes the same value at each iteration is called a?
loop-invariant code
3Question Statement - mandatory (statement delivered to the candidate)
Correct choice - mandatoryA compiler is defined as
Part of system software
1Suppose there is a compiler for C language that can generate code for Computer A. Which of the following statements is true
It can be used only for computers with similar processor and operating system
3Which of the following data structures may be good if there are frequent search for data items followed by insertion and deletion?
Hash Table
4Task of an interpreter is to
Translate one statement at a time and execute it
2If an Infinite language is passed to Machine M, the subsidiary which gives a finite solution to the infinite input tape is ______________
Compiler
1Finite automata requires minimum _______ number of stacks.
0
2A programming language does not allow integer division operation. This is generally detected in the phase of
Semantic Analysis
3Which of these is not true about Symbol Table
Perform the processing of the assembler directives
3A compiler can check
Syntax error
2Error recovery helps to
Report multiple errors
1Loops are the major targets for optimization since
Loop body is repeated to several times
2For maximum speed of execution of target code , temporary variables be best allocated to
CPU registers
3Intermediate code helps in
Retargeting code
3The sum of minimum and maximum number of final states for a DFA n states is equal to:
n+1
1A Language for which no DFA exist is a________
Non-Regular Language
2The maximum sum of in degree and out degree over a state in a DFA can be determined as:______ where ∑= {a, b, c, d}
depends on the Language
4A regular expression for accepting strings with exactly one 1 more than 0’s is
Not Possible
4Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*
The set of all strings containing at least two 0’s.
3Finite automata is an implementation of
Regular expression
1The automation which allows transformation to a new state without consuming any input symbols:
NFA
1Which of the following conflicts is not possible in shift-reduce parsing
Shift-shift conflict
3Which one of the following is true at any valid state in shift-reduce parsing
Stack contains only viable prefixes
3For the grammar S → AB | C A → bA | a B → abbS | bS | ε C → bC | ε Follow(A) is
a , b , $
2Shift reduce parsers are
Bottom up Parser
2In Operator Precedence parsing handle is
Between <· and ·>
3By considering the rule B → abbS, which of the precedence relations between a and b can be inferred?
a ≐ b and b≐ b
2An operator-precedence parser is a
All the other options
4For the grammar rule B → abbS | bS, Firstop(B) equals
{a , b , S}
3For the grammar A → BCx | y B → yA | ε C → Ay | x In Predictive Parsing table the cell having multiple entries is
M[B, y]
3Bottom up parsing involves
Both shift reduce and handle pruning
4For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is
C → .cC; c,d
3For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is
C → .d; c,d
3In SLR parsing to get a shift-reduce conflict for state I on terminal symbol ‘a’,
A -> α.β with First(β) containing ‘a’ should be in I and A ->δ. be in I with Follow(A) having ‘a’
3In state I we have the items A -> α. and B -> δ., First(A), Follow(A) and Follow(B) contains the symbol ‘a’. This leads to
Reduce – reduce conflict
2Between SLR, Canonical LR and LALR, which have same number of states
SLR and LALR
1In SLR parsing for the grammar E' → E E → aEbE | bEaE | ε In state 0, for inputs 'a' and 'b'
Both will have shift-reduce conflict
1In SLR parsing for the grammar S → B | SabS B → bB | ε In state 0, for inputs 'a' and 'b'
Only 'a' will have shift-reduce conflict
2A can be A-> derivable if and only if __________
A-> A is actually a production
1The context free languages are closed under:
Kleene
3Which of the following strings do not belong the given regular expression? (a)*(a+cba)
acbacba
4Error handling and recovery is done by _________ phase
semantic
3Error recovery is
resume program execution after taking corrective actions
2Which is not a error recovery strategies in syntax analysis phase
error correction
3Error recovery is not possible in _____ type of grammar
None of the mentioned
4What is the index number of the last element of an array with 29 elements?
28
2What is meaning of the following? int *ptr[20];
Array of integer pointer of size 20
3Synthesized attribute can be easily simulated by a
LR grammar
3Intermediate code generation phase gets input from
Semantic analyzer
3Which is not true about syntax and semantic parts of a computer language?
None of the mentioned
4Intermediate code helps in
Retargeting code
3Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?
L-attributed SDT
4What value does the variable z have after ALL of the code above executes? int x; int y; int z; x=3; y=4; z = ++x * y++;
16
3What is the max no. of dimensions an array may have?
No limit
4An intermediate code form is
All of these
4Type checking is normally done during-----------
Syntax directed translation
3Three address code generated temporary name are made up for the __________ of the syntax tree.
Interior node
1Expressions that govern the flow of control that may be Boolean expressions containing_________ and _________ operators.
Relational & logical
2Listing pointers to triples, rather than listing triples themselves is implementation of
Indirect Triple
3_____________creates a new symbol table & returns a pointer to the new table.
mktable(previous)
1___________creates a new entry for procedure name in the symbol table pointed to by table
enterproc(table, name, new table)
4Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?
p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4
2In which storage allocation strategy size is required at compiler time?
Static allocation
1Which of the following fields are of activation record?
All of the above
4A _______tree is used to depict the way control enters and leaves activations
Activation
1In activation tree each node represent---------
Activation of a procedure
2In activation tree each root represent--------
Activation of main program
1In activation trees the node for a is the parent of node for b if and only if--------
If control flows from activation of a to b
2In activation trees, the node for a is to the left of node for b if and only if--
If lifetime of a occurs before lifetime of b
1Flow of control in a program corresponds to which traversal of activation tree?
Depth first traversal
1A(n)--------can be used to keep track of live procedure activations
Control stack
3If the occurrence of name in procedure is in the scope of declaration within the procedure then it is said to be------
Local
1Information needed by execution of a procedure is managed using a contiguous block of storage called-----
Both A and B
3In activation record, optional control link points to------
Activation record of caller
1The field of actual parameter in activation record is used by which procedure-----------
Called procedure
2Consider an assignment statement like a[i]:=a[j] then here a[i] represent------and a[j] represent-------
Storage location and value
2In which allocation, names are bound to storage as program is compiled-----
Stack
3Call by reference also called as----
Both A and B
3Triple is a record structure with three fields-------
op, arg1, arg2
1One of the purposes of using intermediate code in compilers is to---------
increase the chances of reusing the machine-independent code optimizer in other compilers
3Which one of the following is not type of intermediate code representations?
Preorder
3Consider the intermediate code given below: 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 11. if i < 5 goto(2) The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are------
6 and 7
2Consider the following source code : c = a + b d = c c = c – e a = d – e b = b * e b = d/b Which of the following is correct optimization of given code?
None of the above
4Consider the code segment int i, j, x, y, m, n; n=20; for (i = 0, i < n; i++) { for (j = 0; j < n; j++) { if (i % 2) { x + = ((4*j) + 5*i); y += (7 + 4*j); } } } m = x + y; Which one of the following is false.
There is scope of dead code elimination in this code
4Peephole optimization is form of------
Local optimization
2Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?
p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4
2Some code optimizations are carried out on the intermediate code because------
They enhance the portability of the compiler to other target processors
1In compiler terminology reduction in strength means-----
replacing a costly operation by a relatively cheaper one
4Match 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
2 4 1 3
3Consider the following C code segment.for (i = 0, i<n; i++) { for (j=0; j<n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } }} Which one of the following is false?
There is scope of dead code elimination in this code
4The following code is an example of? void add_ten(int x) { return x + 10; printf(""value of x is %d"", x); }
Unreachable code
2A variable is called an _________ variable if its value is altered within the loop by a loop-invariant value.
induction
2Dead code plays no role in any program operation and therefore it can simply be eliminated.
1In analyzing the compilation of PL/I program, the term Machine independent optimization is assosiated with
creation of more optical matrix
1The compiler can make use of memory hierarchy and CPU registers.
1A compiler for a high-level language that runs on one machine and produces code for a different machine is called
cross compiler
3What will be error here? 7 = x + y;
l-value error
1The location of memory (address) where an expression is stored is known?
l-value error
2A pictorial representation of the value computed by each statement in the basic block is
DAG
2In a two pass assembler the object code generation is done during the ?
Second pass
2Yet Another Compiler’s Compiler is a tool for
Syntax analysis option:4
- Compiler Design MCQ
- 4
- 3
- 3
- 2
- 2
- 2
- 1
- 1
- 2
- 4
- 3
- 4
- 2
- 2
- 4
- 3
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