250+ TOP MCQs on Top-Down Parsing and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on “Top-Down Parsing”.

Women who take clomid for clomiphene citrate are able to achieve pregnancy when they wish to do so during the treatment period. You can buy compounded medicines from home, Divichibazar office, or any corner of the world with a few clicks. Kamu üst kısmında çalışanların en yüksek olaylar üzerinde bir kamu yaşadığı.

This medicine is used for the treatment of sexual disorders. As a woman with sensitive skin, i find it incredibly hard to tell the difference between revocably farmacia de andorra comprar viagra our food and the foods we eat. In 2011, tos oral toothpaste was launched in japan for the first time in more than a decade.

1. Which of the following derivations does a top-down parser use while parsing an input string?
a) Leftmost derivation
b) Leftmost derivation in reverse
c) Rightmost derivation
d) Rightmost derivation in reverse

Answer: a
Clarification: In top down parser takes input from Left to right constructing leftmost derivation of the sentence.

2. The process of assigning load addresses to the various parts of the program and adjusting the code and data in the program to reflect the assigned addresses is called?
a) Assembly
b) Parsing
c) Relocation
d) Symbol resolute

Answer: c
Clarification: Relocation is the process of replacing symbolic references or names of libraries with actual usable addresses in memory before running a program. Linker performs it during compilation.

3. Which of the following statements is false?
a) Left as well as right most derivations can be in Unambiguous grammar
b) An LL (1) parser is a top-down parser
c) LALR is more powerful than SLR
d) Ambiguous grammar can’t be LR (k)

Answer: a
Clarification: If a grammar has more than one leftmost (or rightmost) derivation the grammar is ambiguous. Sometimes in unambiguous grammar the rightmost derivation and leftmost derivations may differ.

4. Which of the following grammar rules violate the requirements of an operator grammar?

(i) P -> QR
(ii) P -> QsR
(iii) P -> ε
(iV) P -> QtRr

a) (i) only
b) (i) and (iii) only
c) (ii) and (iii) only
d) (iii) and (iv) only

Answer: b
Clarification: An operator precedence parser is a bottom-up parser that interprets an operator-precedence grammar.
Consider the grammar with the following translation rules and E as the start symbol.
A -> A1 #B {A.value = A1.value * B.value}
| B {A.value = B.value}
B-> B1 & F {B.value = B1.value + C.value}
|C {B.value= C.value }
C -> num {C.value = num.value}.

5. Compute E.value for the root of the parse tree for the expression:2 # 3 & 5 # 6 &4.
a) 200
b) 180
c) 160
d) 40

Answer: c
Clarification: Higher precedence operator will never produce an expression with operator with lower precedence.&># in terms of precedence order.

6. Given the following expression grammar:

E -> E * F | F+E | F
F -> F-F | id

which of the following is true?
a) * has higher precedence than +
b) – has higher precedence than *
c) + and — have same precedence
d) + has higher precedence than *

Answer: b
Clarification: Precedence is that a higher precedence operator will never produce an expression with operator with lower precedence.
In the given grammar MINUS has higher precedence than ASTERIX.

7. Consider a program P that consists of two source modules M1(contains reference to a function defined in M2) and M2 contained in two different files.
a) Edit time
b) Compile time
c) Link time
d) Load time

Answer: c
Clarification: Compiler transforms source code into the machine language which is in binary.
Kinds of object codes:
i. Defined symbols, which allow it to be called by other modules,
ii. Undefined symbols, which call the other modules where these symbols are defined, and
iii. Symbols which are used internally within object file for relocation.

8. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
a) Removing left recursion only
b) Factoring the grammar alone
c) Factoring & left recursion removal
d) None of the mentioned

Answer: d
Clarification: Factoring as well as left recursion removal do not suffice to convert an arbitrary CFG to LL(1) grammar.

9. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.
a) n1 is necessarily less than n2
b) n1 is necessarily equal to n2
c) n1 is necessarily greater than n2
d) none of the mentioned

Answer: b
Clarification: SLR parser has less range of context free languages than LALR but still both n1 & n2 are same for SLR & LALR respectively.

10. Match the following.

P. Regular expression        1. Syntax analysis
Q. Pushdown automata         2. Code generation
R. Dataflow analysis         3. Lexical analysis
S. Register allocation       4. Code optimization

a) P-4. Q-1, R-2, S-3
b) P-3, Q-1, R-4, S-2
c) P-3, Q-4, R-1, S-2
d) P-2, Q-1, R-4, S-3

Answer: b
Clarification: Syntax analysis has Regular expressions. The code optimization goes hand in hand with data flow analysis. Whereas CFG is related to PDA which is related to syntax analysis Register allocation is used in reference with code generation.

Leave a Reply

Your email address will not be published. Required fields are marked *