예제 #1
0
        public void Visit(BracketNode node)
        {
            if (node.ChildNodes[0].Token.TokenType == TokenType.Not)
            {
                node.ChildNodes[0].Accept(this);
                return;
            }

            INode current = node;

            while (current.ChildNodes[0].Token.TokenType == TokenType.Concatenation)
            {
                current = node.ChildNodes[0];
            }

            var nodes = new LiteralNodeCollection();

            foreach (var expandedNode in Expand(current))
            {
                if (nodes.Contains(expandedNode) == false)
                {
                    nodes.Add(expandedNode);
                }
            }

            var index = RandomNumberProvider.GetRandomNumber(0, nodes.Count);

            nodes[index].Accept(this);
        }
예제 #2
0
        public void Visit(NotNode node)
        {
            var nodes = new LiteralNodeCollection();

            for (var i = 32; i < 126; i++)
            {
                nodes.Add(NodeBuilder.BuildLiteralNode(TokenBuilder.BuildLiteralToken((char)i)));
            }

            INode current = node;

            while (current.ChildNodes[0].Token.TokenType == TokenType.Concatenation)
            {
                current = node.ChildNodes[0];
            }

            foreach (var expandedNode in Expand(current))
            {
                if (nodes.Contains(expandedNode))
                {
                    nodes.Remove(expandedNode);
                }
            }

            var index = RandomNumberProvider.GetRandomNumber(0, nodes.Count);

            nodes[index].Accept(this);
        }
예제 #3
0
        public void Visit(RangeNode node)
        {
            var min     = (int)((LiteralNode)node.ChildNodes[0]).Token.Character;
            var max     = (int)((LiteralNode)node.ChildNodes[1]).Token.Character;
            var index   = RandomNumberProvider.GetRandomNumber(min, max + 1);
            var literal = new LiteralNode(TokenBuilder.BuildLiteralToken((char)index));

            literal.Accept(this);
        }
예제 #4
0
        public void Visit(RepetitionNode node)
        {
            var index = RandomNumberProvider.GetRandomNumber(node.Token.MinOccurs, node.Token.MaxOccurs > -1 ? node.Token.MaxOccurs + 1 : DefaultMaxOccurs);

            for (var i = 0; i < index; i++)
            {
                foreach (var childNode in node.ChildNodes)
                {
                    childNode.Accept(this);
                }
            }
        }
예제 #5
0
        public void Visit(AlternationNode node)
        {
            var index = RandomNumberProvider.GetRandomNumber(0, 2);

            node.ChildNodes[index].Accept(this);
        }