Parsing


Q11.

Consider the following grammar. S\rightarrow aSB|d B\rightarrow b The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is___________.
GateOverflow

Q12.

A given grammar is called ambiguous if
GateOverflow

Q13.

Consider the following given grammar: S \rightarrow Aa A \rightarrow BD B \rightarrow b|\epsilon D \rightarrow d|\epsilon Let a, b, d and $ be indexed as follows: Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210). Answer:_____
GateOverflow

Q14.

Which one of the following kinds of derivation is used by LR parsers?
GateOverflow

Q15.

Consider the following grammar: stmt\rightarrow if expr then else expr; stmt| \dot{O} expr\rightarrowterm relop term|term term\rightarrow id|number if\rightarrowa|b|c number\rightarrow [0-9] where relop is a relational operate (e.g \lt ,\gt,...), \dot{O} refers to the empty statement, and if ,then, else are terminals. Consider a program P following the above grammar containing ten if terminals. The number of control flows paths in P is ____________. For example the program if e_1 then e_3 else e_3 has 2 controls flow paths e_{1} \rightarrow e_{2} and e_{1} \rightarrow e_{3}.
GateOverflow

Q16.

Recursive descent parsing is an example of
GateOverflow

Q17.

A top-down parser generates
GateOverflow

Q18.

Which one of the following is a top-down parser?
GateOverflow

Q19.

Consider the following Syntax Directed Translation Scheme(SDTS),with non-terminals {S, A} and terminals {a, b}. S \rightarrow aA {print 1} S \rightarrow a { print 2} A \rightarrow Sb { print 3} Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:
GateOverflow

Q20.

A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example, int a[10][3]; The grammars use D as the start symbol,and use six terminal symbols int ;id[]num. Which of the grammars correctly generate the declaration mentioned above?
GateOverflow