public int Eval(string s) { if (string.IsNullOrEmpty(s)) throw new Exception(); var elements = new ElementList(parser.Parse(s)); var operation = elements.FindOperation(); while (operation != null) { var newElement = operation.Compute(); elements.ReplaceOperation(operation, newElement); operation = elements.FindOperation(); } return elements.First.Value; }
public int Eval(string s) { if (string.IsNullOrEmpty(s)) { throw new Exception(); } var elements = new ElementList(parser.Parse(s)); var operation = elements.FindOperation(); while (operation != null) { var newElement = operation.Compute(); elements.ReplaceOperation(operation, newElement); operation = elements.FindOperation(); } return(elements.First.Value); }