Professional Documents
Culture Documents
CMP 401 Emma
CMP 401 Emma
S S *
S S + a
a a
C. What language is generated by this grammar?
Solution
L = {Postfix expression consisting of digits, plus and various signs}
The language of the grammar is infinite.
b. S +SS | -SS | a
L = {Prefix expression having plus and minus signs}
c. S S(S) S | ε
L = {matched brackets of arbitrary arrangement and nesting includes ε}
Therefore the language of the grammar is finite.
d. S aSbS | bSaS |ε
L = {string has the same amount of a and b, includes ε}
The language consists of infinite number of strings, therefore the language of the grammar
is infinite.