static void QuantifierNode_Description_Test(int? min, int? max, string expected)
 {
     var node = new QuantifierNode("data", 0, min, max, new ExpressionNode("data", 0));
     Assert.AreEqual(expected, node.Description);
 }
        static Node BuildQuantifierNode(IEnumerable<Token> quantifierTokens, TreeBuilderState state, int? min, int? max)
        {
            var targetNode = state.ProcessingState.TargetNode;
            var previousNodes = targetNode.Children;

            if (previousNodes.None())
                return new ParseFailureNode(quantifierTokens.First(), "Nothing preceeding the quantifier.");

            var immediatelyPriorNode = previousNodes.Last();

            // If there's a multi-character literal then we need to split it up
            Node nodeToQuantify;
            Node nodeToInsertBeforeQuantifier = null;
            if (immediatelyPriorNode is LiteralNode &&
                immediatelyPriorNode.Data.Length > 1)
            {
                var originalLiteralData = immediatelyPriorNode.Data;

                nodeToQuantify = new LiteralNode(
                    originalLiteralData.Substring(originalLiteralData.Length - 1),
                    immediatelyPriorNode.StartIndex + originalLiteralData.Length - 1);
                nodeToInsertBeforeQuantifier = new LiteralNode(
                    originalLiteralData.Substring(0, originalLiteralData.Length - 1),
                    immediatelyPriorNode.StartIndex);
            }
            else
            {
                nodeToQuantify = immediatelyPriorNode;
            }

            var quantifierNode = new QuantifierNode(
                nodeToQuantify.Data + Token.GetData(quantifierTokens),
                nodeToQuantify.StartIndex,
                min,
                max,
                nodeToQuantify
                );

            targetNode.ReplaceLastChild(nodeToInsertBeforeQuantifier, quantifierNode);

            return null;
        }
 public bool Equals(QuantifierNode other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return base.Equals(other) && other.min.Equals(min) && other.max.Equals(max);
 }