示例#1
0
        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);
        }
示例#2
0
        static Node ParseToken(BalanceData data, string s)
        {
            double result;

            if (double.TryParse(s, out result))
            {
                return(new ConstNode(result));
            }

            return(new VariableNode(data, s));
        }
示例#3
0
 public VariableNode(BalanceData data, string key)
 {
     this.data = data;
     this.key  = key;
 }
示例#4
0
 public BalanceStringEvaluator(BalanceData data)
 {
     this.data = data;
 }