The Gateway to Computer Science Excellence
0 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.
in Compiler Design by Veteran (54.9k points)
retagged by | 42 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 Boss (13.4k points)

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
50,644 questions
56,516 answers
101,133 users