Machine-translated by Google. Questions are authored in English.
Top

Top Down Parsing Questions and Answers

Answer: A

Each production contributes entries only for the terminals in its FIRST set. The sparsity is what makes compressed representations attractive for large grammars. A grammar with many terminals produces a table that is almost entirely empty.

Please log in or register to report this question.

Answer: B

The dependencies can be cyclic, so a single pass may miss contributions. Repeating until a fixed point is reached is the standard way to solve such a system of set equations. The same fixed point technique reappears later in data flow analysis.

Please log in or register to report this question.

Answer: C

Whatever follows a nonterminal contributes its FIRST set to that nonterminal's FOLLOW. The dependency runs one way only, which fixes the order in which the two must be computed. Attempting the reverse order produces sets that are silently incomplete.

Please log in or register to report this question.

Answer: D

Correct answer: add FOLLOW of the left side nonterminal to the FOLLOW of that symbol

If everything after a symbol in a right side can vanish, then whatever may follow the left side may follow that symbol too. This propagation rule is what makes FOLLOW computation iterative, since adding to one FOLLOW set may require additions to others until nothing changes.

Please log in or register to report this question.

Answer: A

The first three all build the tree from the root down. Shift reduce parsing constructs the tree from the leaves upward and belongs to the bottom up family. The direction of construction is the defining difference between the families.

Please log in or register to report this question.

Answer: B

Correct answer: the correspondence between the grammar and the code is direct

A recursive descent parser can be read alongside its grammar, so the mechanics of parsing are visible rather than hidden in a table. That transparency makes it the natural first method, and it prepares the ground for tables by making clear what a table is doing.

Please log in or register to report this question.

Answer: C

Correct answer: an abstract syntax tree returned by each parsing procedure

Each procedure recognises one construct, so it is the natural place to build the node for that construct from the nodes its callees return. The tree is assembled bottom up as the recursion unwinds, and no separate tree-building pass is needed.

Please log in or register to report this question.

Answer: D

Correct answer: directly in the code of the parsing procedures

Actions sit in the procedure at the point where the corresponding part of the construct has been recognised, so there is no separate mechanism at all - the parser and the translator are the same code. This freedom is one of the practical attractions of writing the parser by hand.

Please log in or register to report this question.

Answer: A

Host stacks are finite, so deeply nested input can exhaust them. Table driven parsers use a heap allocated stack and are limited only by available memory. Compilers therefore often impose a documented limit on nesting depth.

Please log in or register to report this question.

70.

Consider the following statements about predictive parsing.
1. It runs in time linear in the length of the input.
2. It requires the grammar to be free of left recursion.
3. It can parse any unambiguous context free grammar.

Answer: B

Linear time and freedom from left recursion both hold. The third overstates the power of the method, since many unambiguous grammars need more lookahead or a bottom up approach. Unambiguity is a property of the language description, not of parsing difficulty.

Please log in or register to report this question.

Loading…
Tags: Top Down Parsing Questions and Answers || Top Down Parsing MCQ Questions and Answers || Top Down Parsing GK Questions and Answers || Top Down Parsing GK MCQ Questions || Top Down Parsing Multiple Choice Questions and Answers || Top Down Parsing GK || GK on Top Down Parsing || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design