Parsing


Q31.

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

Q32.

Given the grammars \rightarrow T^{*} S \mid TT \rightarrow U+T \mid UU \rightarrow a \mid bWhich of the following statements is wrong?
GateOverflow

Q33.

C onsider the following parse tree for the expression a#b$c$d#e#f, involving two binary operators $ and #. Which one of the following is correct for the given parse tree?
GateOverflow

Q34.

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

Q35.

Recursive descent parsing is an example of
GateOverflow

Q36.

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

Q37.

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

Q38.

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

Q39.

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

Q40.

Which statement is true?
GateOverflow