예제 #1
0
        private void CreateNode()
        {
            var node = new HmlNode(this.indent, this.nodeName, this.nodeText, this.nodeProperties, this.position);

            if (stack.Count == 0)
            {
                stack.Push(node);
            }
            else
            {
                HmlNode parent = null;

                while (stack.Count > 0 && (parent = stack.First()).Indent >= node.Indent)
                {
                    parent = stack.Pop();
                }

                if (stack.Count == 0)
                {
                    throw new HmlParsingException(lastToken, "node has a greater level than the root node");
                }

                stack.Push(node);
                parent.Add(node);
            }

            this.EndNode();
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Hml.Parser.HmlDocument"/> class.
 /// </summary>
 /// <param name="root">The root node.</param>
 /// <param name="tokens">The parsed tokens.</param>
 public HmlDocument(HmlNode root, HmlToken[] tokens)
 {
     this.Root   = root;
     this.Tokens = tokens;
 }