public CodeGenerator(ASTNodeBase tree)
        {
            if (tree == null)
            {
                throw new ArgumentException("Tree can´t be null", "tree");
            }

            _code = string.Empty;
            _tree = tree;
        }
        private void GenerateInternal(ASTNodeBase node)
        {
            AddCode(node.PreCode());

            if (node.LeftNode != null)
            {
                GenerateInternal(node.LeftNode);
            }

            if (node.RightNode != null)
            {
                GenerateInternal(node.RightNode);
            }

            AddCode(node.PostCode());
        }
        public static IEnumerable<ASTNodeBase> PreOrderWalk(ASTNodeBase rootNode)
        {
            var stack = new Stack<ASTNodeBase>();

            if (rootNode != null)
            {
                stack.Push(rootNode);
            }

            while (stack.Count > 0)
            {
                for (ASTNodeBase current = stack.Pop(); current != null; current = current.LeftNode)
                {
                    yield return current;

                    if (current.RightNode != null)
                    {
                        stack.Push(current.RightNode);
                    }
                }
            }
        }