Menu

[Solved]Context Free Grammar Arithmetic Expressions Alphabet Int S S S S S S S S S Int Valid Examp Q37263070

Context free grammar for arithmetic expressions over thealphabet {int, (, ), +, -} is:

S -> S + S

S -> S – S

S -> (S)

S -> int

Some valid example expressions are:  (int), int , (int+ (int – int))

Some invalid example expressions are: (int , int + (int – ,int)

  1. Convert this grammar to an empty stack Push Down Automata (PDA)with a single state allowing multiple stack operations in one PDAtransition.
  2. Using solution from (1), find a sequence of PDA transitions toshow that the expression

(int + (int – int)) is valid for the grammar.At each step of the sequence, indicate the contents of the stackand the PDA transition used.

Expert Answer


Answer to Context free grammar for arithmetic expressions over the alphabet {int, (, ), +, -} is: S -> S + S S -> S – S S -> (S)… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *