コード例 #1
0
        private void AddLiteralNodes(RegexResultTreeNode regexResultTreeNode, string toMatch)
        {
            int currentIndex = regexResultTreeNode.StartIndex;
            List <LiteralNode> literalNodes = new List <LiteralNode>();

            foreach (RegexResultTreeNode child in regexResultTreeNode.ChildNodes)
            {
                AddLiteralNode(literalNodes, currentIndex, child.StartIndex, toMatch);
                AddLiteralNodes(child, toMatch);
                currentIndex = child.EndIndex;
            }
            AddLiteralNode(literalNodes, currentIndex, regexResultTreeNode.EndIndex, toMatch);
            foreach (LiteralNode literalNode in literalNodes)
            {
                regexResultTreeNode.AddChildNode(literalNode);
            }
        }
コード例 #2
0
        public int CompareTo(object obj)
        {
            RegexResultTreeNode other = obj as RegexResultTreeNode;

            if (this.StartIndex < other.StartIndex)
            {
                return(-1);
            }
            if (other.StartIndex < this.StartIndex)
            {
                return(1);
            }
            if (this.EndIndex < other.EndIndex)
            {
                return(-1);
            }
            if (other.EndIndex < this.EndIndex)
            {
                return(1);
            }
            return(0);
        }
コード例 #3
0
        private void AddRegexResultTreeNode(RegexResultTreeNode parent, RegexResultTreeNode child)
        {
            List <RegexResultTreeNode> toRemove = new List <RegexResultTreeNode>();

            foreach (RegexResultTreeNode otherNode in parent.ChildNodes)
            {
                if (child.IsChildOf(otherNode))
                {
                    AddRegexResultTreeNode(otherNode, child);
                    return;
                }
                else if (otherNode.IsChildOf(child))
                {
                    toRemove.Add(otherNode);
                    child.AddChildNode(otherNode);
                }
            }
            foreach (RegexResultTreeNode node in toRemove)
            {
                parent.RemoveChildNode(node);
            }
            parent.AddChildNode(child);
        }
コード例 #4
0
 public bool IsChildOf(RegexResultTreeNode other)
 {
     return(this.StartIndex >= other.StartIndex && this.EndIndex <= other.EndIndex);
 }
コード例 #5
0
 public void RemoveChildNode(RegexResultTreeNode child)
 {
     children.Remove(child);
 }
コード例 #6
0
 public void AddChildNode(RegexResultTreeNode child)
 {
     children.Add(child, child);
 }