Home / Expert Answers / Computer Science / consider-the-context-free-grammar-cfg-mathrm-s-rightarrow-mathrm-ab-quad-s-being-t-pa463

(Solved): Consider the context free grammar (CFG): \( \mathrm{S} \rightarrow \mathrm{AB} \quad \) (S being t ...



Consider the context free grammar (CFG):
\( \mathrm{S} \rightarrow \mathrm{AB} \quad \) (S being the start symbol)
\( \mathrm

Consider the context free grammar (CFG): \( \mathrm{S} \rightarrow \mathrm{AB} \quad \) (S being the start symbol) \( \mathrm{A} \rightarrow \mathrm{aAb} \mid \) aabb \( \mathrm{B} \rightarrow \mathrm{cBd} \mid \) cd The grammar is strong LL(k). a) Determine the value of \( k \). b) As a result of a) above, compute the corresponding look ahead sets (for each production). c) As a result of \( \mathrm{b} \) ) above, write (in \( \mathrm{C}++ \) pseudo code) the corresponding recursive descent parser (for the grammar). \( \mathrm{NB} \) : Assume that 1. the procedure: void expect(char token), has been coded appropriately 2. The next k symbols will be contained in the character array: symbol 3. the procedure: bool equal(char \( * \operatorname{str} 1, \operatorname{char} * \operatorname{str} 2) \), has been coded appropriately to compare the two \( \mathrm{C}(++) \) strings, str1 and str2. \( [1]+[5]+[(2)+(6)+(6)] \)


We have an Answer from Expert

View Expert Answer

Expert Answer


a) To determine the value of k, we need to consider the maximum number of look-ahead symbols needed to determine which production to use at each point
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe