The Gateway to Computer Science Excellence
0 votes
373 views

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.
in Compiler Design by
retagged by | 373 views

1 Answer

0 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
by

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,345 questions
60,522 answers
201,950 comments
95,372 users