Example #1
0
        public void Validate()
        {
            MyStack stack       = new MyStack();
            int     white_space = 0;

            foreach (HtmlTag x in this.queue)
            {
                if (x.GetIsOpenTag())
                {
                    if (x.IsSelfClosing())
                    {
                        for (int i = 0; i < white_space; i++)
                        {
                            Console.Write(this.space);
                        }

                        Console.WriteLine(x);
                    }
                    else
                    {
                        for (int i = 0; i < white_space; i++)
                        {
                            Console.Write(this.space);
                        }
                        white_space++;

                        Console.WriteLine(x);
                        stack.Push(x);
                    }
                }
                else
                {
                    if (stack.IsEmpty())
                    {
                        Console.WriteLine("ERROR unexpected tag: " + x);
                    }
                    else
                    {
                        if (x.Matches(stack.Peek()))
                        {
                            white_space--;
                            for (int i = 0; i < white_space; i++)
                            {
                                Console.Write(this.space);
                            }

                            Console.WriteLine(x);
                            stack.Pop();
                        }
                        else
                        {
                            Console.WriteLine("ERROR unexpected tag: " + x);
                        }
                    }
                }
            }

            while (!stack.IsEmpty())
            {
                Console.WriteLine("ERROR unclosed tag: " + stack.Peek());
                stack.Pop();
            }
        }
Example #2
0
 public void Init()
 {
     this.stack = new MyStack();
 }