private String RenderNode(ProgramNode node)
        {
            StringBuilder result = new StringBuilder();

            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                ProgramNode childNode = node.GetChildNode(i);
                result.Append(RenderNode(childNode));
            }

            result.Append('[');
            result.Append(node.Name);
            result.Append(':');
            result.Append(node.Template.ChildNodeCount);

            for (int i = 0; i < node.Template.DataSize; i++)
            {
                result.Append(':');
                EPLValueType t = node.Data[i].ExprType;
                if (t == EPLValueType.BooleanType)
                {
                    result.Append(node.Data[i].ToBooleanValue() ? 't' : 'f');
                }
                else if (t == EPLValueType.FloatingType)
                {
                    result.Append(CSVFormat.EgFormat.Format(node.Data[i].ToFloatValue(), EncogFramework.DefaultPrecision));
                }
                else if (t == EPLValueType.IntType)
                {
                    result.Append(node.Data[i].ToIntValue());
                }
                else if (t == EPLValueType.EnumType)
                {
                    result.Append(node.Data[i].EnumType);
                    result.Append("#");
                    result.Append(node.Data[i].ToIntValue());
                }
                else if (t == EPLValueType.StringType)
                {
                    result.Append("\"");
                    result.Append(node.Data[i].ToStringValue());
                    result.Append("\"");
                }
            }
            result.Append(']');

            return result.ToString().Trim();
        }
 private String RenderFunction(ProgramNode node)
 {
     StringBuilder result = new StringBuilder();
     result.Append(node.Name);
     result.Append('(');
     for (int i = 0; i < node.ChildNodes.Count; i++)
     {
         if (i > 0)
         {
             result.Append(',');
         }
         ProgramNode childNode = node.GetChildNode(i);
         result.Append(RenderNode(childNode));
     }
     result.Append(')');
     return result.ToString();
 }
        private String RenderNode(ProgramNode node)
        {
            StringBuilder result = new StringBuilder();

            ExpressionNodeType t = this.DetermineNodeType(node);

            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                ProgramNode childNode = node.GetChildNode(i);
                if (result.Length > 0)
                {
                    result.Append(" ");
                }
                result.Append(RenderNode(childNode));
            }

            if (result.Length > 0)
            {
                result.Append(" ");
            }

            if (t == ExpressionNodeType.ConstVal)
            {
                result.Append(HandleConst(node));
            }
            else if (t == ExpressionNodeType.Variable)
            {
                result.Append(HandleVar(node));
            }
            else if (t == ExpressionNodeType.Function || t == ExpressionNodeType.Operator)
            {
                result.Append('[');
                result.Append(node.Name);

                result.Append(']');
            }

            return result.ToString().Trim();
        }
 private String RenderOperator(ProgramNode node)
 {
     StringBuilder result = new StringBuilder();
     result.Append("(");
     result.Append(RenderNode(node.GetChildNode(0)));
     result.Append(node.Name);
     result.Append(RenderNode(node.GetChildNode(1)));
     result.Append(")");
     return result.ToString();
 }
        private String HandleFunction(ProgramNode node)
        {
            IProgramExtensionTemplate temp = node.Template;
            StringBuilder result = new StringBuilder();

            if (temp == StandardExtensions.EXTENSION_SQRT)
            {
                result.Append("\\sqrt{");
                result.Append(RenderNode(node.GetChildNode(0)));
                result.Append("}");
            }
            else
            {
                result.Append(temp.Name);
                result.Append('(');
                for (int i = 0; i < temp.ChildNodeCount; i++)
                {
                    if (i > 0)
                    {
                        result.Append(',');
                    }
                    result.Append(RenderNode(node.GetChildNode(i)));
                }
                result.Append(')');
            }
            return result.ToString();
        }
        private String HandleOperator(ProgramNode node)
        {
            IProgramExtensionTemplate temp = node.Template;
            StringBuilder result = new StringBuilder();

            if (temp.ChildNodeCount == 2)
            {
                String a = RenderNode(node.GetChildNode(0));
                String b = RenderNode(node.GetChildNode(1));

                if (temp == StandardExtensions.EXTENSION_DIV)
                {
                    result.Append("\\frac{");
                    result.Append(b);
                    result.Append("}{");
                    result.Append(a);
                    result.Append("}");
                }
                else if (temp == StandardExtensions.EXTENSION_MUL)
                {
                    result.Append("(");
                    result.Append(b);
                    result.Append("\\cdot ");
                    result.Append(a);
                    result.Append(")");
                }
                else
                {
                    result.Append("(");
                    result.Append(b);
                    result.Append(temp.Name);
                    result.Append(a);
                    result.Append(")");
                }

            }
            else if (temp.ChildNodeCount == 1)
            {
                String a = RenderNode(node.GetChildNode(0));
                result.Append("(");
                result.Append(temp.Name);
                result.Append(a);
                result.Append(")");
            }
            else
            {
                throw new EACompileError(
                        "An operator must have an arity of 1 or 2, probably should be made a function.");
            }

            return result.ToString();
        }