Showing posts with label Compiler Construction. Show all posts
Showing posts with label Compiler Construction. Show all posts

Compiler Construction MCQ :Code Generation and Optimization-three address code, DAG, block graph : Link2

Compiler Construction MCQ :Code Generation and Optimization-three address code, DAG, block graph : Link2

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Code Generation and Optimization-three address code, DAG, block graph ? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. The identification of common sub-expression and replacement of run time computations by compile-time computations is------

A. Local optimization
B. Constant folding
C. Loop optimization
D. Data flow analysis

Q.2. Which of the following class of statement usually produces no executable code when compiled?

A. Declaration
B. Assignment statements
C. Input and output statements
D. Structural statements

Q.3. Code optimization is responsibility of--------

A. Application programmer                                         B. System programmer
C. Operating system                                      D. All of the above.

Q.4. Dead-code elimination in machine code optimization refersto -----------

A. Removal of all labels.
B. Removal of values that never get used.
C. Removal of function which are not involved.
D. Removal of a module after its use.

Q.5. Which of the following statement is false?

A. Flow graph is used to represent DAG.
B. Three address code is the input to the code generator.
C. The first statement of three address code is always leader of the first basic block.
D. Transformation of block is needed for code optimization.

Q.6. -------- is the final phase of compiler.

A. Semantic analysis                                                                     B. Code generation
C. Target code generation                                                                    D. Syntax analysis

Q.7. Consider 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?

(A) p1 = a - b
q1 = p1 * c
p1 = u * c
q1 = p1 + q1
(B) p3 = a - b
q4 = p3 * c
p4 = u * c
q5 = p4 + q4
(C) p1 = a - b
q1 = p2 * c
p3 = u * c
q2 = p4 + q3
(D) p1 = a - b
q1 = p * c
p2 = u * c
q2 = p + q

Q.8.Some code optimizations are carried out on the intermediate code because------

A. They enhance the portability of the compiler to other target processors                                                               B. Program analysis is more accurate on intermediate code than on machine code
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

Q.9. Peephole optimization is form of------

A. Loop optimization                                       B. Local optimization
C. Constant folding                                                D. Data flow analysis

Q.10. In compiler terminology reduction in strength means-----

A. Replacing run time computation by compile time computation
B. Removing loop invariant computation
C. Removing common subexpressions
D. replacing a costly operation by a relatively cheaper one

Q.11. Substitution of values for names (whose values are constants) is done in----------

A. Local optimization                                                                 B. Loop optimization
C. Constant folding                                                                   D. Strength reduction

Q.12. Which of the following comment about peep-hole optimization is true?

A. It is applied to small part of the code and applied repeatedly                                                                B. It can be used to optimize intermediate code
C. It can be applied to a portion of the code that is not contiguous                                                                      D. It is applied in symbol table to optimize the memory requirements

Q.13. CWhich of the following statements about peephole optimization is False?

A. It is applied to a small part of the code                              B. It can be used to optimize intermediate code
C. To get the best out of this, it has to be applied repeatedly                        D. It can be applied to the portion of the code that is not contiguous

Q.14. Quadruple is a record structure with four fields-------

A. Op, arg1, arg2 and result
B. op1, op2, arg2 and result
C. arg1, arg2, result and op
D. All of the above.

Q.15. Graph used to represent semantic network is ----

A. Undirected graph                              B. Directed graph
C. Directed Acyclic graph (DAG)                                  D. Directed complete graph

Compiler Construction MCQ :Code Generation and Optimization-Compilation of expression, intermediate codes for expressions : Link1

Compiler Construction MCQ :Code Generation and Optimization-Compilation of expression, intermediate codes for expressions : Link1

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Code Generation and Optimization-Compilation of expression, intermediate codes for expressions? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. Some code optimizations are carried out on the intermediate code because------

A. they enhance the portability of the compiler to other target processors
B. program analysis is more accurate on intermediate code than on machine code
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

Q.2. Which one of the following is FALSE?

A. A basic block is a sequence of instructions where control enters the sequence at the beginning and exits at the end.
B. Available expression analysis can be used for common subexpression elimination.
C. Live variable analysis can be used for dead code elimination.
D. x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination

Q.3. One of the purposes of using intermediate code in compilers is to---------

A. make parsing and semantic analysis simpler.
B. improve error recovery and error reporting.
C. increase the chances of reusing the machine-independent code optimizer in other compilers
D. improve the register allocation.

Q.4. Which one of the following is false?

A. The code contains loop invariant computation
B. There is scope of common sub-expression elimination in this code
C. There is scope of strength reduction in this code
D. There is scope of dead code elimination in this code

Q.5. Consider the grammar rule E → E1 - E2 for arith¬metic expressions. The code generated is targeted to a CPU having a single user register. The sub¬traction operation requires the first operand to be in the register. If E1 and E2 do not have any com¬mon sub expression, in order to get the shortest possible code

A. E1 should be evaluated first
B. E2 should be evaluated first
C. Evaluation of E1 and E2 should necessarily be interleaved
D. Order of evaluation of E1 and E2 is of no consequence

Q.6. Consider 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------

A. 5 and 7                                                                     B. 6 and 7
C. 5 and 5                                                                    D. 7 and 8

Q.7. Consider 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?

A] c = a + b
t = b * e
a = d – e
b = d/t
c = a

B] c = a + b
d = c
c = c – e
a = d – e
b = d/b

C] d = c
c = c – e
a = d – e
b = b * e
b = d/b
D] None of the above

Q.8.Consider 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.

A. The code contains loop invariant computation
B. There is scope of common sub-expression elimination in this code
C. There is scope of strength reduction in this code
D. There is scope of dead code elimination in this code

Q.9. Peephole optimization is form of------

A. Loop optimization                                             B. Local optimization
C. Constant folding                                                D. Data flow analysis

Q.10. In compiler terminology reduction in strength means-----

A. Replacing run time computation by compile time computation
B. Removing loop invariant computation
C. Removing common subexpressions
D. replacing a costly operation by a relatively cheaper one

Q.11. Substitution of values for names (whose values are constants) is done in----------

A. Local optimization                                                                B. Loop optimization
C. Constant folding                                                                   D. Strength reduction

Q.12. Which of the following comment about peep-hole optimization is true?

A. It is applied to small part of the code and applied repeatedly
B. It can be used to optimize intermediate code
C. It can be applied to a portion of the code that is not contiguous
;D. It is applied in symbol table to optimize the memory requirements

Q.13. CWhich of the following statements about peephole optimization is False?

A. It is applied to a small part of the code
B. It can be used to optimize intermediate code
C. To get the best out of this, it has to be applied repeatedly
D. It can be applied to the portion of the code that is not contiguous

Q.14. Quadruple is a record structure with four fields-------

A. Op, arg1, arg2 and result                                    B. op1, op2, arg2 and result
C. arg1, arg2, result and op                                     D. All of the above.

Q.15. Graph used to represent semantic network is ----

A. Undirected graph                                                      B. Directed graph
C. Directed Acyclic graph (DAG)                                  D. Directed complete graph

Compiler Construction MCQ :Memory allocation-activation record, activation trees : Link2

Compiler Construction MCQ :Memory allocation-activation record, activation trees : Link2

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Memory allocation-activation record, activation trees? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. Which of the following are storage allocation strategies ---------

A. Static allocation
B. Stack allocation
C. Heap allocation
D. all of the above.

Q.2. ------tree is used to depict the way control enters and leaves activations.

A. Activation                                                       B. Parse
C. Syntax                                                            D. None of the above

Q.3. In activation tree each node represent---------

A. Activation of main program                          B. Activation of a procedure
C. Both A and B                                                   D. None of the above

Q.4. In activation tree each root represent---------

A. Activation of main program                          B. Activation of a procedure
C. Both A and B                                                   D. None of the above

Q.5. The node for a is the parent of node for b if and only if--------

A. If lifetime of a occurs before lifetime of b
B. If control flows from activation of a to b
C. Both A and B
D. None of the above

Q.6. The node for a is to the left of node for b if and only if--------

A. If lifetime of a occurs before lifetime of b
B. If control flows from activation of a to b
C. Both A and B
D. None of the above.

Q.7. Flow of control in a program corresponds to which traversal of activation tree?

A. Depth first traversal                                               B. Breadth first traversal
C. Both A and B                                                           D. None of the above

Q.8.--------can be used to keep track of live procedure activations

A. Activation tree                                                         B. Activation node
C. Control stack                                                          D. None of the above.

Q.9. If the occurrence of name in procedure is in the scope of declaration within the procedure then it is said to be------

A. Local                                                                         B. Nonlocal
C. Global                                                                       D. None of the above

Q.10. Information needed by execution of a procedure is managed using a contiguous block of storage called-----

A. Activation record                                                     B. Frame
C. Both A and B                                                             D. Activation tree

Q.11. In activation record, optional control link points to------

A. Activation record of caller                                     B. Activation record of callee
C. Both A and B                                                            D. None of the above

Q.12. The field of actual parameter in activation record is used by which procedure-----------

A. Calling procedure                                                  B. Called procedure
C.Both A and B                                                            D. None of the above.

Q.13. Consider an assignment statement like a[i]:=a[j] then here a[i] represent------and a[j] represent-------

A. Value and storage location                                   B. Storage location and value
C. Value and value                                                      D. None of the above.

Q.14. In which allocation, names are bound to storage as program is compiled-----

A. Static                                                                         B. Heap
C. Stack                                                                         D. None of the above.

Q.15. Call by reference also called as----

A. Call-by-address                                                       B. Call-by-location
C. Both A and B                                                             D. None of the above

Compiler Construction MCQ :Memory allocation-static and dynamic memory allocation : Link1

Compiler Construction MCQ :Memory allocation-static and dynamic memory allocation : Link1

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Memory allocation-static and dynamic memory allocation,Memory allocation in block structure languages, Array allocation and access.? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. The dope vector is exist during ---------

A. compilation.                                           B. execution.
C. static allocation                                     D. all of the above.

Q.2. Choose the statement which is incorrect with respect to dynamic memory allocation.

A. Memory is allocated in a less structured area of memory, known as heap
B. Used for unpredictable memory requirements
C. Execution of the program is faster than that of static memory allocation
D. Allocated memory can be changed during the run time of the program based on the requirement of the program

Q.3. Dynamic memory allocation is implemented using ---------

A. array                                                        B. stacks
C. heap                                                        D. Both B & C

Q.4. The memory for variable is allocated before the execution of a program is called------allocation.

A. static                                                       B. dynamic
C. automatic                                               D. program controlled

Q.5. In--------allocation,a memory can be allocated or deallocated at arbitrary points during its execution.

A. static                                                        B. dynamic
C. automatic                                                D. program controlled

Q.6. In --------memory allocation, storage is allocated at run-time i.e. memory binding are established and destroyed during the execution of a program.

A. dynamic                                                  B. static
C. automatic                                               D. None of the above.

Q.7. Which of the following is drawback of static allocation strategy?

A. Size of the data objects must be known at compile time
B. Data structures cannot be created dynamically
C. Recursive procedure are restricted
D. All of the above

Q.8. Which field is not present in activation record?

A. Saved machine status                            B. Register allocation
C. Optional control link                             D. Temporaries

Q.9. Which is not part of runtime memory subdivision?

A. Stack                                                        B. Heap
C. Static data                                              D. Access link

Q.10. Which language necessarily need heap allocation in the run time environment?

A. Those that support recursion
B.Those that use dynamic scoping
C.Those that allow dynamic data structure
D. Those that uses global variables

Q.11. Which of the following expression have no l-value?

A. a[i+1]                                                         B. a
C. 3                                                               D. *a

Q.12. The size field of activation record can be determined at-----------

A. Run time                                                 B. Compile time
C. Both A and B                                          D. None of the above.

Q.13. Which of the following symbol table implementation makes efficient use of memory?

A. List                                                          B. Search tree
C. Hash table                                              D. Self-organizing list

Q.14. In which storage allocation strategy size is required at compiler time?

A. Static allocation                                     B. Dynamic allocation
C. Stack allocation                                     D. All of the above.

Q.15. Which of the following fields are of activation record?

A. Return value                                           B. Local data
C. Temporaries                                           D. All of the above

Compiler Construction MCQ :Syntax Directed Definition-S-attributed and L-attributed definition : Link2

Compiler Construction MCQ :Syntax Directed Definition-S-attributed and L-attributed definition : Link2

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Syntax Directed Definition-S-attributed and L-attributed definition? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. Consider the productions A → PQ and A → XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: s is a synthesized attribute and i is an inherited attribute. Consider the following rules.
Rule 1 : P.i = A.i + 2, Q.i = P.i + A.i, and A.s = P.s + Q.s
Rule 2 : X.i = A.i + Y.s and Y.i = X.s + A.i
Which one of the following is TRUE?

A. Only Rule 2 is L-attributed.
B. Neither Rule 1 nor Rule 2 is L-attributed.
C. Both Rule 1 and Rule 2 are L-attributed.
D. Only Rule 1 is L-attributed

Q.2. Consider the following expression grammar. The seman¬tic rules for expression calculation are stated next to each grammar production.
E→number       E.val=number.val
|E+E      E(1).val=E(2).val+E(3).val
|E×E      E(1).val=E(2).val×E(3).val
The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?

A. It detects recursion and eliminates recursion
B. It detects reduce-reduce conflict, and resolves
C. It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
D. It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action

Q.3. Which one of the following restricts the class of syntax directed definitions that can be implemented----------

A. Parse tree methods                                    B. Rule-based methods
C. Oblivious method                                      D. None of the above.

Q.4. Which one of the following is not method for evaluating semantic rules?

A. Parse tree methods
B. Oblivious method
C. syntax -based methods
D. Rule-based methods

Q.5. Syntax directed translation can be based on---------

A. syntax tree
B. parse tree.
C. syntax tree as well as parse tree.
D. None of the above.

Q.6.-----------are useful tool for determining an evaluation order for the attribute instances in given parse tree.

A. DAG                                                              B. Dependency graph
C. Graph coloring graph                               D. None of the above.

Q.7. Notations for associating semantic rules with productions are--------

A. Syntax directed definition                         B. Translation scheme
C. Both A and B                                               D. None of the above.

Q.8. The interdependencies among inherited and synthesized attributes at nodes in parse tree can be depicted by---------

A. DAG                                                               B. Dependency graph
C. Interdependency graph                             D. Wait for graph

Q.9. Inherited attribute can easily be simulated by an ----------

A. LL grammar                                                B. Ambiguous
C. LR grammar                                                D. None of the above.

Q.10. From the following production with semantic rule E.val is-------.
E → E1 + T { E.val = E1.val + T.val}

A. Synthesized attribute
B. Inherited attribute
C. Syntax attribute
D. None of the above.

Q.11. 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

Q.12. Which one of the following is not type of intermediate code representations?

A. Syntax tree                                                  B. Postfix
C. Preorder                                                      D. Three address code

Compiler Construction MCQ :Syntax Directed Definition-SDT, SDD : Link1

Compiler Construction MCQ :Syntax Directed Definition-SDT, SDD : Link1

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Syntax Directed Definition-Syntan Directed Translation, Syntax Directed Definition-inherited, synthesized attributes? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. A grammar oriented compiling technique known as--------------

A. Syntax directed translation
B. Data flow translation
C. Two pass compiler
D. None of the above.

Q.2. Type checking is normally done during-----------

A. Lexical analysis
B. Syntax Analysis
C. Syntax directed translation
D. Code optimization

Q.3. A parse tree showing the value of attributes at each node is called----------

A. Syntax tree                                           B. Annotated parse tree
C. Semantic tree                                      D. All of the above.

Q.4. Inherited attribute is a natural choice in----------

A. keeping track of variable declaration
B. checking for the correct use of L-values and R-values
C. both (A) and (B)
D. None of the above.

Q.5. Syntax directed translation scheme is desirable because-------

A. it is based on the syntax
B. its description is independent of any implementation
C. it is easy to modify
D. All of the above.

Q.6. A synthesized attribute is an attribute whose value at a parse tree node depends on -------

A. Attributes at the siblings only                          B. Attributes at parent node only
C. Attributes at children nodes only                    D. None of the above.

Q.7. A inherited attribute is an attribute whose value at a parse tree node not depends on------

A. Attributes at the siblings only                      B. Attributes at parent node only
C. Attributes at children nodes only                D. None of the above.

Q.8. Attributes whose values are defined in terms of a node’s own attributes, node’s siblings and node’s parent are called--------

A. Inherited attributes                                      B. Physical attributes
C.Logical attributes                                          D. Un-synthesized attributes

Q.9. The--------translation statements can be conveniently specified in YACC.

A. Syntax-directed                                            B. Image-directed
C. Sign-directed                                                 D. Segment-directed

Q.10. In a bottom up evaluation of a syntax direction definition, inherited attributes can-------

A. always be evaluated
B. be evaluated only if the definition is L –attributed
C. evaluation only done if the definition has synthesized attributes
D. None of the above.

Q.11. Synthesized attribute can be easily simulated by a---------

A. LL grammar                                                    B. Ambiguous grammar
C. LR grammar                                                    D. None of the above.

Q.12. In synthesize attribute, we can evaluate in------------order.

A. Bottom-up                                                      B. Top-down
C. Preorder                                                          D. None of the above.

Q.13. In inherited attribute, we can evaluate in---------order.

A. Bottom-up                                                      B. Top-down
C. postorder                                                       D. None of the above

Q.14. An SDD without side effects is called ---------

A. Context free grammar
B. Operator grammar
C. Attribute grammar
D. Both A and C

Q.15. An SDD that involves only synthesized attributes is called--------

A. S-attributed                                                   B. L-attributed
C. Both A and B                                                  D. None of the above.

Compiler Construction MCQ :Syntax Analysis(Parser)-LR parser, YACC : Link7

Compiler Construction MCQ :Syntax Analysis(Parser)-LR parser, YACC : Link7

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Syntax Analysis(Parser)-LR parser, YACC? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. YACC stand for-----------

A. es Another Compiler Compiler
B. Yet Another Compile Compiler
C. Yet Another Compiler Compiler
D. Yes Another Compile Compiler

Q.2. The YACC takes C code as input and outputs----------

A. Top down parsers
B. Bottom up parsers
C. Machine code
D. None of the above.

Q.3. Which of the following software tool is parser generator ?

A. Lex                                                         B. Yacc
C. Both A and B                                        D. None of the above

Q.4. The output of YACC---------

A. y.tab.c                                                   B. lex.yy.c
C. yacc.c                                                   D. None of the above.

Q.5.The output of LEX-----

A. y.tab.c                                                   B. lex.yy.c
C. lex.c                                                      D. None of the above.

Q.6. Findout the incorrect statement from the following statements.

A. YACC is parser generator.
B. Every SLR(1) grammar is unambiguous.
C. LL(1) language cannot have left-recursive production
D. Number of states of SLR parsing are more than that of LR parsing.

Compiler Construction MCQ :Syntax Analysis(Parser)-Operator Precedence Parser, LR parser : Link6

Compiler Construction MCQ :Syntax Analysis(Parser)-Operator Precedence Parser, LR parser : Link6

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Syntax Analysis(Parser)-Operator Precedence Parser, LR parser? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. LR parser is attractive because--------------

A. It can be constructed to recognize CFG corresponding to almost all programming constructs.
B. It does not backtrack
C. It detects error as and when they occur
D. Both A and B

Q.2. Choose the correct statements.

A. There are CFG’s that are not LR
B. An ambiguous grammar can never be LR
C. An ambiguous grammar can be LR
D. Both A and B

Q.3. YACC builds up----------

A. SLR parsing table                                         B. canonical LR parsing table
C. LALR parsing table                                      D. None of the above

Q.4. Choose the incorrect statement.

A. LL(k) grammar has to be a CFG
B. LL(k) grammar has to be unambiguous
C. There are LL(k) grammars that are not context free
D. LL(k) grammars cannot have left recursive non-terminals

Q.5. LR(k) grammar-----

A. Can only examine a maximum of k input symbols
B. Can be used to identify handles and Covers the LL(k) class
C. Can be used to identify the production associated with a handle
D. All of the above.

Q.6. The ‘k’ in LR(k) cannot be------

A. 0                                                                     B. 1
C. 2                                                                     D. None of the above.

Q.7. Consider the grammar
E➔TE'
E'➔+TE'|ε
T➔FT'
T'➔*FT'|ε
F➔(E)|id
FOLLOW(F) will be--------

A. { +, *, ), $ }                                                     B. {+, ), $ }
C. {*, ), $}                                                           D. {+, (, ), * }

Q.8. LR(0) items of Production A➔ε is--------

A] A➔ε                                                               B] A➔.
C] A➔.ε                                                              D] A➔ε.

Q.9. To construct the canonical LR(0) collection for a grammar, we need to define an augmented grammar for G and two functions----and --------.

A. CLOSUREC, GOTO                                      B. SHIFT, REDUCE
C. SHIFT, SHIFT                                                D. None of the above.

Q.10. Construct LR(0) items for the following production
A➔ XYZ

A] A➔.XYZ
A➔X.YZ
A➔XY.Z
A➔XYZ.
B] A➔.XYZ
A➔X.YZ
A➔XYZ.
C] A➔.XYZ
A➔X.YZ
A➔XYZ.
D. None of the above.

Q.11. Check whether the following grammar is SLR(1) or not.
S➔A|B
A➔aA|b
B➔dB|b

A. SLR(1)                                                                B. not SLR(1)
C. CLR                                                                   D. None of the above.

Q.12. Consider the grammar
A -> B C C
B -> h B | ε
C -> C g | g | C h | i
D -> A B | ε
First of A is------

A] h, g, i                                                                B] g
C] h                                                                      D] None of the above.

Q.13. 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------

A. n1 is necessarily less than n2                              B. n1 is necessarily equal to n2
C. n1 is necessarily greater than n2                        D. None of the above

Q.14. Which of the following statements is true?

A. SLR parser is more powerful than LALR
B. LALR parser is more powerful than Canonical LR parser
C. Canonical LR parser is more powerful than LALR parser
D. The parsers SLR, Canonical CR, and LALR have the same power

Q.15. Merging states with a common core may produce--------, conflicts but does not produce--------conflicts in an LALR parser.

A. reduce-reduce; shift-reduce                              B. shift-reduce; reduce-reduce
C. shift-reduce; shift-reduce                                  D. None of the above