retagged by
10,861 views
4 votes
4 votes

Consider the context-free grammar:$$S\rightarrow SS + \mid SS {\ast} \mid a$$and the string $aa + a{\ast}$.

  1. Give a leftmost derivation for the string.
  2. Give a rightmost derivation for the string.
  3. Give a parse tree for the string.
  4. Is the grammar ambiguous or unambiguous? Justify your answer.
  5. Describe the language generated by this grammar.
retagged by

1 Answer

1 votes
1 votes
  1. S =lm=> SS* => SS+S* => aS+S* => aa+S* => aa+a*
  2. S =rm=> SS* => Sa* => SS+a* => Sa+a* => aa+a*
  3. Unambiguous
  4. The set of all postfix expressions consist of addition and multiplication

Related questions

0 votes
0 votes
0 answers
2
1 votes
1 votes
2 answers
3