static Node Treeify(BalanceData data, List <string> input, int start, int end) { if (end < start) { return(null); } if (end == start) { return(ParseToken(data, input[start])); } int index = FindHighestPriorityOperationIndex(input, start, end); if (index == -1) { throw new Exception(); } var op = ParseOperation(input[index]); op.Left = Treeify(data, input, start, index - 1); op.Right = Treeify(data, input, index + 1, end); return(op); }
static Node ParseToken(BalanceData data, string s) { double result; if (double.TryParse(s, out result)) { return(new ConstNode(result)); } return(new VariableNode(data, s)); }
public VariableNode(BalanceData data, string key) { this.data = data; this.key = key; }
public BalanceStringEvaluator(BalanceData data) { this.data = data; }