COSC5315 Program-4 Due: 12/3/2012 CFG Reduction Task: Write a program that will reduce an input CF grammar by eliminating all useless symbols, all empty-production rules, and all unit-productions. Your program will output the following: a. The input grammar rules. b. All useless symbols found. c. The resulting grammar after all useless symbols have been eliminated. d. All nullable nonterminals. e. All unit productions including those to be derived. f. The final reduced grammar obtained after eliminating all empty-production rules followed by eliminating all unit-productions. Input grammar: (Note that every Nonterminal must appear at least once on the LHS of a production rule. Hence if a symbol does not appear even once as the LHS of a production rule, it must be a terminal symbol.) Program --> Block Block --> begin Body end Body --> S ; Body Body --> S S --> Dec SS Dec --> int IdList Dec --> real IdList Dec --> Empty-string SS --> Block SS --> Id = Exp SS --> Print ExpList SR SS --> Print IdList SS --> Empty-string SS --> If Exp then SS SS --> If Exp then SS else SS SS --> Read IdList IdList --> Id , IdList IdList --> Id Id --> aa Id --> bb Id --> cc SR --> SS : SR ExpList --> Exp ExpList --> Exp , ExpList Exp --> Exp + Term Exp --> Exp * Term Exp --> Exp ^ Term Exp --> Empty-string Exp --> Term Term --> id Term --> ( Exp )