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

Bottom Up Parsing Questions and Answers

81.

Consider the grammar shown below

\(S \rightarrow AA\)
\(A \rightarrow aA / d\)

The grammar is :

Exam Year(s)

MH SET - 2023, SET Exam - 2023,

Answer: A

The grammar is LL(1).

A grammar is LL(1) if, for each non-terminal, the alternatives can be told apart by one symbol of lookahead. S has a single production. For A → aA | d, the alternatives begin with different terminals: FIRST(aA) = {a} and FIRST(d) = {d}, which are disjoint, and neither alternative derives the empty string, so no FOLLOW set is involved.

Every LL(1) grammar without such conflicts is also SLR(1), LALR(1) and LR(1), so the options that say 'but not LL(1)' are all false for this grammar.

Please log in or register to report this question.

82.

Which of the following is the most powerful parring method ?

Exam Year(s)

UGC NET - 2012,

Answer: B

Canonical LR is the most powerful parsing method of those listed. It keeps a full look-ahead symbol with each item, so it can parse every deterministic context-free grammar, with the largest set of states and the most precise reductions.

LL(1) is a top-down method and handles a smaller class of grammars, SLR uses the follow sets and so makes more conflicts, and LALR merges states of canonical LR with the same core, which can only add reduce-reduce conflicts. So the order of power is SLR, then LALR, then canonical LR.

Please log in or register to report this question.

83.

Given the following statements : S1 : SLR uses follow information to guide reductions. In case of LR and LALR parsers, the lookaheads are associated with the items and they make use of the left context available to the parser. S2 : LR grammar is a larger subclass of context free grammar as compared to that SLR and LALR grammars. Which of the following is true ?

Exam Year(s)

UGC NET - 2013,

Answer: D

Both statements are correct. S1 describes how the parsers use lookahead: SLR reductions are guided by the FOLLOW set, whereas LR and LALR items carry their own lookaheads and use the left context the parser has, which is why they are more precise.

S2 is correct because the LR grammars form a larger subclass of context free grammars than SLR and LALR grammars, which are both proper subsets of LR(1). Hence the option that calls both statements correct is right and the three others are wrong.

Please log in or register to report this question.

84.

Given a grammar : S1 → Sc, S → SA | A, A → aSb | ab, there is a rightmost derivation S1 ⇒ Sc ⇒ SAC ⇒ SaSbc Thus, SaSbc is a right sentential form, and its handle is

Exam Year(s)

UGC NET - 2013,

Answer: D

The handle of a right sentential form is the production body whose reduction is the previous step of the rightmost derivation. In S1 => Sc => SAc => SaSbc, the last step replaced A with aSb, so in SaSbc the handle is the substring aSb that came from A -> aSb, option (D). SaS and Sbc do not correspond to the right side of any production, and bc is not the whole body of any rule either, so those are not handles. Reducing aSb to A gives SAc, then reducing SA to S gives Sc, then Sc to S1, which is the reverse of the derivation, and each reduction is at the rightmost possible handle.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Bottom Up Parsing Questions and Answers || Bottom Up Parsing MCQ Questions and Answers || Bottom Up Parsing GK Questions and Answers || Bottom Up Parsing GK MCQ Questions || Bottom Up Parsing Multiple Choice Questions and Answers || Bottom Up Parsing GK || GK on Bottom Up Parsing || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design