Example #1
0
 public Formula(string formula)
 {
     Text = formula;
     try {
         evalNode = EvalNodeBuilder.Build(formula);
     } catch (Exception) {
         evalNode = new ValueNode(0);
     }
 }
Example #2
0
        public EvalNodeBuilder(List <string> postfix)
        {
            var tokens = new Queue <string>(postfix);

            while (tokens.Count > 0)
            {
                var token = tokens.Dequeue();

                if (OperatorLibrary.IsOperator(token))
                {
                    PushOperator(token);
                }
                else if (IsFunction(token))
                {
                    var arity = int.Parse(tokens.Dequeue());
                    PushFunction(token, arity);
                }
                else if (IsBool(token))
                {
                    PushBool(token);
                }
                else if (IsValue(token))
                {
                    PushValue(token);
                }
                else if (IsString(token))
                {
                    PushString(token);
                }
                else
                {
                    PushCellReferenceNode(token);
                }
            }
            Root = treeNodes.Pop();
        }
Example #3
0
 public void AddChild(EvalNode child)
 {
     children.Insert(0, child);
 }
Example #4
0
 public Formula()
 {
     Text     = "0";
     evalNode = new ValueNode(0);
 }