A simple string - math parser. There are three implementations but only one that supports nested parentheses
###The different implementations:
- ShuntingYardCalculator.cs an implementation of the shunting-yard algorithm. The core implementation is not my own, it is taken from here - http://www.codeproject.com/Tips/351042/Shunting-Yard-algorithm-in-Csharp. Dont re-invent the wheel, and re-invent it square shaped! - Does not work with multiple parentheses
- StackCalculator - an attempt at #1 without RPN, works without parentheses
- ListCalculator - after been blinkered toward RPN / Shunting yard with stack, just used a plain old list, indexes, indexOf and lastIndex of. Works with multiple brackets.
The main program.cs is currently using the working version. To switch either run the tests or grab a different calculator from the calculator factory.
###Running it
To get up and running:
- Clone this repo
- Enable nuget package restore in VS and build
- Run the MathParser .exe console application
###Parser Rules The parser must be able to convert the following rules to operators
Rules:
a = '+', b = '-', c = '*', d = '/', e = '(', f = ')'
The parser must respect left to right presendense, including inside of parentheses