Test: Top Down Parsing


10 Questions MCQ Test Compiler Design | Test: Top Down Parsing


Description
This mock test of Test: Top Down Parsing for Computer Science Engineering (CSE) helps you for every Computer Science Engineering (CSE) entrance exam. This contains 10 Multiple Choice Questions for Computer Science Engineering (CSE) Test: Top Down Parsing (mcq) to study with solutions a complete question bank. The solved questions answers in this Test: Top Down Parsing quiz give you a good mix of easy questions and tough questions. Computer Science Engineering (CSE) students definitely take this Test: Top Down Parsing exercise for a better result in the exam. You can find other Test: Top Down Parsing extra questions, long questions & short questions for Computer Science Engineering (CSE) on EduRev as well by searching above.
QUESTION: 1

Which of the following derivations does a top-down parser use while parsing an input string?

Solution:

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

QUESTION: 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

Solution:

Explanation: 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.

QUESTION: 3

Which of the following statements is false?

Solution:

Explanation: 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.

QUESTION: 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

Solution:

Explanation:
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}.

QUESTION: 5

Consider the grammar with the following translation rules and E as the start symbol.

E → E1 # T { E.value = E1.value * T.value }

| T{ E.value = T.value }

T → T1 & F { T.value = T1.value + F.value }

| F{ T.value = F.value }

F → num { F.value = num.value }

Compute E.value for the root of the parse tree for the expression:2 # 3 & 5 # 6 &4.

Solution:

Explanation:higher precedence operator will never produce an expression with operator with lower precedence.&># in terms of precedence order.

QUESTION: 6

Given the following expression grammar:
E -> E * F | F + E | F
F -> F - F | id
which of the following is true?

Solution:
QUESTION: 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.

Solution:

Explanation:
Compiler transforms source code into the machine language which is in binary .
Kinds of object codes:
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.

QUESTION: 8

Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

Solution:

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

QUESTION: 9

Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.

Solution:

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

QUESTION: 10

 Which of the following describes a handle (as applicable to LR-parsing) appropriately?

Solution:

Explanation: the next step in LR parsing shall have Reduction .

Related tests