Revisit problem 3.3 (the exercise about the Composite pattern). Extend the implementation of the "while" language with expressions, which were left empty. The abstract syntax of expressions isExpr := Variable | Operation Expr Exprwhere "Variable" is an identifier or a literal and "Operation" is a familiar infix operation, such as add, sub, mul, etc.Design, code and test two programs: one in which the objects representing variables (and literals) are not shared and another which adopts the Flyweight pattern and shares all occurences of the same variable (or literal).
As in the original problem, it suffices to contruct the representation of a program and print it.