This new sample shows how to create an arithmetic expression evaluator, so the application can evaluate a formula such as:
((a + b) ^(c / d)) * e
or
a + b + c * (d - e)
There some limitations due the way the parser was built:
. Only one letter variables are supported
. There is no numeric literal support. All values must be hold in variables
. Variables are case sensitive (a <> A)
The OO Cobol code is an improved version of Partha Kuchana Java Calculator sample : http://www.java2s.com/Code/Java/Design-Pattern/InterpreterPatternCalculator.htm
Click here to read the article!