示例#1
0
        public CommentNode Parse(IEnumerator <LexerItem> items)
        {
            var root = new CommentNode();

            this.Parse(root, items);
            return(root);
        }
示例#2
0
        private CommentNode Parse(XmlLexerItem item, IEnumerator <LexerItem> items)
        {
            var node = new CommentNode(item);

            if (!item.IsCloseTag)
            {
                this.Parse(node, items, xml => !xml.IsOpenTag && xml.IsCloseTag && xml.TagName == item.TagName);
            }

            return(node);
        }
示例#3
0
        internal CommentNode Add(CommentNode node)
        {
            node.Parent = this;
            var last = this.children.LastOrDefault();

            if (last != null)
            {
                last.Next     = node;
                node.Previous = last;
            }
            this.children.Add(node);
            return(node);
        }
示例#4
0
        private void Parse(CommentNode root, IEnumerator <LexerItem> items, Predicate <XmlLexerItem> shouldCloseAfter)
        {
            while (items.MoveNext())
            {
                var item = items.Current;
                if (item is XmlLexerItem xmlItem)
                {
                    root.Add(this.Parse(xmlItem, items));

                    if (shouldCloseAfter(xmlItem))
                    {
                        return;
                    }
                }
                else if (item is TextLexerItem textItem)
                {
                    root.Add(new CommentNode(textItem));
                }
                else
                {
                    throw new InvalidOperationException($"Unhandled lexer item type '{item.GetType().Name}'.");
                }
            }
        }
示例#5
0
 private void Parse(CommentNode root, IEnumerator <LexerItem> items)
 {
     this.Parse(root, items, _ => false);
 }